Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/bin/sh Pull up revision 1.13 (requested by dsl in ticket ...



details:   https://anonhg.NetBSD.org/src/rev/f53dc4bf01a2
branches:  netbsd-3
changeset: 575287:f53dc4bf01a2
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Apr 07 11:38:58 2005 +0000

description:
Pull up revision 1.13 (requested by dsl in ticket #120):
A rather better fix for treating $((x)) as equivalent to $(($x)) provided
that $x has a numeric value - which is what posix/sus needs.

diffstat:

 bin/sh/arith_lex.l |  21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diffs (57 lines):

diff -r 2108ccc96f32 -r f53dc4bf01a2 bin/sh/arith_lex.l
--- a/bin/sh/arith_lex.l        Thu Apr 07 11:37:39 2005 +0000
+++ b/bin/sh/arith_lex.l        Thu Apr 07 11:38:58 2005 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: arith_lex.l,v 1.12 2003/08/07 09:05:30 agc Exp $       */
+/*     $NetBSD: arith_lex.l,v 1.12.6.1 2005/04/07 11:38:58 tron Exp $  */
 
 /*-
  * Copyright (c) 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)arith_lex.l        8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: arith_lex.l,v 1.12 2003/08/07 09:05:30 agc Exp $");
+__RCSID("$NetBSD: arith_lex.l,v 1.12.6.1 2005/04/07 11:38:58 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -46,6 +46,7 @@
 #include "arith.h"
 #include "error.h"
 #include "expand.h"
+#include "var.h"
 
 extern int yylval;
 extern char *arith_buf, *arith_startbuf;
@@ -57,9 +58,17 @@
 
 %%
 [ \t\n]        { ; }
-0x[0-9a-fA-F]+ { yylval = strtol(yytext, 0, 16); return(ARITH_NUM); }
-0[0-7]*                { yylval = strtol(yytext, 0, 8); return(ARITH_NUM); }
-[1-9][0-9]*    { yylval = strtol(yytext, 0, 10); return(ARITH_NUM); }
+0x[0-9a-fA-F]+ { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); }
+0[0-7]*                { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); }
+[1-9][0-9]*    { yylval = strtol(yytext, 0, 0); return(ARITH_NUM); }
+[A-Za-z_][A-Za-z_0-9]* { char *v = lookupvar(yytext);
+                       if (v) {
+                               yylval = strtol(v, &v, 0);
+                               if (*v == 0)
+                                       return ARITH_NUM;
+                       }
+                       error("arith: syntax error: \"%s\"", arith_startbuf);
+               }
 "("    { return(ARITH_LPAREN); }
 ")"    { return(ARITH_RPAREN); }
 "||"   { return(ARITH_OR); }
@@ -82,7 +91,7 @@
 "-"    { return(ARITH_SUB); }
 "~"    { return(ARITH_BNOT); }
 "!"    { return(ARITH_NOT); }
-.      { error("arith: syntax error: \"%s\"\n", arith_startbuf); }
+.      { error("arith: syntax error: \"%s\"", arith_startbuf); }
 %%
 
 void



Home | Main Index | Thread Index | Old Index