CVS update: php3/functions

From: Date: Mon, 05 Oct 1998 16:14:54 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1683@lists.php.net to get a copy of this message
Date: Monday October 5, 1998 @ 12:14 Author: zeev Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv12936/functions Modified Files: url.c Log Message: url.c fixes... I don't think we need warnings in those internally called functions. Also handle freeing memory in case of errors. Index: php3/functions/url.c diff -c php3/functions/url.c:1.38 php3/functions/url.c:1.39 *** php3/functions/url.c:1.38 Mon Oct 5 11:10:25 1998 --- php3/functions/url.c Mon Oct 5 12:14:54 1998 *************** *** 26,32 **** | Author: Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ ! /* $Id: url.c,v 1.38 1998/10/05 15:10:25 zeev Exp $ */ #include <stdlib.h> #include <string.h> --- 26,32 ---- | Author: Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ ! /* $Id: url.c,v 1.39 1998/10/05 16:14:54 zeev Exp $ */ #include <stdlib.h> #include <string.h> *************** *** 75,81 **** url *ret = (url *) emalloc(sizeof(url)); if (!ret) { ! php3_error(E_WARNING,"Unable to allocate memory\n"); return NULL; } memset(ret, 0, sizeof(url)); --- 75,81 ---- url *ret = (url *) emalloc(sizeof(url)); if (!ret) { ! /*php3_error(E_WARNING,"Unable to allocate memory\n");*/ return NULL; } memset(ret, 0, sizeof(url)); *************** *** 84,112 **** http://www.ics.uci.edu/~fielding/url/url.txt */ err = regcomp(&re, "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", REG_EXTENDED); if (err) { ! php3_error(E_WARNING,"Unable to compile regex: %d\n", err); return NULL; } err = regexec(&re, string, 10, subs, 0); if (err) { ! php3_error(E_WARNING,"Error with regex\n"); return NULL; } /* no processing necessary on the scheme */ ! if (subs[2].rm_so != -1 && subs[2].rm_so < length) ret->scheme = estrndup(string + subs[2].rm_so, subs[2].rm_eo - subs[2].rm_so); /* the path to the resource */ ! if (subs[5].rm_so != -1 && subs[5].rm_so < length) ret->path = estrndup(string + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so); /* the query part */ ! if (subs[7].rm_so != -1 && subs[7].rm_so < length) ret->query = estrndup(string + subs[7].rm_so, subs[7].rm_eo - subs[7].rm_so); /* the fragment */ ! if (subs[9].rm_so != -1 && subs[9].rm_so < length) ret->fragment = estrndup(string + subs[9].rm_so, subs[9].rm_eo - subs[9].rm_so); /* extract the username, pass, and port from the hostname */ if (subs[4].rm_so != -1 && subs[4].rm_so < length) { --- 84,118 ---- http://www.ics.uci.edu/~fielding/url/url.txt */ err = regcomp(&re, "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", REG_EXTENDED); if (err) { ! /*php3_error(E_WARNING,"Unable to compile regex: %d\n", err);*/ ! efree(ret); return NULL; } err = regexec(&re, string, 10, subs, 0); if (err) { ! /*php3_error(E_WARNING,"Error with regex\n");*/ ! efree(ret); return NULL; } /* no processing necessary on the scheme */ ! if (subs[2].rm_so != -1 && subs[2].rm_so < length) { ret->scheme = estrndup(string + subs[2].rm_so, subs[2].rm_eo - subs[2].rm_so); + } /* the path to the resource */ ! if (subs[5].rm_so != -1 && subs[5].rm_so < length) { ret->path = estrndup(string + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so); + } /* the query part */ ! if (subs[7].rm_so != -1 && subs[7].rm_so < length) { ret->query = estrndup(string + subs[7].rm_so, subs[7].rm_eo - subs[7].rm_so); + } /* the fragment */ ! if (subs[9].rm_so != -1 && subs[9].rm_so < length) { ret->fragment = estrndup(string + subs[9].rm_so, subs[9].rm_eo - subs[9].rm_so); + } /* extract the username, pass, and port from the hostname */ if (subs[4].rm_so != -1 && subs[4].rm_so < length) { *************** *** 115,140 **** length = strlen(result); regfree(&re); /* free the old regex */ ! err = regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED); ! if (err) { ! php3_error(E_WARNING,"Unable to compile regex: %d\n", err); ! return NULL; ! } ! err = regexec(&re, result, 10, subs, 0); ! if (err) { ! php3_error(E_WARNING,"error with regex\n"); return NULL; } /* now deal with all of the results */ ! if (subs[2].rm_so != -1 && subs[2].rm_so < length) ret->user = estrndup(result + subs[2].rm_so, subs[2].rm_eo - subs[2].rm_so); ! if (subs[4].rm_so != -1 && subs[4].rm_so < length) ret->pass = estrndup(result + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so); ! if (subs[5].rm_so != -1 && subs[5].rm_so < length) ret->host = estrndup(result + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so); ! if (subs[7].rm_so != -1 && subs[7].rm_so < length) ret->port = (unsigned short) strtol(result + subs[7].rm_so, NULL, 10); ! efree(result); } regfree(&re); --- 121,151 ---- length = strlen(result); regfree(&re); /* free the old regex */ ! ! if ((err=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED)) ! || (err=regexec(&re, result, 10, subs, 0))) { ! STR_FREE(ret->scheme); ! STR_FREE(ret->path); ! STR_FREE(ret->query); ! STR_FREE(ret->fragment); ! efree(ret); ! efree(result); ! /*php3_error(E_WARNING,"Unable to compile regex: %d\n", err);*/ return NULL; } /* now deal with all of the results */ ! if (subs[2].rm_so != -1 && subs[2].rm_so < length) { ret->user = estrndup(result + subs[2].rm_so, subs[2].rm_eo - subs[2].rm_so); ! } ! if (subs[4].rm_so != -1 && subs[4].rm_so < length) { ret->pass = estrndup(result + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so); ! } ! if (subs[5].rm_so != -1 && subs[5].rm_so < length) { ret->host = estrndup(result + subs[5].rm_so, subs[5].rm_eo - subs[5].rm_so); ! } ! if (subs[7].rm_so != -1 && subs[7].rm_so < length) { ret->port = (unsigned short) strtol(result + subs[7].rm_so, NULL, 10); ! } efree(result); } regfree(&re); -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1683) next »