zsh-workers
 help / color / mirror / code / Atom feed
* Octal and hex numbers in zsh
@ 1995-06-09 17:55 Zoltan Hidvegi
  0 siblings, 0 replies; only message in thread
From: Zoltan Hidvegi @ 1995-06-09 17:55 UTC (permalink / raw)
  To: zsh-workers

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++;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-06-09 16:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-09 17:55 Octal and hex numbers in zsh Zoltan Hidvegi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).