From: Scott MacVicar Date: Sat, 22 Nov 2008 10:27:19 +0000 (+0000) Subject: Warnings from libmagic should be notices rather than sent to stderr, this fixes a... X-Git-Tag: BEFORE_HEAD_NS_CHANGES_MERGE~119 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a064b61971afbcf143789efd79833a29921f19d9;p=php Warnings from libmagic should be notices rather than sent to stderr, this fixes a test on Windows --- diff --git a/ext/fileinfo/libmagic/print.c b/ext/fileinfo/libmagic/print.c index 3ebbc019ad..5a54fb692c 100644 --- a/ext/fileinfo/libmagic/print.c +++ b/ext/fileinfo/libmagic/print.c @@ -29,6 +29,8 @@ * print.c - debugging printout routines */ +#include "php.h" + #include "file.h" #include #include @@ -51,18 +53,16 @@ protected void file_magwarn(struct magic_set *ms, const char *f, ...) { va_list va; + char *expanded_format; + TSRMLS_FETCH(); - /* cuz we use stdout for most, stderr here */ - (void) fflush(stdout); - - if (ms->file) - (void) fprintf(stderr, "%s, %lu: ", ms->file, - (unsigned long)ms->line); - (void) fprintf(stderr, "Warning: "); va_start(va, f); - (void) vfprintf(stderr, f, va); + vasprintf(&expanded_format, f, va); va_end(va); - (void) fputc('\n', stderr); + + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format); + + efree(expanded_format); } protected const char * diff --git a/ext/fileinfo/tests/finfo_open_error.phpt b/ext/fileinfo/tests/finfo_open_error.phpt index 079a2cb738..4aa3736783 100644 --- a/ext/fileinfo/tests/finfo_open_error.phpt +++ b/ext/fileinfo/tests/finfo_open_error.phpt @@ -31,7 +31,8 @@ bool(false) Warning: finfo_open() expects at most 2 parameters, 3 given in %s on line %d bool(false) -unknown, 0: Warning: using regular magic file `%s' + +Notice: finfo_open(): Warning: using regular magic file `%s' in %s on line %d resource(%d) of type (file_info) Warning: finfo_open() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d