cvs: php4 /ext/standard file.c file.h
| From: | Sean Bright | Date: | Sat, 04 Aug 2001 12:36:51 +0000 |
| Subject: | cvs: php4 /ext/standard file.c file.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6541@lists.php.net to get a copy of this message | ||
elixer Sat Aug 4 08:36:51 2001 EDT
Modified files:
/php4/ext/standard file.c file.h
Log:
Don't allocated quoted strings unless we are in a META tag.
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.176 php4/ext/standard/file.c:1.177
--- php4/ext/standard/file.c:1.176 Tue Jul 31 03:09:44 2001
+++ php4/ext/standard/file.c Sat Aug 4 08:36:51 2001
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.176 2001/07/31 07:09:44 zeev Exp $ */
+/* $Id: file.c,v 1.177 2001/08/04 12:36:51 elixer Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -285,6 +285,7 @@
#define PHP_META_UNSAFE ".\\+*?[^]$() "
/* {{{ proto array get_meta_tags(string filename [, int use_include_path])
+
Extracts all meta tag content attributes from a file and returns an array */
PHP_FUNCTION(get_meta_tags)
@@ -348,6 +349,7 @@
if (tok == TOK_ID) {
if (tok_last == TOK_OPENTAG) {
in_meta_tag = !strcasecmp("meta",md.token_data);
+ md.in_meta = in_meta_tag;
} else if (tok_last == TOK_SLASH && in_tag) {
if (strcasecmp("head", md.token_data) == 0) {
/* We are done here! */
@@ -444,6 +446,7 @@
in_tag = in_meta_tag = looking_for_val = 0;
have_name = saw_name = 0;
have_content = saw_content = 0;
+ md.in_meta = 0;
}
tok_last = tok;
@@ -2378,6 +2381,7 @@
#define PHP_META_HTML401_CHARS "-_.:"
/* {{{ php_next_meta_token
+
Tokenizes an HTML file for get_meta_tags */
php_meta_tags_token php_next_meta_token(php_meta_tags_data *md)
{
@@ -2429,8 +2433,11 @@
md->lc = ch;
}
- md->token_data = (char *) emalloc(md->token_len + 1);
- memcpy(md->token_data,buff,md->token_len+1);
+ /* We don't need to alloc unless we are in a meta tag */
+ if (md->in_meta) {
+ md->token_data = (char *) emalloc(md->token_len + 1);
+ memcpy(md->token_data,buff,md->token_len+1);
+ }
return TOK_STRING;
break;
@@ -2474,6 +2481,7 @@
return TOK_EOF;
}
+
/* }}} */
/*
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.38 php4/ext/standard/file.h:1.39
--- php4/ext/standard/file.h:1.38 Sat Jul 28 07:36:16 2001
+++ php4/ext/standard/file.h Sat Aug 4 08:36:51 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.h,v 1.38 2001/07/28 11:36:16 zeev Exp $ */
+/* $Id: file.h,v 1.39 2001/08/04 12:36:51 elixer Exp $ */
/* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
@@ -100,6 +100,7 @@
char *input_buffer;
char *token_data;
int token_len;
+ int in_meta;
} php_meta_tags_data;
php_meta_tags_token php_next_meta_token(php_meta_tags_data *);