about summary refs log tree commit diff
path: root/Src/Builtins
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-11-01 15:41:40 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-11-01 15:41:40 +0000
commit6a75b3c0c59a8d6fc6718acaaffada3503611dd8 (patch)
tree569135ed437a633f9965481ea82b5d446b5cd269 /Src/Builtins
parentaf711a4dfc57fff491fe8ca3cdeb47e020f2e7c3 (diff)
downloadzsh-6a75b3c0c59a8d6fc6718acaaffada3503611dd8.tar.gz
zsh-6a75b3c0c59a8d6fc6718acaaffada3503611dd8.tar.xz
zsh-6a75b3c0c59a8d6fc6718acaaffada3503611dd8.zip
16197: `limit' accepts `unlimited'.
Diffstat (limited to 'Src/Builtins')
-rw-r--r--Src/Builtins/rlimits.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index 0df671786..3db47f866 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -44,12 +44,17 @@ enum {
 
 # 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) {
+	if (t)
+	    *t = (char *) s + 9;
+	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 +72,11 @@ zstrtorlimt(const char *s, char **t, int base)
 	    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 *
@@ -348,9 +353,10 @@ bin_limit(char *nam, char **argv, char *ops, int func)
 	    /* memory-type resource -- `k' and `M' modifiers are permitted,
 	    meaning (respectively) 2^10 and 2^20. */
 	    val = zstrtorlimt(s, &s, 10);
-	    if (!*s || ((*s == 'k' || *s == 'K') && !s[1]))
-		val *= 1024L;
-	    else if ((*s == 'M' || *s == 'm') && !s[1])
+	    if (!*s || ((*s == 'k' || *s == 'K') && !s[1])) {
+		if (val != RLIM_INFINITY)
+		    val *= 1024L;
+	    } else if ((*s == 'M' || *s == 'm') && !s[1])
 		val *= 1024L * 1024;
 	    else {
 		zwarnnam("limit", "unknown scaling factor: %s", s, 0);