cvs: php4 /ext/xslt sablot.c

From: Date: Thu, 23 Aug 2001 21:22:38 +0000
Subject: cvs: php4 /ext/xslt sablot.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-7036@lists.php.net to get a copy of this message
sterling Thu Aug 23 17:22:38 2001 EDT Modified files: /php4/ext/xslt sablot.c Log: some cleanup Index: php4/ext/xslt/sablot.c diff -u php4/ext/xslt/sablot.c:1.19 php4/ext/xslt/sablot.c:1.20 --- php4/ext/xslt/sablot.c:1.19 Tue Jul 31 19:34:22 2001 +++ php4/ext/xslt/sablot.c Thu Aug 23 17:22:37 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sablot.c,v 1.19 2001/07/31 23:34:22 sniper Exp $ */ +/* $Id: sablot.c,v 1.20 2001/08/23 21:22:37 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -128,9 +128,9 @@ /* Error handlers, automatically registered */ static MessageHandler message_handler = { - error_makecode, - error_log, - error_print + error_makecode, + error_log, + error_print }; /* Scheme handlers automatically registered */ @@ -1259,7 +1259,7 @@ Make the error code */ static MH_ERROR error_makecode(void *user_data, SablotHandle proc, int severity, unsigned short facility, unsigned short code) { - return(0); + return 0; } /* }}} */ @@ -1281,7 +1281,7 @@ /* Parse the error array */ /* Loop through the error array */ if (fields) { - while (fields && *fields) { + while (*fields) { char *key; /* Key to for the message */ char *val; /* The message itself */ char *ptr; /* Pointer to the location of the ':' (separator) */ @@ -1301,11 +1301,8 @@ key = emalloc(pos + 1); val = emalloc((len - pos) + 1); - memcpy(key, *fields, pos); - memcpy(val, *fields + pos + 1, len - pos - 1); - - key[pos] = '\0'; - val[len - pos - 1] = '\0'; + strlcpy(key, *fields, pos); + strlcpy(val, *fields + pos + 1, len - pos - 1); /* Check to see whether or not we want to save the data */ if (!strcmp(key, "msg")) { @@ -1370,7 +1367,7 @@ XSLT_LOG(handle).fd = open(XSLT_LOG(handle).path, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR); - if (XSLT_LOG(handle).fd < 0) { + if (XSLT_LOG(handle).fd == -1) { php_error(E_WARNING, "Cannot open log file, %s [%d]: %s", XSLT_LOG(handle).path, errno, strerror(errno)); XSLT_LOG(handle).fd = 0; @@ -1385,12 +1382,12 @@ /* Write the error to the file */ error = write(XSLT_LOG(handle).fd, msgbuf, strlen(msgbuf)); - if (error < 1) { + if (error == -1) { php_error(E_WARNING, "Cannot write data to log file, %s, with fd, %d [%d]: %s", (XSLT_LOG(handle).path ? XSLT_LOG(handle).path : "stderr"), XSLT_LOG(handle).fd, - error, - strerror(error)); + errno, + strerror(errno)); return 0; } @@ -1433,7 +1430,7 @@ ZVAL_LONG(argv[2], code); if (fields) { - while (fields && *fields) { + while (*fields) { char *key; /* Key to for the message */ char *val; /* The message itself */ char *ptr; /* Pointer to the location of the ':' (separator) */ @@ -1453,10 +1450,8 @@ key = emalloc(pos + 1); val = emalloc((len - pos) + 1); - memcpy(key, *fields, pos); - memcpy(val, *fields + pos + 1, len - pos - 1); - key[pos] = '\0'; - val[len - pos - 1] = '\0'; + strlcpy(key, *fields, pos); + strlcpy(val, *fields + pos + 1, len - pos - 1); /* Add it */ add_assoc_stringl_ex(argv[3], key, pos, val, len - pos - 1, 1); @@ -1513,11 +1508,8 @@ key = emalloc(pos + 1); val = emalloc((len - pos) + 1); - memcpy(key, *fields, pos); - memcpy(val, *fields + pos + 1, len - pos - 1); - - key[pos] = '\0'; - val[len - pos - 1] = '\0'; + strlcpy(key, *fields, pos); + strlcpy(val, *fields + pos + 1, len - pos - 1); /* Check to see whether or not we want to save the data */ if (!strcmp(key, "msg")) {

« previous php.cvs (#7036) next »