Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Fix two bugs in typeset_setbase
- X-seq: zsh-workers 35021
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Fix two bugs in typeset_setbase
- Date: Sun, 3 May 2015 22:36:02 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=9AQNc4cfcwsS7oJ4bbwrUtr3f5JbbUrTN9OKD/IQzz8=; b=R+LHgScNSggrKZt7LXmZAvnQ4qspdIbC6VTINqSsSJ5b7U7yMzs66+rz4VY0hn3Ulu N1sSUoud0QXSE1C5/ok1MTTOFr+t0LL8/+5+rED1bIDaoAyncvoJcj/o+lzgI5cWkJ0H Cs47R5202WbEgq0lTppoKHyK3v4FEtioT8TRqTdrhcuqS+APWIU6um7eJaPlZe45SPOw lhzXY6V3FseLEXJ43JW6x4cAfdlZvx0gmKK6pRUIluGhQ+maJmAIyw0A8IlGmxb028Tl 4jdi2ydAI62cNemtx34dNZ8uo3g6USQ6+cLCfm4SERm7umfNDR1Xx8MG4SAHvQX07bXF maMQ==
- In-reply-to: <CAOcd6hrtTa7WVerarsU9+ZTWxa5G0g8f9Z+PGKCfMWZ7JWT-UA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAOcd6hrtTa7WVerarsU9+ZTWxa5G0g8f9Z+PGKCfMWZ7JWT-UA@mail.gmail.com>
We refused to set the base outside [2,36], but this restriction should
only apply to integers (where the base is actually the base). For float
values, the precision can be anything. We also failed to actually enforce
this limitation in either of these cases, but only printed the error
message. We now only update the base if it was valid.
---
Src/builtin.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Src/builtin.c b/Src/builtin.c
index 0113757..1243263 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1865,7 +1865,7 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always)
if (arg) {
char *eptr;
- pm->base = (int)zstrtol(arg, &eptr, 10);
+ int base = (int)zstrtol(arg, &eptr, 10);
if (*eptr) {
if (on & PM_INTEGER)
zwarnnam(name, "bad base value: %s", arg);
@@ -1873,11 +1873,12 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always)
zwarnnam(name, "bad precision value: %s", arg);
return 1;
}
- if (pm->base < 2 || pm->base > 36) {
+ if ((on & PM_INTEGER) && (base < 2 || base > 36)) {
zwarnnam(name, "invalid base (must be 2 to 36 inclusive): %d",
- pm->base);
+ base);
return 1;
}
+ pm->base = base;
} else if (always)
pm->base = 0;
--
2.4.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author