cvs: php4 /ext/pgsql pgsql.c
| From: | Yasuo Ohgaki | Date: | Mon, 25 Nov 2002 01:38:30 +0000 |
| Subject: | cvs: php4 /ext/pgsql pgsql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-16630@lists.php.net to get a copy of this message | ||
yohgaki Sun Nov 24 20:38:30 2002 EDT
Modified files:
/php4/ext/pgsql pgsql.c
Log:
Cleanup state=4 and avoid using sscanf()
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.247 php4/ext/pgsql/pgsql.c:1.248
--- php4/ext/pgsql/pgsql.c:1.247 Sun Nov 24 11:23:37 2002
+++ php4/ext/pgsql/pgsql.c Sun Nov 24 20:38:29 2002
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql.c,v 1.247 2002/11/24 16:23:37 sas Exp $ */
+/* $Id: pgsql.c,v 1.248 2002/11/25 01:38:29 yohgaki Exp $ */
#include <stdlib.h>
@@ -2708,15 +2708,13 @@
case 3:
if (isdigit(*sp)) /* state=4 */
{
- unsigned int v,i;
- unsigned char buf[4]; /* 000 + '\0' */
-
+ unsigned char *start, *end, buf[4]; /* 000 + '\0' */
+
bp -= 3;
- for (i = 0; i < 3; i++)
- buf[i] = *((sp-2)+i);
- buf[i] = '\0';
- sscanf(buf, "%03o", &v);
- *bp = v;
+ memcpy(buf, sp-2, 3);
+ buf[3] = '\0';
+ start = buf;
+ *bp = (unsigned char)strtoul(start, &end, 8);
buflen -= 3;
state = 0;
}