small improvements

This commit is contained in:
Roberto Ierusalimschy 1996-02-14 16:11:09 -03:00
parent 45cf24485d
commit 15c17c24fa
2 changed files with 7 additions and 11 deletions

8
lex.c
View File

@ -1,4 +1,4 @@
char *rcs_lex = "$Id: lex.c,v 2.26 1996/02/13 17:30:39 roberto Exp roberto $"; char *rcs_lex = "$Id: lex.c,v 2.27 1996/02/14 13:35:51 roberto Exp roberto $";
#include <ctype.h> #include <ctype.h>
@ -16,8 +16,6 @@ char *rcs_lex = "$Id: lex.c,v 2.26 1996/02/13 17:30:39 roberto Exp roberto $";
#define MINBUFF 260 #define MINBUFF 260
#define lua_strcmp(a,b) (a[0]<b[0]?(-1):(a[0]>b[0]?(1):strcmp(a,b)))
#define next() { current = input(); } #define next() { current = input(); }
#define save(x) { *yytextLast++ = (x); } #define save(x) { *yytextLast++ = (x); }
#define save_and_next() { save(current); next(); } #define save_and_next() { save(current); next(); }
@ -165,12 +163,12 @@ int luaY_lex (void)
while (isalnum(current) || current == '_') while (isalnum(current) || current == '_')
save_and_next(); save_and_next();
*yytextLast = 0; *yytextLast = 0;
if (lua_strcmp(yytext, "debug") == 0) if (strcmp(yytext, "debug") == 0)
{ {
luaY_lval.vInt = 1; luaY_lval.vInt = 1;
return DEBUG; return DEBUG;
} }
else if (lua_strcmp(yytext, "nodebug") == 0) else if (strcmp(yytext, "nodebug") == 0)
{ {
luaY_lval.vInt = 0; luaY_lval.vInt = 0;
return DEBUG; return DEBUG;

10
tree.c
View File

@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio ** TecCGraf - PUC-Rio
*/ */
char *rcs_tree="$Id: tree.c,v 1.16 1996/02/12 18:32:40 roberto Exp roberto $"; char *rcs_tree="$Id: tree.c,v 1.17 1996/02/14 13:35:51 roberto Exp roberto $";
#include <string.h> #include <string.h>
@ -16,8 +16,6 @@ char *rcs_tree="$Id: tree.c,v 1.16 1996/02/12 18:32:40 roberto Exp roberto $";
#include "table.h" #include "table.h"
#define lua_streq(a,b) (a[0] == b[0] && strcmp(a,b) == 0)
#define NUM_HASHS 64 #define NUM_HASHS 64
typedef struct { typedef struct {
@ -30,7 +28,7 @@ static int initialized = 0;
static stringtable string_root[NUM_HASHS]; static stringtable string_root[NUM_HASHS];
static TaggedString EMPTY = {NOT_USED, NOT_USED, 0, 0, {0}}; static TaggedString EMPTY = {NOT_USED, NOT_USED, 0, 2, {0}};
static unsigned long hash (char *str) static unsigned long hash (char *str)
@ -92,7 +90,7 @@ static TaggedString *insert (char *str, stringtable *tb)
{ {
if (tb->hash[i] == &EMPTY) if (tb->hash[i] == &EMPTY)
j = i; j = i;
else if (lua_streq(str, tb->hash[i]->str)) else if (strcmp(str, tb->hash[i]->str) == 0)
return tb->hash[i]; return tb->hash[i];
i = (i+1)%tb->size; i = (i+1)%tb->size;
} }
@ -130,7 +128,7 @@ Long lua_strcollector (void)
for (j=0; j<tb->size; j++) for (j=0; j<tb->size; j++)
{ {
TaggedString *t = tb->hash[j]; TaggedString *t = tb->hash[j];
if (t != NULL && t != &EMPTY && t->marked <= 1) if (t != NULL && t->marked <= 1)
{ {
if (t->marked) if (t->marked)
t->marked = 0; t->marked = 0;