summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Celes <celes@tecgraf.puc-rio.br>1994-08-17 14:41:50 -0300
committerWaldemar Celes <celes@tecgraf.puc-rio.br>1994-08-17 14:41:50 -0300
commit0624540eef9d348392c926024797e582b7e6e2cf (patch)
tree0664af084781bbc053b7a6174e7a52fa6ef07083
parenta4eeb099c8be2ca2608bfec7232da878549288f0 (diff)
downloadlua-0624540eef9d348392c926024797e582b7e6e2cf.tar.gz
lua-0624540eef9d348392c926024797e582b7e6e2cf.tar.bz2
lua-0624540eef9d348392c926024797e582b7e6e2cf.zip
Implementacao da macro 'lua_strcmp'
-rw-r--r--lex.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lex.c b/lex.c
index c7c7bed6..379e4427 100644
--- a/lex.c
+++ b/lex.c
@@ -1,5 +1,9 @@
1char *rcs_lex = "$Id: lex.c,v 2.1 1994/04/15 19:00:28 celes Exp celes $"; 1char *rcs_lex = "$Id: lex.c,v 2.2 1994/08/05 19:27:41 celes Exp celes $";
2/*$Log: lex.c,v $ 2/*$Log: lex.c,v $
3 * Revision 2.2 1994/08/05 19:27:41 celes
4 * implementacao de dois buffer de 'yytext' para evitar bug
5 * no look ahead do yacc
6 *
3 * Revision 2.1 1994/04/15 19:00:28 celes 7 * Revision 2.1 1994/04/15 19:00:28 celes
4 * Retirar chamada da funcao lua_findsymbol associada a cada 8 * Retirar chamada da funcao lua_findsymbol associada a cada
5 * token NAME. A decisao de chamar lua_findsymbol ou lua_findconstant 9 * token NAME. A decisao de chamar lua_findsymbol ou lua_findconstant
@@ -26,6 +30,8 @@ char *rcs_lex = "$Id: lex.c,v 2.1 1994/04/15 19:00:28 celes Exp celes $";
26#include "table.h" 30#include "table.h"
27#include "y.tab.h" 31#include "y.tab.h"
28 32
33#define lua_strcmp(a,b) (a[0]<b[0]?(-1):(a[0]>b[0]?(1):strcmp(a,b)))
34
29#define next() { current = input(); } 35#define next() { current = input(); }
30#define save(x) { *yytextLast++ = (x); } 36#define save(x) { *yytextLast++ = (x); }
31#define save_and_next() { save(current); next(); } 37#define save_and_next() { save(current); next(); }
@@ -83,7 +89,7 @@ static int findReserved (char *name)
83 while (l <= h) 89 while (l <= h)
84 { 90 {
85 int m = (l+h)/2; 91 int m = (l+h)/2;
86 int comp = strcmp(name, reserved[m].name); 92 int comp = lua_strcmp(name, reserved[m].name);
87 if (comp < 0) 93 if (comp < 0)
88 h = m-1; 94 h = m-1;
89 else if (comp == 0) 95 else if (comp == 0)
@@ -114,12 +120,12 @@ int yylex ()
114 while (isalnum(current) || current == '_') 120 while (isalnum(current) || current == '_')
115 save_and_next(); 121 save_and_next();
116 *yytextLast = 0; 122 *yytextLast = 0;
117 if (strcmp(yytext[currentText], "debug") == 0) 123 if (lua_strcmp(yytext[currentText], "debug") == 0)
118 { 124 {
119 yylval.vInt = 1; 125 yylval.vInt = 1;
120 return DEBUG; 126 return DEBUG;
121 } 127 }
122 else if (strcmp(yytext[currentText], "nodebug") == 0) 128 else if (lua_strcmp(yytext[currentText], "nodebug") == 0)
123 { 129 {
124 yylval.vInt = 0; 130 yylval.vInt = 0;
125 return DEBUG; 131 return DEBUG;