zsh-workers
 help / color / mirror / code / Atom feed
From: Geoff Wing <mason@werple.net.au>
To: zsh-workers@math.gatech.edu (zsh-list)
Subject: RLIM_T more fixes
Date: Sat, 29 Jun 1996 04:23:24 +1000 (EST)	[thread overview]
Message-ID: <199606281823.SAA21741@werple.net.au> (raw)

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@werple.mira.net.au    "Hurt...Agony...Pain...LOVE-IT"



                 reply	other threads:[~1996-06-28 18:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199606281823.SAA21741@werple.net.au \
    --to=mason@werple.net.au \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).