]> granicus.if.org Git - php/commitdiff
fixed shift_jis character corruption including 0x5c as second byte.
authorRui Hirokawa <hirokawa@php.net>
Tue, 2 Jul 2002 15:26:25 +0000 (15:26 +0000)
committerRui Hirokawa <hirokawa@php.net>
Tue, 2 Jul 2002 15:26:25 +0000 (15:26 +0000)
ext/mbstring/mbstring.c

index bc8175fc21c3866772edce7f26c68a7fcb2a7965..9d9a5cf3b4f5634289b40d73bd68e52b585a7f81 100644 (file)
@@ -1142,6 +1142,28 @@ SAPI_POST_HANDLER_FUNC(php_mbstr_post_handler)
 }
 #endif
 
+#define IS_SJIS1(c) ((((c)>=0x81 && (c)<=0x9f) || ((c)>=0xe0 && (c)<=0xf5)) ? 1 : 0)
+#define IS_SJIS2(c) ((((c)>=0x40 && (c)<=0x7e) || ((c)>=0x80 && (c)<=0xfc)) ? 1 : 0)
+
+char *mbstr_strrchr(const char *s, char c){
+       unsigned char *p = (unsigned char *)s, *last = NULL;
+       while(*p++) {
+               if (*p == c) {
+                       last = p;
+               }
+               if (*p == '\0'){
+                       break;
+               }
+               if (IS_SJIS1(*p) && IS_SJIS2(*(p+1))) {
+                       p++;
+               }
+       }
+       return last;
+}
+
+
+
+
 /* http input processing */
 void mbstr_treat_data(int arg, char *str, zval* destArray TSRMLS_DC)
 {