Free Hero Mesh

Check-in [00437dafd6]
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: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 00437dafd6975c6bff42aafdd11cc1e208dce78a
User & Date: user on 2022-08-05 05:37:13
Other Links: manifest | tags
Context
2022-08-05
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
2022-08-02
17:46
Implement /mod and ,/mod commands check-in: defb041af6 user: user tags: trunk
Changes

Modified class.c from [b256a9488a] to [bbafd4c28a].

629
630
631
632
633
634
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
629
630
631
632
633
634
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
670
671
672
673
674
675
676
677
678
679
680
681







-
+

















+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  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(*name=='.' || *name=='_' || *name=='-' || !*name || name[strspn(name,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-")])
  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);
}

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();