[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.140,2.141

Tim Peters tim_one@users.sourceforge.net
Wed, 28 Nov 2001 12:27:44 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv5054/python/Objects

Modified Files:
	stringobject.c 
Log Message:
sprintf -> PyOS_snprintf in some "obviously safe" cases.
Also changed <>-style #includes to ""-style in some places where the
former didn't make sense.


Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.140
retrieving revision 2.141
diff -C2 -d -r2.140 -r2.141
*** stringobject.c	2001/10/22 04:12:44	2.140
--- stringobject.c	2001/11/28 20:27:42	2.141
***************
*** 2877,2881 ****
  	if (type == 'f' && fabs(x)/1e25 >= 1e25)
  		type = 'g';
! 	sprintf(fmt, "%%%s.%d%c", (flags&F_ALT) ? "#" : "", prec, type);
  	/* worst case length calc to ensure no buffer overrun:
  	     fmt = %#.<prec>g
--- 2877,2883 ----
  	if (type == 'f' && fabs(x)/1e25 >= 1e25)
  		type = 'g';
! 	PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c",
! 		      (flags&F_ALT) ? "#" : "",
! 		      prec, type);
  	/* worst case length calc to ensure no buffer overrun:
  	     fmt = %#.<prec>g
***************
*** 2890,2894 ****
  		return -1;
  	}
! 	sprintf(buf, fmt, x);
  	return strlen(buf);
  }
--- 2892,2896 ----
  		return -1;
  	}
! 	PyOS_snprintf(buf, buflen, fmt, x);
  	return strlen(buf);
  }
***************
*** 3048,3052 ****
  	if (prec < 0)
  		prec = 1;
! 	sprintf(fmt, "%%%s.%dl%c", (flags&F_ALT) ? "#" : "", prec, type);
  	/* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec, len(x in octal))
  	   worst case buf = '0x' + [0-9]*prec, where prec >= 11 */
--- 3050,3056 ----
  	if (prec < 0)
  		prec = 1;
! 	PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c",
! 		      (flags&F_ALT) ? "#" : "", 
! 		      prec, type);
  	/* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec, len(x in octal))
  	   worst case buf = '0x' + [0-9]*prec, where prec >= 11 */
***************
*** 3056,3060 ****
  		return -1;
  	}
! 	sprintf(buf, fmt, x);
  	/* When converting 0 under %#x or %#X, C leaves off the base marker,
  	 * but we want it (for consistency with other %#x conversions, and
--- 3060,3064 ----
  		return -1;
  	}
! 	PyOS_snprintf(buf, buflen, fmt, x);
  	/* When converting 0 under %#x or %#X, C leaves off the base marker,
  	 * but we want it (for consistency with other %#x conversions, and