Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [bbafd4c28a]:

To Artifact [7edc77ca68]:


415
416
417
418
419
420
421

422
423
424
425
426
427
428
        ms->args=0;
        ms->next=macstack;
        macstack=ms;
      }
      if(main_options['M']) printf("M^ %d\n",tl?1:0);
      goto magain;
    }

    return;
  }
  fl=n=pr=0;
  tokent=tokenv=0;
  *tokenstr=0;
  again:
  c=fgetc(classfp);







>







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
    }
    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]);







}

static void begin_include_file(const char*name) {
  InputStack*nxt=inpstack;
  inpstack=malloc(sizeof(InputStack));
  if(!inpstack) fatal("Allocation failed\n");
  inpstack->classfp=classfp;







>
>
>
>
>
>
>







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







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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





















  ref_macro(mac);
  if(!ms) fatal("Allocation failed\n");
  ms->tok=mac;
  ms->n=0;
  ms->args=0;
  for(;;) {
    nxttok1();