Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Octal and hex numbers in zsh
- X-seq: zsh-workers 95
- From: hzoli@xxxxxxxxxx (Zoltan Hidvegi)
- To: zsh-workers@xxxxxxxxxxxxxxx (zsh-workers)
- Subject: Octal and hex numbers in zsh
- Date: Fri, 9 Jun 1995 18:55:18 +0100 (MET DST)
The following simple patch removes the feature when a leading zero denotes
octal number. But leading 0x still can be uset for hex numbers. The 0xff
syntax also sets lastbase (ie. it sets the base to 16 if an integer is first
assigned this way). To remove this feature, replace `lastbase = 16' with `16'
below. This patch does not depend on the strtol feature to interpret 0xff as a
hex number if called with base 0.
Zoltan
rcsdiff -qc -kk -r1.7 -r1.8 math.c
*** math.c
--- math.c 1995/06/02 23:56:54
***************
*** 327,336 ****
case '\t':
case '\n':
break;
default:
if (idigit(*--ptr)) {
unary = 0;
! yyval = strtol(ptr, &ptr, 0);
if (*ptr == '#') {
ptr++;
--- 327,343 ----
case '\t':
case '\n':
break;
+ case '0':
+ if (*ptr == 'x' || *ptr == 'X') {
+ /* Should we set lastbase here? */
+ yyval = strtol(++ptr, &ptr, lastbase = 16);
+ return NUM;
+ }
+ /* Fall through! */
default:
if (idigit(*--ptr)) {
unary = 0;
! yyval = strtol(ptr, &ptr, 10);
if (*ptr == '#') {
ptr++;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author