cvs: php4 /ext/standard dir.c /main main.c
| From: | Zeev Suraski | Date: | Fri, 01 Sep 2000 12:06:52 +0000 |
| Subject: | cvs: php4 /ext/standard dir.c /main main.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1487@lists.php.net to get a copy of this message | ||
zeev Fri Sep 1 05:06:52 2000 EDT
Modified files:
/php4/ext/standard dir.c
/php4/main main.c
Log:
- Fix dir.c
- Begin cleanup of php_error_cb()
Index: php4/ext/standard/dir.c
diff -u php4/ext/standard/dir.c:1.42 php4/ext/standard/dir.c:1.43
--- php4/ext/standard/dir.c:1.42 Fri Sep 1 02:38:19 2000
+++ php4/ext/standard/dir.c Fri Sep 1 05:06:52 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dir.c,v 1.42 2000/09/01 09:38:19 sas Exp $ */
+/* $Id: dir.c,v 1.43 2000/09/01 12:06:52 zeev Exp $ */
/* {{{ includes/startup/misc */
@@ -289,7 +289,7 @@
{
pval **id, **tmp, *myself;
php_dir *dirp;
- char entry[sizeof(struct dirent) + PATH_MAX + 1];
+ char entry[sizeof(struct dirent)+MAXPATHLEN+1];
struct dirent *result;
DIRLS_FETCH();
Index: php4/main/main.c
diff -u php4/main/main.c:1.309 php4/main/main.c:1.310
--- php4/main/main.c:1.309 Fri Sep 1 02:54:32 2000
+++ php4/main/main.c Fri Sep 1 05:06:52 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.309 2000/09/01 09:54:32 sas Exp $ */
+/* $Id: main.c,v 1.310 2000/09/01 12:06:52 zeev Exp $ */
#include <stdio.h>
@@ -326,15 +326,19 @@
/* extended error handling function */
-static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char
*format, va_list orig_args)
+static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char
*format, va_list args)
{
char buffer[1024];
- zend_bool buffer_ok = 0;
- int size = 0;
+ int buffer_len;
ELS_FETCH();
PLS_FETCH();
- if (EG(error_reporting) & type || (type & E_CORE)) {
+ buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args);
+ buffer[sizeof(buffer)-1]=0;
+
+ /* display/log the error if necessary */
+ if ((EG(error_reporting) & type || (type & E_CORE))
+ && (PG(log_errors) || PG(display_errors) || (!module_initialized))) {
char *error_type_str;
switch (type) {
@@ -363,65 +367,57 @@
error_type_str = "Unknown error";
break;
}
-
- /* get include file name */
- if (PG(log_errors) || PG(display_errors) || (!module_initialized)) {
- size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args);
- buffer_ok = 1;
- va_end(orig_args);
-
- buffer[sizeof(buffer) - 1] = 0;
- if (!module_initialized || PG(log_errors)) {
- char log_buffer[1024];
+ if (!module_initialized || PG(log_errors)) {
+ char log_buffer[1024];
#ifdef PHP_WIN32
- if (type==E_CORE_ERROR || type==E_CORE_WARNING) {
- MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE);
- }
+ if (type==E_CORE_ERROR || type==E_CORE_WARNING) {
+ MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE);
+ }
#endif
- snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer,
error_filename, error_lineno);
- php_log_err(log_buffer);
+ snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer,
error_filename, error_lineno);
+ php_log_err(log_buffer);
+ }
+ if (module_initialized && PG(display_errors)) {
+ char *prepend_string = INI_STR("error_prepend_string");
+ char *append_string = INI_STR("error_append_string");
+ char *error_format;
+
+ error_format = PG(html_errors) ?
+ "<br>\n<b>%s</b>: %s in <b>%s</b> on line
<b>%d</b><br>\n"
+ : "\n%s: %s in %s on line %d\n";
+
+ if (prepend_string) {
+ PUTS(prepend_string);
}
- if (module_initialized && PG(display_errors)) {
- char *prepend_string = INI_STR("error_prepend_string");
- char *append_string = INI_STR("error_append_string");
- char *error_format;
-
- error_format = PG(html_errors) ?
- "<br>\n<b>%s</b>: %s in <b>%s</b> on line
<b>%d</b><br>\n"
- : "\n%s: %s in %s on line %d\n";
-
- if (prepend_string) {
- PUTS(prepend_string);
- }
- php_printf(error_format, error_type_str, buffer,
- error_filename, error_lineno);
- if (append_string) {
- PUTS(append_string);
- }
+ php_printf(error_format, error_type_str, buffer,
+ error_filename, error_lineno);
+ if (append_string) {
+ PUTS(append_string);
}
+ }
#if ZEND_DEBUG
- {
- zend_bool trigger_break;
+ {
+ zend_bool trigger_break;
- switch (type) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- trigger_break=1;
- break;
- default:
- trigger_break=0;
- break;
- }
- zend_output_debug_string(trigger_break, "%s(%d) : %s - %s", error_filename,
error_lineno, error_type_str, buffer);
+ switch (type) {
+ case E_ERROR:
+ case E_CORE_ERROR:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ trigger_break=1;
+ break;
+ default:
+ trigger_break=0;
+ break;
}
-#endif
+ zend_output_debug_string(trigger_break, "%s(%d) : %s - %s", error_filename,
error_lineno, error_type_str, buffer);
}
+#endif
}
+ /* Bail out if we can't recover */
switch (type) {
case E_CORE_ERROR:
if(!module_initialized) {
@@ -440,21 +436,15 @@
break;
}
+ /* Log if necessary */
if (PG(track_errors) && EG(active_symbol_table)) {
pval *tmp;
- if (!buffer_ok) {
- size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args);
- buffer[sizeof(buffer) - 1] = 0;
- va_end(orig_args);
- }
-
ALLOC_ZVAL(tmp);
INIT_PZVAL(tmp);
- tmp->value.str.val = (char *) estrndup(buffer, size);
- tmp->value.str.len = size;
+ tmp->value.str.val = (char *) estrndup(buffer, buffer_len);
+ tmp->value.str.len = buffer_len;
tmp->type = IS_STRING;
-
zend_hash_update(EG(active_symbol_table), "php_errormsg",
sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL);
}
}