cvs: /php4/ext/standard file.c php_string.h
| From: | Andrei Zmievski | Date: | Sat, 11 Dec 1999 19:51:35 +0000 |
| Subject: | cvs: /php4/ext/standard file.c php_string.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-7799@lists.php.net to get a copy of this message | ||
andrei Sat Dec 11 14:51:35 1999 EDT
Modified files:
/php4/ext/standard file.c php_string.h
Log:
get_meta_tags() was using php_stristr() so it needed to be changed.
Optimized it to use php_memnstr() directly.
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.46 php4/ext/standard/file.c:1.47
--- php4/ext/standard/file.c:1.46 Sun Dec 5 11:25:31 1999
+++ php4/ext/standard/file.c Sat Dec 11 14:51:04 1999
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.46 1999/12/05 16:25:31 sas Exp $ */
+/* $Id: file.c,v 1.47 1999/12/11 19:51:04 andrei Exp $ */
/* Synced with php3 revision 1.218 1999-06-16 [ssb] */
@@ -386,6 +386,7 @@
pval **filename, **arg2;
FILE *fp;
char buf[8192];
+ char buf_lcase[8192];
int use_include_path = 0;
int issock=0, socketd=0;
int len, var_namelen;
@@ -432,14 +433,19 @@
}
/* Now loop through the file and do the magic quotes thing if needed */
memset(buf, 0, 8191);
- while((FP_FGETS(buf,8191,socketd,fp,issock) != NULL)
- && !php_stristr(buf,"</head>")) {
- if(php_stristr(buf,"<meta")) {
+ while((FP_FGETS(buf,8191,socketd,fp,issock) != NULL)) {
+ memcpy(buf_lcase, buf, 8191);
+ php_strtolower(buf_lcase, 8191);
+ if (php_memnstr(buf_lcase, "</head>", sizeof("</head>")-1,
buf_lcase + 8191))
+ break;
+ if(php_memnstr(buf_lcase, "<meta", sizeof("<meta")-1, buf_lcase +
8191)) {
+
memset(var_name,0,50);
/* get the variable name from the name attribute of the meta tag */
- tmp=php_stristr(buf,"name=\"");
+ tmp = php_memnstr(buf_lcase, "name=\"", sizeof("name=\"")-1,
buf_lcase + 8191);
if(tmp) {
+ tmp = &buf[tmp - buf_lcase];
tmp+=6;
end=strstr(tmp,"\"");
if(end) {
@@ -473,8 +479,9 @@
}
/* get the variable value from the content attribute of the meta tag */
- tmp=php_stristr(buf,"content=\"");
+ tmp = php_memnstr(buf_lcase, "content=\"",
sizeof("content=\"")-1, buf_lcase + 8191);
if(tmp) {
+ tmp = &buf[tmp - buf_lcase];
tmp+=9;
end=strstr(tmp,"\"");
if(end) {
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.2 php4/ext/standard/php_string.h:1.3
--- php4/ext/standard/php_string.h:1.2 Thu Dec 9 18:45:30 1999
+++ php4/ext/standard/php_string.h Sat Dec 11 14:51:04 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php_string.h,v 1.2 1999/12/09 23:45:30 andrei Exp $ */
+/* $Id: php_string.h,v 1.3 1999/12/11 19:51:04 andrei Exp $ */
/* Synced with php3 revision 1.43 1999-06-16 [ssb] */
@@ -92,7 +92,7 @@
extern PHPAPI void php_stripslashes(char *string, int *len);
extern PHPAPI void php_stripcslashes(char *string, int *len);
extern PHPAPI void php_dirname(char *str, int len);
-extern PHPAPI char *php_stristr(unsigned char *s, unsigned char *t);
+extern PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t t_len);
extern PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
int needle_len, char *str, int str_len, int *_new_length);
extern PHPAPI void php_trim(pval *str, pval *return_value, int mode);
@@ -102,5 +102,6 @@
extern PHPAPI void php_implode(pval *delim, pval *arr, pval *return_value);
extern PHPAPI void php_explode(pval *delim, pval *str, pval *return_value);
+PHPAPI inline char *php_memnstr(char *haystack, char *needle, int needle_len, char *end);
#endif /* _PHPSTRING_H */