Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RLIM_T more fixes



Heyla, 
  this goes on top of article 1444 (though this is diff'd on 3.0-pre1)
The previous patch will patch clean with 3.0-pre1 (just line offsets).
This cleans up the types in the rest of the rlimit stuff.  
I'm still looking for a bug somewhere which is causing me problems
with this.  limits[] stuff is getting corrupted somehow, but I'm not
certain zsh's causing it (might be a gcc bug (gcc used to have bugs
with "long long"s)).


*** builtin.c.~2~	Sat Jun 29 02:48:27 1996
--- builtin.c	Sat Jun 29 02:48:29 1996
***************
*** 3534,3539 ****
--- 3534,3546 ----
   * appear in this array in numerical order of the RLIMIT_* macros.     */
  
  #ifdef HAVE_GETRLIMIT
+ 
+ #ifdef RLIM_T_IS_QUAD_T
+ # define ZSTRTORLIMT(a, b, c)	zstrtoq((a), (b), (c))
+ #else
+ # define ZSTRTORLIMT(a, b, c)	zstrtol((a), (b), (c))
+ #endif
+ 
  static char *recs[] =
  {
      "cputime", "filesize", "datasize", "stacksize", "coredumpsize",
***************
*** 3608,3614 ****
  #else
      char *s;
      int hard, limnum, lim;
!     long val;
  
      hard = ops['h'];
      if (ops['s']) {
--- 3615,3621 ----
  #else
      char *s;
      int hard, limnum, lim;
!     RLIM_T val;
  
      hard = ops['h'];
      if (ops['s']) {
***************
*** 3653,3666 ****
  	     * 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;
--- 3660,3673 ----
  	     * 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 = ZSTRTORLIMT(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 + ZSTRTORLIMT(s + 1, &s, 10);
  		else {
  		    zwarnnam("limit", "unknown scaling factor: %s", s, 0);
  		    return 1;
***************
*** 3670,3687 ****
  	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])
--- 3677,3694 ----
  	else if (lim == RLIMIT_NPROC)
  	    /* pure numeric resource -- only a straight decimal number is
  	    permitted. */
! 	    val = ZSTRTORLIMT(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 = ZSTRTORLIMT(s, &s, 10);
  # endif /* RLIMIT_NOFILE */
  	else {
  	    /* 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])
***************
*** 3839,3849 ****
  	/* set limit to specified value */
  	RLIM_T limit;
  
! #ifdef RLIM_T_IS_QUAD_T
! 	limit = (RLIM_T) zstrtoq(*argv, NULL, 10);
! #else
! 	limit = (RLIM_T) zstrtol(*argv, NULL, 10);
! #endif
  	/* scale appropriately */
  	switch (res) {
  	case RLIMIT_FSIZE:
--- 3846,3852 ----
  	/* set limit to specified value */
  	RLIM_T limit;
  
! 	limit = ZSTRTORLIMT(*argv, NULL, 10);
  	/* scale appropriately */
  	switch (res) {
  	case RLIMIT_FSIZE:

-- 
Mason [G.C.W]  mason@xxxxxxxxxxxxxxxxxx    "Hurt...Agony...Pain...LOVE-IT"




Messages sorted by: Reverse Date, Date, Thread, Author