CVS update: php3/functions
| From: | shane | Date: | Mon, 07 Dec 1998 15:40:46 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-2688@lists.php.net to get a copy of this message | ||
Date: Monday December 7, 1998 @ 10:40
Author: shane
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv7800/functions
Modified Files:
basic_functions.c file.c php3_string.h string.c
Log Message:
fix for bug #918
added internal function php3i_stristr
added function stristr (case insensitive strstr)
Index: php3/functions/basic_functions.c
diff -c php3/functions/basic_functions.c:1.235 php3/functions/basic_functions.c:1.236
*** php3/functions/basic_functions.c:1.235 Wed Nov 18 16:23:03 1998
--- php3/functions/basic_functions.c Mon Dec 7 10:40:40 1998
***************
*** 177,182 ****
--- 177,183 ----
{"dirname", php3_dirname, NULL},
{"stripslashes", php3_stripslashes, NULL},
{"strstr", php3_strstr, NULL},
+ {"stristr", php3_stristr, NULL},
{"strrchr", php3_strrchr, NULL},
{"substr", php3_substr, NULL},
{"quotemeta", php3_quotemeta, NULL},
Index: php3/functions/file.c
diff -c php3/functions/file.c:1.186 php3/functions/file.c:1.187
*** php3/functions/file.c:1.186 Thu Dec 3 17:58:50 1998
--- php3/functions/file.c Mon Dec 7 10:40:42 1998
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: file.c,v 1.186 1998/12/03 22:58:50 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: file.c,v 1.187 1998/12/07 15:40:42 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 209,221 ****
"PHP_file", php3_file_functions, php3_minit_file, NULL, NULL, NULL, NULL,
STANDARD_MODULE_PROPERTIES
};
- /* get_meta_tags(string filename);
- extracts all meta tags from a file and returns an array
- The meta tag must have a name and content attribute, otherwise it will be skipped.
- The function stops parsing at the closing head tag.
- */
/* {{{ proto array get_meta_tags(string filename [, int use_include_path])
! Extracts all meta tags from a file and returns an array */
void php3_get_meta_tags(INTERNAL_FUNCTION_PARAMETERS) {
pval *filename, *arg2;
FILE *fp;
--- 209,216 ----
"PHP_file", php3_file_functions, php3_minit_file, NULL, NULL, NULL, NULL,
STANDARD_MODULE_PROPERTIES
};
/* {{{ proto array get_meta_tags(string filename [, int use_include_path])
! Extracts all meta tag content attributes from a file and returns an array */
void php3_get_meta_tags(INTERNAL_FUNCTION_PARAMETERS) {
pval *filename, *arg2;
FILE *fp;
***************
*** 269,280 ****
/* Now loop through the file and do the magic quotes thing if needed */
memset(buf,0,8191);
while((issock?SOCK_FGETS(buf,8191,socketd):(int)fgets(buf,8191,fp))
! && !strstr(buf,"</head>") &&
!strstr(buf,"</HEAD>")) {
! if(strstr(buf,"<meta")||strstr(buf,"<META")) {
memset(var_name,0,50);
/* get the variable name from the name attribute of the meta tag */
! tmp=strstr(buf,"name=\"");
if(tmp) {
tmp+=6;
end=strstr(tmp,"\"");
--- 264,275 ----
/* Now loop through the file and do the magic quotes thing if needed */
memset(buf,0,8191);
while((issock?SOCK_FGETS(buf,8191,socketd):(int)fgets(buf,8191,fp))
! && !php3i_stristr(buf,"</head>")) {
! if(php3i_stristr(buf,"<meta")) {
memset(var_name,0,50);
/* get the variable name from the name attribute of the meta tag */
! tmp=php3i_stristr(buf,"name=\"");
if(tmp) {
tmp+=6;
end=strstr(tmp,"\"");
***************
*** 309,315 ****
}
/* get the variable value from the content attribute of the meta tag */
! tmp=strstr(buf,"content=\"");
if(tmp) {
tmp+=9;
end=strstr(tmp,"\"");
--- 304,310 ----
}
/* get the variable value from the content attribute of the meta tag */
! tmp=php3i_stristr(buf,"content=\"");
if(tmp) {
tmp+=9;
end=strstr(tmp,"\"");
Index: php3/functions/php3_string.h
diff -c php3/functions/php3_string.h:1.22 php3/functions/php3_string.h:1.23
*** php3/functions/php3_string.h:1.22 Tue Aug 4 09:32:10 1998
--- php3/functions/php3_string.h Mon Dec 7 10:40:44 1998
***************
*** 29,35 ****
*/
! /* $Id: php3_string.h,v 1.22 1998/08/04 13:32:10 rasmus Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
--- 29,35 ----
*/
! /* $Id: php3_string.h,v 1.23 1998/12/07 15:40:44 shane Exp $ */
#ifndef _PHPSTRING_H
#define _PHPSTRING_H
***************
*** 75,80 ****
--- 75,81 ----
extern void php3_ord(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_newline_to_br(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_setlocale(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_stristr(INTERNAL_FUNCTION_PARAMETERS);
#if HAVE_CRYPT
extern php3_module_entry crypt_module_entry;
***************
*** 90,94 ****
--- 91,96 ----
extern PHPAPI char *_php3_addslashes(char *string, int length, int *new_length, int freeit);
extern PHPAPI void _php3_stripslashes(char *string, int *len);
extern PHPAPI void _php3_dirname(char *str, int len);
+ extern PHPAPI char *php3i_stristr(unsigned char *s, unsigned char *t);
#endif /* _PHPSTRING_H */
Index: php3/functions/string.c
diff -c php3/functions/string.c:1.147 php3/functions/string.c:1.148
*** php3/functions/string.c:1.147 Wed Nov 18 16:23:11 1998
--- php3/functions/string.c Mon Dec 7 10:40:44 1998
***************
*** 30,36 ****
*/
! /* $Id: string.c,v 1.147 1998/11/18 21:23:11 ssb Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 30,36 ----
*/
! /* $Id: string.c,v 1.148 1998/12/07 15:40:44 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 519,524 ****
--- 519,569 ----
_php3_dirname(ret,str->value.str.len);
RETVAL_STRING(ret,1);
efree(ret);
+ }
+ /* }}} */
+
+
+ /* case-insensitve strstr */
+ PHPAPI char *php3i_stristr(unsigned char *s, unsigned char *t)
+ {
+ int i, j, k, l;
+
+ for (i = 0; s[i]; i++) {
+ for (j = 0, l = k = i; s[k] && t[j] &&
+ tolower(s[k]) == tolower(t[j]); j++, k++)
+ ;
+ if (t[j] == '\0')
+ return s + l;
+ }
+ return NULL;
+ }
+
+ /* {{{ proto string strstr(string haystack, string needle)
+ Find first occurrence of a string within another, case insensitive */
+ void php3_stristr(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *haystack, *needle;
+ char *found = NULL;
+ TLS_VARS;
+
+ if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &haystack, &needle) ==
+ FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_string(haystack);
+ convert_to_string(needle);
+
+ if (strlen(needle->value.str.val)==0) {
+ php3_error(E_WARNING,"Empty delimiter");
+ RETURN_FALSE;
+ }
+ found = php3i_stristr(haystack->value.str.val, needle->value.str.val);
+
+ if (found) {
+ RETVAL_STRING(found,1);
+ } else {
+ RETVAL_FALSE;
+ }
}
/* }}} */
--
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