[njs] Now ASCII strings use UTF8 variant of PCRE code.

Igor Sysoev igor at sysoev.ru
Mon Jul 11 12:10:03 UTC 2016


details:   http://hg.nginx.org/njs/rev/6888c62477a0
branches:  
changeset: 117:6888c62477a0
user:      Igor Sysoev <igor at sysoev.ru>
date:      Fri Jul 08 18:07:57 2016 +0300
description:
Now ASCII strings use UTF8 variant of PCRE code.

diffstat:

 njs/njs_regexp.c |  5 ++++-
 njs/njs_string.c |  4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diffs (55 lines):

diff -r 73dc069a08c0 -r 6888c62477a0 njs/njs_regexp.c
--- a/njs/njs_regexp.c	Thu Jul 07 20:49:57 2016 +0300
+++ b/njs/njs_regexp.c	Fri Jul 08 18:07:57 2016 +0300
@@ -476,7 +476,7 @@ njs_regexp_prototype_test(njs_vm_t *vm, 
 
     (void) njs_string_prop(&string, value);
 
-    n = (string.length != 0 && string.length != string.size);
+    n = (string.length != 0);
 
     pattern = args[0].data.u.regexp->pattern;
 
@@ -527,14 +527,17 @@ njs_regexp_prototype_exec(njs_vm_t *vm, 
 
     (void) njs_string_prop(&string, value);
 
+    /* Byte string. */
     utf8 = 0;
     n = 0;
 
     if (string.length != 0) {
+        /* ASCII string. */
         utf8 = 1;
         n = 1;
 
         if (string.length != string.size) {
+            /* UTF-8 string. */
             utf8 = 2;
         }
     }
diff -r 73dc069a08c0 -r 6888c62477a0 njs/njs_string.c
--- a/njs/njs_string.c	Thu Jul 07 20:49:57 2016 +0300
+++ b/njs/njs_string.c	Fri Jul 08 18:07:57 2016 +0300
@@ -1450,7 +1450,7 @@ njs_string_prototype_search(njs_vm_t *vm
 
         (void) njs_string_prop(&string, &args[0]);
 
-        n = (string.length != 0 && string.length != string.size);
+        n = (string.length != 0);
 
         if (nxt_regex_is_valid(&pattern->regex[n])) {
             ret = nxt_regex_match(&pattern->regex[n], string.start, string.size,
@@ -1696,11 +1696,11 @@ njs_string_prototype_split(njs_vm_t *vm,
         if (string.length != 0) {
             /* ASCII string. */
             utf8 = 1;
-            n = 1;
 
             if (string.length != string.size) {
                 /* UTF-8 string. */
                 utf8 = 2;
+                n = 1;
             }
         }
 



More information about the nginx-devel mailing list