From: pws@ifh.de (Peter William Stephenson)
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Octal interpretation
Date: Fri, 3 Nov 1995 10:01:46 +0100 (MET) [thread overview]
Message-ID: <9511030901.AA21400@sgi.ifh.de> (raw)
I am heartily sick of being told my stack is unbalanced because the
time happens to be 12:08. Based on the following two facts,
1) No valid octal number ever starts 08 or 09
2) 08 and 09 are the only two digit numbers evaluated incorrectly
I would like to propose that zstrtol explicitly checks for an 8 or a 9
following the 0 and if there is one evaluates it in decimal. This
will mean times can be handled properly --- what I mainly use
arithmetic in zsh for anyway --- while real octal numbers won't be
affected.
Anybody writing scripts for users where this may matter should in any
case be stripping leading 0's as a matter of course. If that's a big
problem, we should simply remove octal handling. (What's wrong with
8#77 etc. anyway? Isn't this just why ksh introduced that syntax?)
*** Src/utils.c.oct Wed Nov 1 11:12:11 1995
--- Src/utils.c Fri Nov 3 09:45:49 1995
***************
*** 1104,1112 ****
base = 10;
else if (*++s == 'x' || *s == 'X')
base = 16, s++;
else
base = 8;
!
if (base <= 10)
for (; *s >= '0' && *s < ('0' + base); s++)
ret = ret * base + *s - '0';
--- 1104,1114 ----
base = 10;
else if (*++s == 'x' || *s == 'X')
base = 16, s++;
+ else if (*s == '8' || *s == '9')
+ base = 10;
else
base = 8;
!
if (base <= 10)
for (; *s >= '0' && *s < ('0' + base); s++)
ret = ret * base + *s - '0';
*** Doc/zshmisc.1.oct Sun Oct 29 11:52:06 1995
--- Doc/zshmisc.1 Fri Nov 3 09:46:30 1995
***************
*** 732,739 ****
.BR let .
Evaluations are performed using
.I long
! arithmetic. Constants with a leading 0 are interpreted as octal numbers.
! A leading \fI0x\fP or \fI0X\fP denotes hexadecimal.
Otherwise, numbers are of the form
[\fIbase\fB#\^\fR]\fIn\^\fP
where
--- 732,741 ----
.BR let .
Evaluations are performed using
.I long
! arithmetic. Constants with a leading 0 are interpreted as octal
! numbers, except in the special case that the 0 is immediately followed
! by an 8 or 9 (this allows processing of sections of time strings such
! as "12:08"). A leading \fI0x\fP or \fI0X\fP denotes hexadecimal.
Otherwise, numbers are of the form
[\fIbase\fB#\^\fR]\fIn\^\fP
where
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
next reply other threads:[~1995-11-03 9:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-11-03 9:01 Peter William Stephenson [this message]
1995-11-03 10:58 ` Richard Coleman
1995-11-03 16:54 ` Zoltan Hidvegi
1995-11-04 1:28 ` Richard Coleman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9511030901.AA21400@sgi.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).