summaryrefslogtreecommitdiff
path: root/Src/math.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2000-05-19 18:22:50 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2000-05-19 18:22:50 +0000
commit8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5 (patch)
tree65bf9ac762900c25f7aa4b7ea88123bd6517254d /Src/math.c
parente20600c8a404d35bd4b4c02976ce08f5b166f415 (diff)
downloadzsh-8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5.tar.gz
zsh-8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5.zip
11467: [#<base>] syntax for output base
zsh-users/3071: compdump tweak to avoid // in path
Diffstat (limited to 'Src/math.c')
-rw-r--r--Src/math.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Src/math.c b/Src/math.c
index a7fcd0978..38466ed8e 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -186,6 +186,8 @@ static int type[TOKCOUNT] =
/* 50 */ LR|OP_OPF, RL|OP_E2, LR|OP_OPF
};
+/**/
+int outputradix;
/**/
static int
@@ -340,12 +342,22 @@ zzlex(void)
return EOI;
case '[':
{
- int base = zstrtol(ptr, &ptr, 10);
+ int base, setradix = 0;
+ if (*ptr == '#') {
+ ptr++;
+ setradix = 1;
+ }
+ base = zstrtol(ptr, &ptr, 10);
if (*ptr == ']')
ptr++;
- yyval.u.l = zstrtol(ptr, &ptr, lastbase = base);
- return NUM;
+ if (setradix)
+ outputradix = base;
+ else {
+ yyval.u.l = zstrtol(ptr, &ptr, lastbase = base);
+ return NUM;
+ }
+ break;
}
case ' ':
case '\t':
@@ -934,6 +946,7 @@ matheval(char *s)
char *junk;
mnumber x;
int xmtok = mtok;
+ outputradix = 0;
if (!*s) {
x.type = MN_INTEGER;