Free Hero Mesh

Check-in [4ce94e1d08]
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:The previous attempted fix of trying to call a macro whose definition is empty had a problem with defining new macros. Instead, make a macro with a single TF_MACRO+TF_ABNORMAL token if it is empty, and skip the TF_MACRO+TF_ABNORMAL token during expansion.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4ce94e1d08056ff116b4899d1719344528b3749b
User & Date: user on 2022-08-05 06:22:01
Other Links: manifest | tags
Context
2022-08-05
08:52
Fix a mistake in picedit.c with freeing memory after saving a multidependent picture. check-in: 95af598a76 user: user tags: trunk
06:22
The previous attempted fix of trying to call a macro whose definition is empty had a problem with defining new macros. Instead, make a macro with a single TF_MACRO+TF_ABNORMAL token if it is empty, and skip the TF_MACRO+TF_ABNORMAL token during expansion. check-in: 4ce94e1d08 user: user tags: trunk
05:37
Fix the {include} macro file name dealing (to allow lowercase letters), and fix the case of trying to call a macro whose definition is empty. check-in: 00437dafd6 user: user tags: trunk
Changes

Modified class.c from [bbafd4c28a] to [7edc77ca68].

415
416
417
418
419
420
421

422
423
424
425
426
427
428
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429







+







        ms->args=0;
        ms->next=macstack;
        macstack=ms;
      }
      if(main_options['M']) printf("M^ %d\n",tl?1:0);
      goto magain;
    }
    if(tokent==TF_MACRO+TF_ABNORMAL) goto magain; // denotes a empty macro
    return;
  }
  fl=n=pr=0;
  tokent=tokenv=0;
  *tokenstr=0;
  again:
  c=fgetc(classfp);
619
620
621
622
623
624
625







626
627
628
629
630
631
632
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640







+
+
+
+
+
+
+







    }
    if(tokent==TF_MACRO+TF_OPEN && ++i>65000) ParseError("Too much macro nesting\n");
    if(tokent==TF_MACRO+TF_CLOSE && !--i) break;
    *t=add_macro();
    t=&(*t)->next;
  }
  if(main_options['M']) printf("M> %04X %04X %p\n",name,glohash[name].id,macros[glohash[name].id-0xC000]);
  if(!macros[glohash[name].id-0xC000]) {
    // The macro is empty, so add a token which denotes a empty macro.
    // This token will be skipped during macro expansion.
    tokent=TF_MACRO+TF_ABNORMAL;
    *tokenstr=0;
    macros[glohash[name].id-0xC000]=add_macro();
  }
}

static void begin_include_file(const char*name) {
  InputStack*nxt=inpstack;
  inpstack=malloc(sizeof(InputStack));
  if(!inpstack) fatal("Allocation failed\n");
  inpstack->classfp=classfp;
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
655
656
657
658
659
660
661





















662
663
664
665
666
667
668







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







static void begin_macro(TokenList*mac) {
  MacroStack*ms=malloc(sizeof(MacroStack));
  TokenList**ap=0;
  int a=0;
  int b=0;
  int c=0;
  if(StackProtection()) fatal("Stack overflow\n");
  if(!mac) {
    // In case of a empty macro
    free(ms);
    for(;;) {
      nxttok1();
      if(tokent&TF_EOF) ParseError("Unexpected end of file in macro argument\n");
      if(tokent&TF_OPEN) {
        ++a;
        if(tokent&TF_MACRO) ++c;
      }
      if(tokent&TF_CLOSE) {
        --a;
        if(tokent&TF_MACRO) --c;
      }
      if(c==-1) {
        if(a!=-1 && !b) ParseError("Misnested macro argument\n");
        return;
      }
    }
    return;
  }
  ref_macro(mac);
  if(!ms) fatal("Allocation failed\n");
  ms->tok=mac;
  ms->n=0;
  ms->args=0;
  for(;;) {
    nxttok1();

Modified comconfig.doc from [e827074f10] to [67db4df1f4].

12
13
14
15
16
17
18
19


20
21
22


23
24
25
26
27
28
29
12
13
14
15
16
17
18

19
20
21
22

23
24
25
26
27
28
29
30
31







-
+
+


-
+
+







  decimal notation, as a string token (not as a numeric token).

CONFIG_DEFAULT_RESOURCES
  If defined, read resource configuration from the specified file if
  it cannot find the configuration file in the home directory.

CONFIG_GLOBAL_HASH_SIZE
  Size of global hash table when reading class definition file.
  Size of global hash table when reading class definition file. This must
  be less than 65535.

CONFIG_LOCAL_HASH_SIZE
  Size of local hash table when reading class definition file.
  Size of local hash table when reading class definition file. This must
  be less than 65535.

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

CONFIG_USING_32BIT_TIMESTAMPS
  If defined, force use of 32-bit timestamps. (This is needed in order to