Subject: Re: Makefile.mbr problem - fix?
To: Darrin B. Jewell <dbj@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-toolchain
Date: 05/05/2003 22:15:24
> However, I did consult the SUSv3 before making this change.  It would
> appear that our shell is out of spec.
> 
> >>From the SUSv3 on arithmetic expansion in the shell:
>   "Only the decimal-constant, octal-constant, and hexadecimal-constant
>   constants specified in the ISO C standard, Section 6.4.4.1 are
>   required to be recognized as constants."
> 
> I will file a PR about the shell bug.

The following patch will fix NetBSD's /bin/sh
(I assume it is proper lex - it seems to work!)

Index: arith_lex.l
===================================================================
RCS file: /cvsroot/src/bin/sh/arith_lex.l,v
retrieving revision 1.10
diff -u -p -r1.10 arith_lex.l
--- arith_lex.l	1999/02/05 07:52:52	1.10
+++ arith_lex.l	2003/05/05 21:07:35
@@ -61,7 +61,9 @@ extern char *arith_buf, *arith_startbuf;
 
 %%
 [ \t\n]	{ ; }
-[0-9]+	{ yylval = atol(yytext); return(ARITH_NUM); }
+"0x"[0-9a-fA-F]+	{ yylval = strtoul(yytext, 0, 16); return(ARITH_NUM); }
+"0"[0-7]*	{ yylval = strtoul(yytext, 0, 8); return(ARITH_NUM); }
+[1-9][0-9]*	{ yylval = strtoul(yytext, 0, 10); return(ARITH_NUM); }
 "("	{ return(ARITH_LPAREN); }
 ")"	{ return(ARITH_RPAREN); }
 "||"	{ return(ARITH_OR); }

	David

-- 
David Laight: david@l8s.co.uk