Skip to content

Commit fa38a6a

Browse files
committed
No more (f)printf for errors and warnings instead use php_error_docref.
1 parent e178bdc commit fa38a6a

File tree

11 files changed

+168
-137
lines changed

11 files changed

+168
-137
lines changed

ext/gd/libgd/gd.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ static int gdAlphaBlendColor(int b1, int b2, int a1, int a2);
9292
static int gdAlphaOverlayColor(int src, int dst, int max);
9393
static int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
9494

95+
void php_gd_error_ex(int type, const char *format, ...)
96+
{
97+
va_list args;
98+
99+
TSRMLS_FETCH();
100+
101+
va_start(args, format);
102+
php_verror(NULL, "", type, format, args TSRMLS_CC);
103+
va_end(args);
104+
}
105+
106+
void php_gd_error(const char *format, ...)
107+
{
108+
va_list args;
109+
110+
TSRMLS_FETCH();
111+
112+
va_start(args, format);
113+
php_verror(NULL, "", E_WARNING, format, args TSRMLS_CC);
114+
va_end(args);
115+
}
116+
95117
gdImagePtr
96118
gdImageCreate (int sx, int sy)
97119
{
@@ -2780,7 +2802,7 @@ gdImageCreateFromXbm (FILE * fd)
27802802
}
27812803
}
27822804
/* Shouldn't happen */
2783-
fprintf (stderr, "Error: bug in gdImageCreateFromXbm!\n");
2805+
php_gd_error("Error: bug in gdImageCreateFromXbm\n");
27842806
return 0;
27852807
fail:
27862808
gdImageDestroy (im);

ext/gd/libgd/gd.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ extern "C" {
3030
#include <stdio.h>
3131
#include "gd_io.h"
3232

33+
void php_gd_error_ex(int type, const char *format, ...);
34+
35+
void php_gd_error(const char *format, ...);
36+
37+
3338
/* The maximum number of palette entries in palette-based images.
3439
In the wonderful new world of gd 2.0, you can of course have
3540
many more colors when using truecolor mode. */

ext/gd/libgd/gd_arc_f_buggy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,12 +726,12 @@ main (int argc, char *argv[])
726726
out = fopen ("test/arctest.png", "wb");
727727
if (!out)
728728
{
729-
fprintf (stderr, "Can't create test/arctest.png\n");
729+
php_gd_error("Can't create test/arctest.png\n");
730730
exit (1);
731731
}
732732
gdImagePng (im, out);
733733
fclose (out);
734-
fprintf (stderr, "Test image written to test/arctest.png\n");
734+
php_gd_error("Test image written to test/arctest.png\n");
735735
/* Destroy it */
736736
gdImageDestroy (im);
737737

0 commit comments

Comments
 (0)