Free Hero Mesh

Check-in [c3370d4109]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement CONFIG_OMIT_INCLUDE
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c3370d41090a59a71d355a82b9ffbb1dc863222f
User & Date: user on 2023-03-29 23:50:29
Other Links: manifest | tags
Context
2023-03-31
17:21
Fix {edit <number>} so that it replaces the entire argument if it begins with an opening delimiter ("{" or "("). check-in: 563de83a02 user: user tags: trunk
2023-03-29
23:50
Implement CONFIG_OMIT_INCLUDE check-in: c3370d4109 user: user tags: trunk
23:46
Correct a memory leak in the recent change to the {edit} macro check-in: 54b97e96bb user: user tags: trunk
Changes

Modified class.c from [b7fec654af] to [32f95c9ffe].

635
636
637
638
639
640
641

642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660

661
662
663
664
665
666
667
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669







+



















+







    // This token will be skipped during macro expansion.
    tokent=TF_MACRO+TF_ABNORMAL;
    *tokenstr=0;
    macros[glohash[name].id-0xC000]=add_macro();
  }
}

#ifndef CONFIG_OMIT_INCLUDE
static void begin_include_file(const char*name) {
  InputStack*nxt=inpstack;
  inpstack=malloc(sizeof(InputStack));
  if(!inpstack) fatal("Allocation failed\n");
  inpstack->classfp=classfp;
  inpstack->linenum=linenum;
  inpstack->next=nxt;
  linenum=1;
  if(main_options['S']) fatal("Cannot use {include} with level hash calculation mode\n");
  if(*name=='.' || *name=='_' || *name=='-' || !*name || name[strspn(name,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-abcdefghijklmnopqrstuvwxyz.")])
   ParseError("Improper name of include file \"%s\"\n",name);
  if(main_options['z']) {
    if(strlen(name)<9 || memcmp(name-strlen(name),".include",8)) ParseError("Include file name doesn't end with .include\n");
    classfp=composite_slice(name,0)?:fopen(name,"r");
  } else {
    classfp=fopen(name,"r");
  }
  if(!classfp) ParseError("Cannot open include file \"%s\": %m\n",name);
}
#endif

static void begin_macro(TokenList*mac) {
  MacroStack*ms=malloc(sizeof(MacroStack));
  TokenList**ap=0;
  int a=0;
  int b=0;
  int c=0;
1017
1018
1019
1020
1021
1022
1023



1024
1025
1026
1027
1028
1029
1030
1031
1032

1033
1034
1035
1036
1037
1038
1039
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045







+
+
+









+







            if(!macros) fatal("Allocation failed\n");
          }
          nxttok();
          if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
          define_macro(look_hash_mac(),1);
          goto again;
        case MAC_INCLUDE:
#ifdef CONFIG_OMIT_INCLUDE
          ParseError("The {include} macro has been omitted from this version\n");
#else
          if(macstack) ParseError("Cannot use {include} inside of a macro\n");
          nxttok1();
          if(tokent==TF_MACRO && tokenv==1) ReturnToken(TF_EOF,0);
          if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
          n=look_hash_mac();
          nxttok1();
          if(tokent!=TF_MACRO+TF_CLOSE) ParseError("Too many macro arguments\n");
          begin_include_file(glohash[n].txt);
          goto again;
#endif
        case MAC_CALL:
          nxttok();
          if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
          tokenv=look_hash_mac();
          goto call;
        case MAC_APPEND:
          if(!macros) {

Modified comconfig.doc from [84d41654b9] to [0ab9c905fe].

40
41
42
43
44
45
46



47
48
49
50
51
52
53
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







+
+
+







  If defined, then portable mode by checking argv[0] is disabled. (It is
  still possible to use portable mode by HEROMESH_PREFIX)

CONFIG_NO_STATUS
  If defined, then most status output is omitted unless -v is specified.
  (Some status output, such as most error messages, are still displayed.)

CONFIG_OMIT_INCLUDE
  If defined, then the {include} macro is not implemented.

CONFIG_OMIT_SOUND
  If defined, omit all sound capabilities (including music). (Even if it
  is not defined, it can still be disabled at runtime.)

CONFIG_USING_32BIT_TIMESTAMPS
  If defined, force use of 32-bit timestamps. (This is needed in order to
  avoid compiler warnings on some systems, such as some versions of the