diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-14 16:11:09 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-02-14 16:11:09 -0300 |
commit | 15c17c24facb6d7e6f837b87927a54a40a54aa36 (patch) | |
tree | 4d0f1d0c49133ea06223627e1abd247c0ad78b6b | |
parent | 45cf24485de6738b44cd9a68738ae6a11b3827db (diff) | |
download | lua-15c17c24facb6d7e6f837b87927a54a40a54aa36.tar.gz lua-15c17c24facb6d7e6f837b87927a54a40a54aa36.tar.bz2 lua-15c17c24facb6d7e6f837b87927a54a40a54aa36.zip |
small improvements
-rw-r--r-- | lex.c | 8 | ||||
-rw-r--r-- | tree.c | 10 |
2 files changed, 7 insertions, 11 deletions
@@ -1,4 +1,4 @@ | |||
1 | char *rcs_lex = "$Id: lex.c,v 2.26 1996/02/13 17:30:39 roberto Exp roberto $"; | 1 | char *rcs_lex = "$Id: lex.c,v 2.27 1996/02/14 13:35:51 roberto Exp roberto $"; |
2 | 2 | ||
3 | 3 | ||
4 | #include <ctype.h> | 4 | #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 $"; | |||
16 | 16 | ||
17 | #define MINBUFF 260 | 17 | #define MINBUFF 260 |
18 | 18 | ||
19 | #define lua_strcmp(a,b) (a[0]<b[0]?(-1):(a[0]>b[0]?(1):strcmp(a,b))) | ||
20 | |||
21 | #define next() { current = input(); } | 19 | #define next() { current = input(); } |
22 | #define save(x) { *yytextLast++ = (x); } | 20 | #define save(x) { *yytextLast++ = (x); } |
23 | #define save_and_next() { save(current); next(); } | 21 | #define save_and_next() { save(current); next(); } |
@@ -165,12 +163,12 @@ int luaY_lex (void) | |||
165 | while (isalnum(current) || current == '_') | 163 | while (isalnum(current) || current == '_') |
166 | save_and_next(); | 164 | save_and_next(); |
167 | *yytextLast = 0; | 165 | *yytextLast = 0; |
168 | if (lua_strcmp(yytext, "debug") == 0) | 166 | if (strcmp(yytext, "debug") == 0) |
169 | { | 167 | { |
170 | luaY_lval.vInt = 1; | 168 | luaY_lval.vInt = 1; |
171 | return DEBUG; | 169 | return DEBUG; |
172 | } | 170 | } |
173 | else if (lua_strcmp(yytext, "nodebug") == 0) | 171 | else if (strcmp(yytext, "nodebug") == 0) |
174 | { | 172 | { |
175 | luaY_lval.vInt = 0; | 173 | luaY_lval.vInt = 0; |
176 | return DEBUG; | 174 | return DEBUG; |
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_tree="$Id: tree.c,v 1.16 1996/02/12 18:32:40 roberto Exp roberto $"; | 6 | char *rcs_tree="$Id: tree.c,v 1.17 1996/02/14 13:35:51 roberto Exp roberto $"; |
7 | 7 | ||
8 | 8 | ||
9 | #include <string.h> | 9 | #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 $"; | |||
16 | #include "table.h" | 16 | #include "table.h" |
17 | 17 | ||
18 | 18 | ||
19 | #define lua_streq(a,b) (a[0] == b[0] && strcmp(a,b) == 0) | ||
20 | |||
21 | #define NUM_HASHS 64 | 19 | #define NUM_HASHS 64 |
22 | 20 | ||
23 | typedef struct { | 21 | typedef struct { |
@@ -30,7 +28,7 @@ static int initialized = 0; | |||
30 | 28 | ||
31 | static stringtable string_root[NUM_HASHS]; | 29 | static stringtable string_root[NUM_HASHS]; |
32 | 30 | ||
33 | static TaggedString EMPTY = {NOT_USED, NOT_USED, 0, 0, {0}}; | 31 | static TaggedString EMPTY = {NOT_USED, NOT_USED, 0, 2, {0}}; |
34 | 32 | ||
35 | 33 | ||
36 | static unsigned long hash (char *str) | 34 | static unsigned long hash (char *str) |
@@ -92,7 +90,7 @@ static TaggedString *insert (char *str, stringtable *tb) | |||
92 | { | 90 | { |
93 | if (tb->hash[i] == &EMPTY) | 91 | if (tb->hash[i] == &EMPTY) |
94 | j = i; | 92 | j = i; |
95 | else if (lua_streq(str, tb->hash[i]->str)) | 93 | else if (strcmp(str, tb->hash[i]->str) == 0) |
96 | return tb->hash[i]; | 94 | return tb->hash[i]; |
97 | i = (i+1)%tb->size; | 95 | i = (i+1)%tb->size; |
98 | } | 96 | } |
@@ -130,7 +128,7 @@ Long lua_strcollector (void) | |||
130 | for (j=0; j<tb->size; j++) | 128 | for (j=0; j<tb->size; j++) |
131 | { | 129 | { |
132 | TaggedString *t = tb->hash[j]; | 130 | TaggedString *t = tb->hash[j]; |
133 | if (t != NULL && t != &EMPTY && t->marked <= 1) | 131 | if (t != NULL && t->marked <= 1) |
134 | { | 132 | { |
135 | if (t->marked) | 133 | if (t->marked) |
136 | t->marked = 0; | 134 | t->marked = 0; |