about summary refs log tree commit diff
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
parentaf711a4dfc57fff491fe8ca3cdeb47e020f2e7c3 (diff)
downloadzsh-6a75b3c0c59a8d6fc6718acaaffada3503611dd8.tar.gz
zsh-6a75b3c0c59a8d6fc6718acaaffada3503611dd8.tar.xz
zsh-6a75b3c0c59a8d6fc6718acaaffada3503611dd8.zip
16197: `limit' accepts `unlimited'.
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Zsh/Command/.distfiles14
-rw-r--r--Completion/Zsh/Command/_limit9
-rw-r--r--Completion/Zsh/Type/_limits2
-rw-r--r--Src/Builtins/rlimits.c22
5 files changed, 37 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 3599f3c65..f2558b339 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-11-01  Bart Schaefer  <schaefer@zsh.org>
+
+	* 16197: Completion/Zsh/Command/.distfiles,
+	Completion/Zsh/Command/_limit, Completion/Zsh/Type/_limits,
+	Src/Builtins/rlimits.c: `limit' accepts `unlimited' as a value.
+
 2001-10-26  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* 16184: Src/hist.c: Improved readhistline() to reject binary data
diff --git a/Completion/Zsh/Command/.distfiles b/Completion/Zsh/Command/.distfiles
index 4e75e0e3d..a3762d14a 100644
--- a/Completion/Zsh/Command/.distfiles
+++ b/Completion/Zsh/Command/.distfiles
@@ -1,10 +1,10 @@
 DISTFILES_SRC='
 .distfiles
-_autoload    _disable     _kill        _sched       _typeset     _zed
-_bindkey     _echotc      _mere        _set         _unhash      _zftp
-_builtin     _emulate     _precommand  _setopt      _unsetopt    _zle
-_cd          _enable      _print       _source      _wait        _zmodload
-_command     _fc          _prompt      _stat        _which       _zpty
-_compdef     _hash        _read        _trap        _zcompile    _zstyle
-_echoti      _ttyctl      _ulimit      _vared       _alias       _jobs_builtin
+_alias     _disable  _jobs_builtin  _read    _ttyctl    _which     _zstyle
+_autoload  _echotc   _kill          _sched   _typeset   _zcompile
+_bindkey   _echoti   _limit         _set     _ulimit    _zed
+_builtin   _emulate  _mere          _setopt  _unhash    _zftp
+_cd        _enable   _precommand    _source  _unsetopt  _zle
+_command   _fc       _print         _stat    _vared     _zmodload
+_compdef   _hash     _prompt        _trap    _wait      _zpty
 '
diff --git a/Completion/Zsh/Command/_limit b/Completion/Zsh/Command/_limit
new file mode 100644
index 000000000..ba384f980
--- /dev/null
+++ b/Completion/Zsh/Command/_limit
@@ -0,0 +1,9 @@
+#compdef limit
+
+if ! ((CURRENT % 2)); then
+    _limits
+elif [[ $PREFIX = u* ]]; then
+    compadd unlimited
+else
+    _message "number and scaling factor"
+fi
diff --git a/Completion/Zsh/Type/_limits b/Completion/Zsh/Type/_limits
index 5dd2bffe5..232ce7e94 100644
--- a/Completion/Zsh/Type/_limits
+++ b/Completion/Zsh/Type/_limits
@@ -1,4 +1,4 @@
-#compdef limit unlimit
+#compdef unlimit
 
 local expl
 
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);