* PATCH: "limit" should not set a limit to 0 on bad input
@ 2001-10-22 15:04 Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2001-10-22 15:04 UTC (permalink / raw)
To: zsh-workers
Remind me again why "limit" doesn't understand a spec of "unlimited"?
Index: Src/Builtins/rlimits.c
===================================================================
--- Src/Builtins/rlimits.c 2001/04/09 20:14:13 1.1.1.1
+++ Src/Builtins/rlimits.c 2001/10/22 15:01:09
@@ -332,7 +332,12 @@
} else if (limtype[lim] == ZLIMTYPE_NUMBER || limtype[lim] == ZLIMTYPE_UNKNOWN) {
/* pure numeric resource -- only a straight decimal number is
permitted. */
- val = zstrtorlimt(s, &s, 10);
+ char *t = s;
+ val = zstrtorlimt(t, &s, 10);
+ if (s == t) {
+ zwarnnam("limit", "limit must be a number", NULL, 0);
+ return 1;
+ }
} else {
/* memory-type resource -- `k' and `M' modifiers are permitted,
meaning (respectively) 2^10 and 2^20. */
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: "limit" should not set a limit to 0 on bad input
[not found] <11892.1003769407@csr.com>
@ 2001-10-22 17:44 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2001-10-22 17:44 UTC (permalink / raw)
To: Peter Stephenson; +Cc: zsh-workers
On Oct 22, 5:50pm, Peter Stephenson wrote:
} Subject: Re: PATCH: "limit" should not set a limit to 0 on bad input
}
} Bart Schaefer wrote:
} > Remind me again why "limit" doesn't understand a spec of "unlimited"?
}
} You're supposed to use `unlimit', I assume. But it would make perfect
} sense to allow `unlimited' given that that's what it outputs.
See potential patch below.
} Probably a good idea to apply this to 4.0.
Did that.
Index: Src/Builtins/rlimits.c
===================================================================
--- Src/Builtins/rlimits.c 2001/10/22 17:03:58 1.2
+++ Src/Builtins/rlimits.c 2001/10/22 17:17:16
@@ -44,12 +44,14 @@
# include "rlimits.h"
-# if defined(RLIM_T_IS_QUAD_T) || defined(RLIM_T_IS_LONG_LONG) || defined(RLIM_T_IS_UNSIGNED)
static rlim_t
zstrtorlimt(const char *s, char **t, int base)
{
rlim_t ret = 0;
-
+
+ if (strcmp(s, "unlimited") == 0)
+ return RLIM_INFINITY;
+# if defined(RLIM_T_IS_QUAD_T) || defined(RLIM_T_IS_LONG_LONG) || defined(RLIM_T_IS_UNSIGNED)
if (!base) {
if (*s != '0')
base = 10;
@@ -67,11 +69,11 @@
ret = ret * base + (idigit(*s) ? (*s - '0') : (*s & 0x1f) + 9);
if (t)
*t = (char *)s;
- return ret;
-}
# else /* !RLIM_T_IS_QUAD_T && !RLIM_T_IS_LONG_LONG && !RLIM_T_IS_UNSIGNED */
-# define zstrtorlimt(a, b, c) zstrtol((a), (b), (c))
+ ret = zstrtol(s, t, base);
# endif /* !RLIM_T_IS_QUAD_T && !RLIM_T_IS_LONG_LONG && !RLIM_T_IS_UNSIGNED */
+ return ret;
+}
/* Display resource limits. hard indicates whether `hard' or `soft' *
* limits should be displayed. lim specifies the limit, or may be -1 *
@@ -317,7 +319,7 @@
* together more than one of these. It's easier to understand from *
* the code: */
val = zstrtorlimt(s, &s, 10);
- if (*s) {
+ if (*s && val != RLIM_INFINITY) {
if ((*s == 'h' || *s == 'H') && !s[1])
val *= 3600L;
else if ((*s == 'm' || *s == 'M') && !s[1])
@@ -334,7 +336,7 @@
permitted. */
char *t = s;
val = zstrtorlimt(t, &s, 10);
- if (s == t) {
+ if (s == t && val != RLIM_INFINITY) {
zwarnnam("limit", "limit must be a number", NULL, 0);
return 1;
}
@@ -346,7 +348,7 @@
val *= 1024L;
else if ((*s == 'M' || *s == 'm') && !s[1])
val *= 1024L * 1024;
- else {
+ else if (val != RLIM_INFINITY) {
zwarnnam("limit", "unknown scaling factor: %s", s, 0);
return 1;
}
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-10-22 17:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-22 15:04 PATCH: "limit" should not set a limit to 0 on bad input Bart Schaefer
[not found] <11892.1003769407@csr.com>
2001-10-22 17:44 ` Bart Schaefer
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).