Free Hero Mesh

Check-in [224148554e]
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:Make the {include} macro safer, and allow it to work with composite puzzle sets too.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 224148554ee45cc721fa3f73e135995f61277cc5
User & Date: user on 2021-11-26 05:28:02
Other Links: manifest | tags
Context
2021-11-30
04:36
Display descriptions of inventory items when clicking them. check-in: 4ff3818394 user: user tags: trunk
2021-11-26
05:28
Make the {include} macro safer, and allow it to work with composite puzzle sets too. check-in: 224148554e user: user tags: trunk
05:12
Implement the "fork ... else ... then" block. check-in: f949f9c20d user: user tags: trunk
Changes

Modified class.c from [6a14969945] to [0a4452237b].

610
611
612
613
614
615
616

617




618

619
620
621
622
623
624
625
  InputStack*nxt=inpstack;
  inpstack=malloc(sizeof(InputStack));
  if(!inpstack) fatal("Allocation failed\n");
  inpstack->classfp=classfp;
  inpstack->linenum=linenum;
  inpstack->next=nxt;
  linenum=1;

  //TODO: Use the correct directory to load the include file




  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;







>
|
>
>
>
>
|
>







610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
  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_-")])
   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;

Modified class.doc from [cb772c239e] to [04a1165740].

186
187
188
189
190
191
192
193





194
195
196
197
198
199
200
  Edit a macro. This changes the first token of the definition of the macro
  (which must not be another macro) to the specified token (which also must
  not be another macro). The token is expanded, and must be a single token
  once it is expanded; that is what it will be replaced with.

{include <string>}
  Include text from another file into this one. You cannot use {include}
  inside of another macro or in a macro argument.






{make <mode> <arg>}
  Make a synthetic token; see the below section about synthetic tokens for
  details. The second argument can be a number, or a direction or key name
  which is treated as a number, or a string. In most cases, a number will
  be converted to a string with its unsigned decimal representation.








|
>
>
>
>
>







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
  Edit a macro. This changes the first token of the definition of the macro
  (which must not be another macro) to the specified token (which also must
  not be another macro). The token is expanded, and must be a single token
  once it is expanded; that is what it will be replaced with.

{include <string>}
  Include text from another file into this one. You cannot use {include}
  inside of another macro or in a macro argument. The file must be in the
  current directory, and its name must contain only letters, digits, dot,
  underscore, and minus signs, and must start with a letter or digit. If
  it is a composite puzzle set, then the name must end with ".include",
  and is looked for first inside of the composite puzzle set; if it is not
  found there then it is looked for in the current directory.

{make <mode> <arg>}
  Make a synthetic token; see the below section about synthetic tokens for
  details. The second argument can be a number, or a direction or key name
  which is treated as a number, or a string. In most cases, a number will
  be converted to a string with its unsigned decimal representation.