You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mc...@apache.org on 2002/07/12 16:31:15 UTC

cvs commit: apache-1.3/src/ap ap_strtol.c

mccreedy    2002/07/12 07:31:15

  Modified:    src/ap   ap_strtol.c
  Log:
  EBCDIC fix to ap/ap_strtol.c so it can handle bases greater than 19.
  
  Revision  Changes    Path
  1.8       +17 -3     apache-1.3/src/ap/ap_strtol.c
  
  Index: ap_strtol.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/ap/ap_strtol.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ap_strtol.c	18 Jun 2002 17:57:59 -0000	1.7
  +++ ap_strtol.c	12 Jul 2002 14:31:15 -0000	1.8
  @@ -106,9 +106,8 @@
    *
    * Assumes that the upper and lower case
    * alphabets and digits are each contiguous.
  - * As such, this will break on EBCDIC machines
  - * if base is >19. The highest we use is 16
  - * so we're OK, but you are warned!
  + * (On EBCDIC machines it assumes that digits and
  + *  upper/lower case A-I, J-R, and S-Z are contiguous.)
    */
   
   API_EXPORT(long) ap_strtol(const char *nptr, char **endptr, int base)
  @@ -173,10 +172,25 @@
   	for ( ; ; c = *s++) {
   		if (c >= '0' && c <= '9')
   			c -= '0';
  +#ifdef CHARSET_EBCDIC
  +		else if (c >= 'A' && c <= 'I')
  +			c -= 'A' - 10;
  +		else if (c >= 'a' && c <= 'i')
  +			c -= 'a' - 10;
  +		else if (c >= 'J' && c <= 'R')
  +			c -= 'J' - 19;
  +		else if (c >= 'j' && c <= 'r')
  +			c -= 'j' - 19;
  +		else if (c >= 'S' && c <= 'Z')
  +			c -= 'S' - 28;
  +		else if (c >= 's' && c <= 'z')
  +			c -= 's' - 28;
  +#else
   		else if (c >= 'A' && c <= 'Z')
   			c -= 'A' - 10;
   		else if (c >= 'a' && c <= 'z')
   			c -= 'a' - 10;
  +#endif /* CHARSET_EBCDIC */
   		else
   			break;
   		if (c >= base)