Index: class.c ================================================================== --- class.c +++ class.c @@ -417,10 +417,11 @@ 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; @@ -621,10 +622,17 @@ 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)); @@ -649,31 +657,10 @@ 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; Index: comconfig.doc ================================================================== --- comconfig.doc +++ comconfig.doc @@ -14,14 +14,16 @@ 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)