helly Fri Feb 14 14:43:07 2003 EDT
Modified files:
/php4/ext/standard image.c
Log:
a little bit slower but somewhat tricky and more flexible and it does not
allocate static buffers anymore
Index: php4/ext/standard/image.c
diff -u php4/ext/standard/image.c:1.90 php4/ext/standard/image.c:1.91
--- php4/ext/standard/image.c:1.90 Thu Feb 13 02:02:53 2003
+++ php4/ext/standard/image.c Fri Feb 14 14:43:06 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: image.c,v 1.90 2003/02/13 07:02:53 sniper Exp $ */
+/* $Id: image.c,v 1.91 2003/02/14 19:43:06 helly Exp $ */
#include "php.h"
#include <stdio.h>
@@ -956,11 +956,10 @@
/* {{{ php_get_xbm
*/
-#define MAX_XBM_LINE_SIZE 255
static int php_get_xbm(php_stream *stream, struct gfxinfo **result TSRMLS_DC)
{
- char fline[MAX_XBM_LINE_SIZE];
- char iname[MAX_XBM_LINE_SIZE];
+ char *fline;
+ char *iname;
char *type;
int value;
unsigned int width = 0, height = 0;
@@ -971,12 +970,8 @@
if (php_stream_rewind(stream)) {
return 0;
}
- while (php_stream_gets(stream, fline, MAX_XBM_LINE_SIZE)) {
- fline[MAX_XBM_LINE_SIZE-1] = '\0';
- if (strlen(fline) == MAX_XBM_LINE_SIZE-1) {
- return 0;
- }
-
+ while ((fline=php_stream_gets(stream, NULL, 0)) != NULL) {
+ iname = estrdup(fline); /* simple way to get necessary buffer of
+required size */
if (sscanf(fline, "#define %s %d", iname, &value) == 2) {
if (!(type = strrchr(iname, '_'))) {
type = iname;
@@ -987,16 +982,23 @@
if (!strcmp("width", type)) {
width = (unsigned int) value;
if (height) {
+ efree(iname);
break;
}
}
if (!strcmp("height", type)) {
height = (unsigned int) value;
if (width) {
+ efree(iname);
break;
}
}
}
+ efree(fline);
+ efree(iname);
+ }
+ if (fline) {
+ efree(fline);
}
if (width && height) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php