[PHP-DEV] CVS update: php31/ext/standard From: rasmus (php-dev <email protected>)
Date: 05/31/98

Date: Sunday May 31, 1998 @ 17:48
Author: rasmus

Update of /repository/php31/ext/standard
In directory asf:/tmp/cvs-serv328/ext/standard

Modified Files:
        basic_functions.c php3_string.h string.c
Log Message:
Add strrpos function to complement strpos function

Index: php31/ext/standard/basic_functions.c
diff -c php31/ext/standard/basic_functions.c:1.11 php31/ext/standard/basic_functions.c:1.12
*** php31/ext/standard/basic_functions.c:1.11 Sun May 31 17:32:57 1998
--- php31/ext/standard/basic_functions.c Sun May 31 17:48:18 1998
***************
*** 150,155 ****
--- 150,156 ----
          {"strtolower", php3_strtolower, NULL},
          {"strchr", php3_strstr, NULL},
          {"strpos", php3_strpos, NULL},
+ {"strrpos", php3_strrpos, NULL},
          {"strrev", php3_strrev, NULL},
          {"hebrev", php3_hebrev, NULL},
          {"hebrevc", php3_hebrev_with_conversion,NULL},
Index: php31/ext/standard/php3_string.h
diff -c php31/ext/standard/php3_string.h:1.4 php31/ext/standard/php3_string.h:1.5
*** php31/ext/standard/php3_string.h:1.4 Sun May 31 17:21:50 1998
--- php31/ext/standard/php3_string.h Sun May 31 17:48:18 1998
***************
*** 29,35 ****
   */
  
  
! /* $Id: php3_string.h,v 1.4 1998/05/31 21:21:50 rasmus Exp $ */
  
  #ifndef _PHPSTRING_H
  #define _PHPSTRING_H
--- 29,35 ----
   */
  
  
! /* $Id: php3_string.h,v 1.5 1998/05/31 21:48:18 rasmus Exp $ */
  
  #ifndef _PHPSTRING_H
  #define _PHPSTRING_H
***************
*** 54,59 ****
--- 54,60 ----
  extern void php3_dirname(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_strstr(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_strpos(INTERNAL_FUNCTION_PARAMETERS);
+ extern void php3_strrpos(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_strrchr(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_substr(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_quotemeta(INTERNAL_FUNCTION_PARAMETERS);
Index: php31/ext/standard/string.c
diff -c php31/ext/standard/string.c:1.6 php31/ext/standard/string.c:1.7
*** php31/ext/standard/string.c:1.6 Sun May 31 17:21:50 1998
--- php31/ext/standard/string.c Sun May 31 17:48:18 1998
***************
*** 30,36 ****
   */
  
  
! /* $Id: string.c,v 1.6 1998/05/31 21:21:50 rasmus Exp $ */
  #ifdef THREAD_SAFE
  #include "tls.h"
  #endif
--- 30,36 ----
   */
  
  
! /* $Id: string.c,v 1.7 1998/05/31 21:48:18 rasmus Exp $ */
  #ifdef THREAD_SAFE
  #include "tls.h"
  #endif
***************
*** 478,483 ****
--- 478,508 ----
          } else {
                  convert_to_long(needle);
                  found = strchr(haystack->value.str.val, (char) needle->value.lval);
+ }
+
+ if (found) {
+ RETVAL_LONG(haystack->value.str.len - strlen(found));
+ } else {
+ RETVAL_FALSE;
+ }
+ }
+
+ void php3_strrpos(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);
+
+ if (needle->type == IS_STRING) {
+ found = strrchr(haystack->value.str.val, *needle->value.str.val);
+ } else {
+ convert_to_long(needle);
+ found = strrchr(haystack->value.str.val, (char) needle->value.lval);
          }
  
          if (found) {