* numeric brace expansion
@ 1995-06-05 16:44 Gerald Skerbitz
1995-06-05 16:52 ` Richard Coleman
0 siblings, 1 reply; 4+ messages in thread
From: Gerald Skerbitz @ 1995-06-05 16:44 UTC (permalink / raw)
To: zsh-users
>From zshexpn.1:
An expression of the form {n1..n2}, where n1 and n2 are
integers, is expanded to every number between n1 and n2,
inclusive. If either number begins with a zero, all the
resulting numbers will be padded with leading zeroes to that
minimum width. If the numbers are in decreasing order the
resulting sequence will also be in decreasing order.
This doesn't work at all for me.
>echo {01..03}
. 0 1 3
I figure there has to be some option I haven't set. Could someone clue
me in here?
>setopt
allexport appendhistory autocd automenu autonamedirs autopushd braceccl
cdablevars completeinword cshjunkieparen extendedglob globdots hashcmds
hashdirs hashlistall histignoredups ignoreeof interactive interactivecomments
listtypes menucomplete monitor nonomatch notify pathdirs pushdignoredups
pushdminus pushdsilent pushdtohome shinstdin zle
>echo $ZSH_VERSION
2.6-beta9
Thanks.
--
Gerry
Gerald Skerbitz <gsker@med.umn.edu> U of MN Med School Admin 6-5379
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: numeric brace expansion
1995-06-05 16:44 numeric brace expansion Gerald Skerbitz
@ 1995-06-05 16:52 ` Richard Coleman
1995-06-05 17:39 ` Mike Campbell
0 siblings, 1 reply; 4+ messages in thread
From: Richard Coleman @ 1995-06-05 16:52 UTC (permalink / raw)
To: zsh-users
> An expression of the form {n1..n2}, where n1 and n2 are
> integers, is expanded to every number between n1 and n2,
> inclusive. If either number begins with a zero, all the
> resulting numbers will be padded with leading zeroes to that
> minimum width. If the numbers are in decreasing order the
> resulting sequence will also be in decreasing order.
>
>
> This doesn't work at all for me.
> >echo {01..03}
> . 0 1 3
>
> I figure there has to be some option I haven't set. Could someone clue
> me in here?
This is broken on both beta8/beta9 (and maybe beta7). It will
be fixed in beta10 (by the end of the week). To fix this now,
you should be able to undefine HAVE_STRTOL in config.h and recompile.
Richard Coleman
coleman@math.gatech.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: numeric brace expansion
1995-06-05 16:52 ` Richard Coleman
@ 1995-06-05 17:39 ` Mike Campbell
1995-06-05 17:47 ` Richard Coleman
0 siblings, 1 reply; 4+ messages in thread
From: Mike Campbell @ 1995-06-05 17:39 UTC (permalink / raw)
To: Richard Coleman; +Cc: zsh-users
Richard> This is broken on both beta8/beta9 (and maybe beta7). It will be
Richard> fixed in beta10 (by the end of the week). To fix this now, you
Richard> should be able to undefine HAVE_STRTOL in config.h and recompile.
With Solaris 2.4 and gcc 2.6.3, I get an error (follows) doing this. Guess
I'll wait till beta 10.
==============================================================================
mcampbel@offenbach:/local/ftp/zsh-2.6-beta9> make
for subdir in Src Doc Etc Functions Startup_Files Misc Util; do \
(cd $subdir && make all) ; \
done
gcc -c -I.. -I. -I. -DCONFIG_BROKETS -DHAVE_CONFIG_H -Wall -Wno-implicit -Wmissing-prototypes -O2 builtin.c
In file included from zsh.h:1013,
from builtin.c:32:
prototypes.h:125: conflicting types for `strtol'
/optware/unsupported/lib/gcc-lib/sparc-sun-solaris2.3/2.6.3/include/stdlib.h:75: previous declaration of `strtol'
*** Error code 1
make: Fatal error: Command failed for target `builtin.o'
Current working directory /export/local/ftp/zsh-2.6-beta9/Src
*** Error code 1
make: Fatal error: Command failed for target `all'
==============================================================================
+-----------------------------------------------------------------------------+
| Michael Campbell - mcampbel@offenbach.sbi.com :: I speak only for myself :: |
| I prefer PGP'd mail. Send me your public key! |
+-----------------------------------------------------------------------------+
| Plebescite: A popular vote to ascertain the will of the sovereign. -- The |
| Devil's Dictionary |
+-----------------------------------------------------------------------------+
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: numeric brace expansion
1995-06-05 17:39 ` Mike Campbell
@ 1995-06-05 17:47 ` Richard Coleman
0 siblings, 0 replies; 4+ messages in thread
From: Richard Coleman @ 1995-06-05 17:47 UTC (permalink / raw)
To: zsh-users
> Richard> This is broken on both beta8/beta9 (and maybe beta7). It will be
> Richard> fixed in beta10 (by the end of the week). To fix this now, you
> Richard> should be able to undefine HAVE_STRTOL in config.h and recompile.
>
> With Solaris 2.4 and gcc 2.6.3, I get an error (follows) doing this. Guess
> I'll wait till beta 10.
> ==============================================================================
Hmm.. better yet, here is a quick patch (originally posted by Mark Borges).
I didn't think the prototypes would be a problem like that. Sorry for
the lame advice.
Richard Coleman
coleman@math.gatech.edu
Note this is a temporary fix until Richard decides the right thing to
do (use zstrtol or somehow work around the (broken?) system supplied
strtol) and adjusts configure accordingly. I did nothing w.r.t. the
configure script, i.e., if configure detects you have strtol, you will
have to manually edit config.h and undef the HAVE_STRTOL line:
/* Define if you have the strtol function. */
/* #define HAVE_STRTOL 1 */
-mb-
-------------------------------- cut here --------------------------------
diff -c Src.orig/builtin.c Src/builtin.c
*** Src.orig/builtin.c Tue May 30 22:10:07 1995
--- Src/builtin.c Wed May 31 06:58:22 1995
***************
*** 1249,1255 ****
doprintdir++;
if (argv[0][1] && argv[0][0] == (isset(PUSHDMINUS) ? '-' : '+')) {
/* popping directory, specified with + */
! dd = strtol(argv[0] + 1, &end, 10) - 1;
if (dd >= 0 && *end == '\0') {
for (n = firstnode(dirstack); n && dd; dd--, incnode(n));
if (!n) {
--- 1249,1255 ----
doprintdir++;
if (argv[0][1] && argv[0][0] == (isset(PUSHDMINUS) ? '-' : '+')) {
/* popping directory, specified with + */
! dd = zstrtol(argv[0] + 1, &end, 10) - 1;
if (dd >= 0 && *end == '\0') {
for (n = firstnode(dirstack); n && dd; dd--, incnode(n));
if (!n) {
***************
*** 1260,1266 ****
}
} else if (argv[0][1] && argv[0][0] == (isset(PUSHDMINUS) ? '+' : '-')) {
/* popping directory, specified with - */
! dd = strtol(argv[0] + 1, &end, 10);
if (*end == '\0') {
for (n = lastnode(dirstack); n != (Lknode) dirstack && dd;
dd--, n = prevnode(n));
--- 1260,1266 ----
}
} else if (argv[0][1] && argv[0][0] == (isset(PUSHDMINUS) ? '+' : '-')) {
/* popping directory, specified with - */
! dd = zstrtol(argv[0] + 1, &end, 10);
if (*end == '\0') {
for (n = lastnode(dirstack); n != (Lknode) dirstack && dd;
dd--, n = prevnode(n));
***************
*** 4071,4084 ****
hours with the `m' and `h' modifiers, and `:' may be used to add
together more than one of these. It's easier to understand from
the code: */
! val = strtol(s, &s, 10);
if (*s)
if ((*s == 'h' || *s == 'H') && !s[1])
val *= 3600L;
else if ((*s == 'm' || *s == 'M') && !s[1])
val *= 60L;
else if (*s == ':')
! val = val * 60 + strtol(s + 1, &s, 10);
else {
zwarnnam("limit", "unknown scaling factor: %s", s, 0);
return 1;
--- 4071,4084 ----
hours with the `m' and `h' modifiers, and `:' may be used to add
together more than one of these. It's easier to understand from
the code: */
! val = zstrtol(s, &s, 10);
if (*s)
if ((*s == 'h' || *s == 'H') && !s[1])
val *= 3600L;
else if ((*s == 'm' || *s == 'M') && !s[1])
val *= 60L;
else if (*s == ':')
! val = val * 60 + zstrtol(s + 1, &s, 10);
else {
zwarnnam("limit", "unknown scaling factor: %s", s, 0);
return 1;
***************
*** 4088,4105 ****
else if (lim == RLIMIT_NPROC)
/* pure numeric resource -- only a straight decimal number is
permitted. */
! val = strtol(s, &s, 10);
# endif /* RLIMIT_NPROC */
# ifdef RLIMIT_NOFILE
else if (lim == RLIMIT_NOFILE)
/* pure numeric resource -- only a straight decimal number is
permitted. */
! val = strtol(s, &s, 10);
# endif /* RLIMIT_NOFILE */
else {
/* memory-type resource -- `k' and `M' modifiers are permitted,
meaning (respectively) 2^10 and 2^20. */
! val = strtol(s, &s, 10);
if (!*s || ((*s == 'k' || *s == 'K') && !s[1]))
val *= 1024L;
else if ((*s == 'M' || *s == 'm') && !s[1])
--- 4088,4105 ----
else if (lim == RLIMIT_NPROC)
/* pure numeric resource -- only a straight decimal number is
permitted. */
! val = zstrtol(s, &s, 10);
# endif /* RLIMIT_NPROC */
# ifdef RLIMIT_NOFILE
else if (lim == RLIMIT_NOFILE)
/* pure numeric resource -- only a straight decimal number is
permitted. */
! val = zstrtol(s, &s, 10);
# endif /* RLIMIT_NOFILE */
else {
/* memory-type resource -- `k' and `M' modifiers are permitted,
meaning (respectively) 2^10 and 2^20. */
! val = zstrtol(s, &s, 10);
if (!*s || ((*s == 'k' || *s == 'K') && !s[1]))
val *= 1024L;
else if ((*s == 'M' || *s == 'm') && !s[1])
***************
*** 5466,5477 ****
hour:minute offset from the current time. Once the hour and minute
numbers have been extracted, and the format verified, the resulting
offset is simply added to the current time. */
! h = strtol(s + 1, &s, 10);
if (*s != ':') {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
}
! m = strtol(s + 1, &s, 10);
if (*s) {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
--- 5466,5477 ----
hour:minute offset from the current time. Once the hour and minute
numbers have been extracted, and the format verified, the resulting
offset is simply added to the current time. */
! h = zstrtol(s + 1, &s, 10);
if (*s != ':') {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
}
! m = zstrtol(s + 1, &s, 10);
if (*s) {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
***************
*** 5482,5493 ****
This is in hour:minute format, optionally followed by a string starting
with `a' or `p' (for a.m. or p.m.). Characters after the `a' or `p'
are ignored. */
! h = strtol(s, &s, 10);
if (*s != ':') {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
}
! m = strtol(s + 1, &s, 10);
if (*s && *s != 'a' && *s != 'A' && *s != 'p' && *s != 'P') {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
--- 5482,5493 ----
This is in hour:minute format, optionally followed by a string starting
with `a' or `p' (for a.m. or p.m.). Characters after the `a' or `p'
are ignored. */
! h = zstrtol(s, &s, 10);
if (*s != ':') {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
}
! m = zstrtol(s + 1, &s, 10);
if (*s && *s != 'a' && *s != 'A' && *s != 'p' && *s != 'P') {
zwarnnam("sched", "bad time specifier", NULL, 0);
return 1;
***************
*** 5722,5728 ****
if (idigit(*s)) {
/* Simple digital umask. */
! um = strtol(s, &s, 8);
if (*s) {
zwarnnam(nam, "bad umask", NULL, 0);
return 1;
--- 5722,5728 ----
if (idigit(*s)) {
/* Simple digital umask. */
! um = zstrtol(s, &s, 8);
if (*s) {
zwarnnam(nam, "bad umask", NULL, 0);
return 1;
diff -c Src.orig/compat.c Src/compat.c
*** Src.orig/compat.c Tue May 30 22:10:08 1995
--- Src/compat.c Wed May 31 06:57:24 1995
***************
*** 35,41 ****
#ifndef HAVE_STRTOL
long
! strtol(char *s, char **t, int base)
{
long ret = 0;
--- 35,41 ----
#ifndef HAVE_STRTOL
long
! zstrtol(char *s, char **t, int base)
{
long ret = 0;
diff -c Src.orig/glob.c Src/glob.c
*** Src.orig/glob.c Tue May 30 22:10:15 1995
--- Src/glob.c Wed May 31 06:59:07 1995
***************
*** 815,821 ****
char *dots, *p;
Lknode olast = last;
/* Get the first number of the range */
! int rstart = strtol(str+1,&dots,10), rend = 0, err = 0, rev = 0;
int wid1 = (dots - str) - 1, wid2 = (str2 - dots) - 2;
int strp = str - str3;
--- 815,821 ----
char *dots, *p;
Lknode olast = last;
/* Get the first number of the range */
! int rstart = zstrtol(str+1,&dots,10), rend = 0, err = 0, rev = 0;
int wid1 = (dots - str) - 1, wid2 = (str2 - dots) - 2;
int strp = str - str3;
***************
*** 823,829 ****
err++;
else {
/* Get the last number of the range */
! rend = strtol(dots+2,&p,10);
if (p == dots+2 || p != str2)
err++;
}
--- 823,829 ----
err++;
else {
/* Get the last number of the range */
! rend = zstrtol(dots+2,&p,10);
if (p == dots+2 || p != str2)
err++;
}
***************
*** 1454,1460 ****
if (*++pat == Outang ||
(*pat == '-' && pat[1] == Outang && ++pat)) {
/* <> or <->: any number matches */
! (void)strtol(pptr, &ptr, 10);
if (ptr == pptr)
break;
pptr = ptr;
--- 1454,1460 ----
if (*++pat == Outang ||
(*pat == '-' && pat[1] == Outang && ++pat)) {
/* <> or <->: any number matches */
! (void)zstrtol(pptr, &ptr, 10);
if (ptr == pptr)
break;
pptr = ptr;
***************
*** 1467,1483 ****
* t1 = number supplied: must be positive, so use
* unsigned arithmetic.
*/
! t1 = (unsigned long)strtol(pptr, &ptr, 10);
if (ptr == pptr)
break;
pptr = ptr;
/* t2 = lower limit */
! t2 = (unsigned long)strtol(pat, &ptr, 10);
if (*ptr != '-' || (not3 = (ptr[1] == Outang)))
/* exact match or no upper limit */
t3 = t2, pat = ptr + not3;
else /* t3 = upper limit */
! t3 = (unsigned long)strtol(ptr + 1, &pat, 10);
if (*pat++ != Outang)
exit(21);
if (t1 < t2 || (!not3 && t1 > t3))
--- 1467,1483 ----
* t1 = number supplied: must be positive, so use
* unsigned arithmetic.
*/
! t1 = (unsigned long)zstrtol(pptr, &ptr, 10);
if (ptr == pptr)
break;
pptr = ptr;
/* t2 = lower limit */
! t2 = (unsigned long)zstrtol(pat, &ptr, 10);
if (*ptr != '-' || (not3 = (ptr[1] == Outang)))
/* exact match or no upper limit */
t3 = t2, pat = ptr + not3;
else /* t3 = upper limit */
! t3 = (unsigned long)zstrtol(ptr + 1, &pat, 10);
if (*pat++ != Outang)
exit(21);
if (t1 < t2 || (!not3 && t1 > t3))
diff -c Src.orig/math.c Src/math.c
*** Src.orig/math.c Tue May 30 22:10:26 1995
--- Src/math.c Wed May 31 06:59:23 1995
***************
*** 309,319 ****
case '[':
unary = 0;
{
! int base = strtol(ptr, &ptr, 10);
if (*ptr == ']')
ptr++;
! yyval = strtol(ptr, &ptr, lastbase = base);
return NUM;
}
case ' ':
--- 309,319 ----
case '[':
unary = 0;
{
! int base = zstrtol(ptr, &ptr, 10);
if (*ptr == ']')
ptr++;
! yyval = zstrtol(ptr, &ptr, lastbase = base);
return NUM;
}
case ' ':
***************
*** 331,341 ****
default:
if (idigit(*--ptr)) {
unary = 0;
! yyval = strtol(ptr, &ptr, 0);
if (*ptr == '#') {
ptr++;
! yyval = strtol(ptr, &ptr, lastbase = yyval);
}
return NUM;
}
--- 331,341 ----
default:
if (idigit(*--ptr)) {
unary = 0;
! yyval = zstrtol(ptr, &ptr, 0);
if (*ptr == '#') {
ptr++;
! yyval = zstrtol(ptr, &ptr, lastbase = yyval);
}
return NUM;
}
***************
*** 943,948 ****
* This is only used when reading from strings outside the formula,
* e.g. in parameter substitutions, so does not set lastbase.
*/
! long num1 = strtol(s, &s, 10);
! return (*s == '#' || *s == Pound) ? strtol(s+1, &s, num1) : num1;
}
--- 943,948 ----
* This is only used when reading from strings outside the formula,
* e.g. in parameter substitutions, so does not set lastbase.
*/
! long num1 = zstrtol(s, &s, 10);
! return (*s == '#' || *s == Pound) ? zstrtol(s+1, &s, num1) : num1;
}
diff -c Src.orig/prototypes.h Src/prototypes.h
*** Src.orig/prototypes.h Tue May 30 22:09:46 1995
--- Src/prototypes.h Wed May 31 06:57:36 1995
***************
*** 122,128 ****
/**************************************************/
/*** prototypes for functions built in compat.c ***/
#ifndef HAVE_STRTOL
! extern long strtol _((char *s, char **t, int base));
#endif
#ifndef HAVE_STRSTR
--- 122,128 ----
/**************************************************/
/*** prototypes for functions built in compat.c ***/
#ifndef HAVE_STRTOL
! extern long zstrtol _((char *s, char **t, int base));
#endif
#ifndef HAVE_STRSTR
diff -c Src.orig/subst.c Src/subst.c
*** Src.orig/subst.c Tue May 30 22:10:38 1995
--- Src/subst.c Wed May 31 06:59:34 1995
***************
*** 263,269 ****
val = -1;
ptr = str + 2;
} else if (idigit(str[1]))
! val = strtol(str + 1, &ptr, 10); /* =# */
else
/* =foo */
{
--- 263,269 ----
val = -1;
ptr = str + 2;
} else if (idigit(str[1]))
! val = zstrtol(str + 1, &ptr, 10); /* =# */
else
/* =foo */
{
diff -c Src.orig/zle_main.c Src/zle_main.c
*** Src.orig/zle_main.c Tue May 30 22:10:52 1995
--- Src/zle_main.c Wed May 31 06:59:43 1995
***************
*** 754,760 ****
s[3] = '\0';
u = s;
}
! *t++ = strtol(s + (*s == 'x'), &s,
(*s == 'x') ? 16 : 8);
if (svchar) {
u[3] = svchar;
--- 754,760 ----
s[3] = '\0';
u = s;
}
! *t++ = zstrtol(s + (*s == 'x'), &s,
(*s == 'x') ? 16 : 8);
if (svchar) {
u[3] = svchar;
diff -c Src.orig/zle_misc.c Src/zle_misc.c
*** Src.orig/zle_misc.c Tue May 30 22:10:54 1995
--- Src/zle_misc.c Wed May 31 06:59:55 1995
***************
*** 818,830 ****
arg = 0;
if (*fm == '%') {
if (idigit(*++fm)) {
! arg = strtol(fm, &fm, 10);
}
if (*fm == '(') {
int tc;
if (idigit(*++fm)) {
! arg = strtol(fm, &fm, 10);
}
test = 0;
ss = pwd;
--- 818,830 ----
arg = 0;
if (*fm == '%') {
if (idigit(*++fm)) {
! arg = zstrtol(fm, &fm, 10);
}
if (*fm == '(') {
int tc;
if (idigit(*++fm)) {
! arg = zstrtol(fm, &fm, 10);
}
test = 0;
ss = pwd;
***************
*** 1015,1021 ****
break;
case '[':
if (idigit(*++fm))
! trunclen = strtol(fm, &fm, 10);
else
trunclen = arg;
ss = bp;
--- 1015,1021 ----
break;
case '[':
if (idigit(*++fm))
! trunclen = zstrtol(fm, &fm, 10);
else
trunclen = arg;
ss = bp;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1995-06-05 17:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-05 16:44 numeric brace expansion Gerald Skerbitz
1995-06-05 16:52 ` Richard Coleman
1995-06-05 17:39 ` Mike Campbell
1995-06-05 17:47 ` Richard Coleman
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).