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

RLIM_T fix, also atol



Heyla,
 this fixes some small things in rlimit stuff.
Also changes atol() to zstrtol() - atol() is not used anymore.
Diffs on beta21.



*** Src/builtin.c.~1~	Thu Jun 20 06:40:54 1996
--- Src/builtin.c	Wed Jun 26 19:40:53 1996
***************
*** 3798,3804 ****
  	/* set limit to specified value */
  	RLIM_T limit;
  
! 	limit = (RLIM_T) atol(*argv);
  	/* scale appropriately */
  	switch (res) {
  	case RLIMIT_FSIZE:
--- 3798,3808 ----
  	/* 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:
***************
*** 3925,3954 ****
  	break;
      case RLIMIT_FSIZE:
  	printf("file size (blocks)         ");
! 	limit /= 512;
  	break;
      case RLIMIT_DATA:
  	printf("data seg size (kbytes)     ");
! 	limit /= 1024;
  	break;
      case RLIMIT_STACK:
  	printf("stack size (kbytes)        ");
! 	limit /= 1024;
  	break;
      case RLIMIT_CORE:
  	printf("core file size (blocks)    ");
! 	limit /= 512;
  	break;
  # ifdef RLIMIT_RSS
      case RLIMIT_RSS:
  	printf("resident set size (kbytes) ");
! 	limit /= 1024;
  	break;
  # endif /* RLIMIT_RSS */
  # ifdef RLIMIT_MEMLOCK
      case RLIMIT_MEMLOCK:
  	printf("locked-in-memory size (kb) ");
! 	limit /= 1024;
  	break;
  # endif /* RLIMIT_MEMLOCK */
  # ifdef RLIMIT_NPROC
--- 3929,3964 ----
  	break;
      case RLIMIT_FSIZE:
  	printf("file size (blocks)         ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 512;
  	break;
      case RLIMIT_DATA:
  	printf("data seg size (kbytes)     ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 1024;
  	break;
      case RLIMIT_STACK:
  	printf("stack size (kbytes)        ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 1024;
  	break;
      case RLIMIT_CORE:
  	printf("core file size (blocks)    ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 512;
  	break;
  # ifdef RLIMIT_RSS
      case RLIMIT_RSS:
  	printf("resident set size (kbytes) ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 1024;
  	break;
  # endif /* RLIMIT_RSS */
  # ifdef RLIMIT_MEMLOCK
      case RLIMIT_MEMLOCK:
  	printf("locked-in-memory size (kb) ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 1024;
  	break;
  # endif /* RLIMIT_MEMLOCK */
  # ifdef RLIMIT_NPROC
***************
*** 3964,3976 ****
  # ifdef RLIMIT_VMEM
      case RLIMIT_VMEM:
  	printf("virtual memory size (kb)   ");
! 	limit /= 1024;
  	break;
  # endif /* RLIMIT_VMEM */
  # if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
      case RLIMIT_AS:
  	printf("address space (kb)         ");
! 	limit /= 1024;
  	break;
  # endif /* RLIMIT_AS */
      }
--- 3974,3988 ----
  # ifdef RLIMIT_VMEM
      case RLIMIT_VMEM:
  	printf("virtual memory size (kb)   ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 1024;
  	break;
  # endif /* RLIMIT_VMEM */
  # if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
      case RLIMIT_AS:
  	printf("address space (kb)         ");
! 	if (limit != RLIM_INFINITY)
! 	    limit /= 1024;
  	break;
  # endif /* RLIMIT_AS */
      }

*** Src/hist.c.~1~	Sat May 11 06:22:30 1996
--- Src/hist.c	Wed Jun 26 19:14:03 1996
***************
*** 1353,1363 ****
  	    pt = buf;
  	    if (*pt == ':') {
  		pt++;
! 		ent->stim = atol(pt);
  		for (; *pt != ':' && *pt; pt++);
  		if (*pt) {
  		    pt++;
! 		    ent->ftim = atol(pt);
  		    for (; *pt != ';' && *pt; pt++);
  		    if (*pt)
  			pt++;
--- 1353,1363 ----
  	    pt = buf;
  	    if (*pt == ':') {
  		pt++;
! 		ent->stim = zstrtol(pt, NULL, 0);
  		for (; *pt != ':' && *pt; pt++);
  		if (*pt) {
  		    pt++;
! 		    ent->ftim = zstrtol(pt, NULL, 0);
  		    for (; *pt != ';' && *pt; pt++);
  		    if (*pt)
  			pt++;

*** Src/utils.c.~1~	Thu Jun 20 06:01:40 1996
--- Src/utils.c	Wed Jun 26 19:11:38 1996
***************
*** 1055,1060 ****
--- 1055,1090 ----
      return ret;
  }
  
+ /* Convert string to quad_t. */
+ 
+ #ifdef RLIM_T_IS_QUAD_T
+ /**/
+ quad_t
+ zstrtoq(const char *s, char **t, int base)
+ {
+     quad_t ret = 0;
+  
+     if (!base)
+ 	if (*s != '0')
+ 	    base = 10;
+ 	else if (*++s == 'x' || *s == 'X')
+ 	    base = 16, s++;
+ 	else
+ 	    base = 8;
+  
+     if (base <= 10)
+ 	for (; *s >= '0' && *s < ('0' + base); s++)
+ 	    ret = ret * base + *s - '0';
+     else
+ 	for (; idigit(*s) || (*s >= 'a' && *s < ('a' + base - 10))
+ 	     || (*s >= 'A' && *s < ('A' + base - 10)); s++)
+ 	    ret = ret * base + (idigit(*s) ? (*s - '0') : (*s & 0x1f) + 9);
+     if (t)
+ 	*t = (char *)s;
+     return ret;
+ }
+ #endif
+ 
  /**/
  int
  checkrmall(char *s)



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




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