[njs] Added njs_vm_string_compare().

Dmitry Volyntsev xeioex at nginx.com
Thu Dec 8 02:13:59 UTC 2022


details:   https://hg.nginx.org/njs/rev/23607989a28b
branches:  
changeset: 2013:23607989a28b
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Dec 07 18:11:57 2022 -0800
description:
Added njs_vm_string_compare().

diffstat:

 src/njs.h        |  2 ++
 src/njs_string.c |  3 +++
 src/njs_vm.c     |  7 +++++++
 3 files changed, 12 insertions(+), 0 deletions(-)

diffs (42 lines):

diff -r 61357fb10f4a -r 23607989a28b src/njs.h
--- a/src/njs.h	Wed Dec 07 18:11:56 2022 -0800
+++ b/src/njs.h	Wed Dec 07 18:11:57 2022 -0800
@@ -411,6 +411,8 @@ NJS_EXPORT u_char *njs_vm_value_string_a
     uint32_t size);
 NJS_EXPORT njs_int_t njs_vm_value_string_copy(njs_vm_t *vm, njs_str_t *retval,
     njs_value_t *value, uintptr_t *next);
+NJS_EXPORT njs_int_t njs_vm_string_compare(const njs_value_t *v1,
+    const njs_value_t *v2);
 
 NJS_EXPORT njs_int_t njs_vm_value_array_buffer_set(njs_vm_t *vm,
     njs_value_t *value, const u_char *start, uint32_t size);
diff -r 61357fb10f4a -r 23607989a28b src/njs_string.c
--- a/src/njs_string.c	Wed Dec 07 18:11:56 2022 -0800
+++ b/src/njs_string.c	Wed Dec 07 18:11:57 2022 -0800
@@ -728,6 +728,9 @@ njs_string_cmp(const njs_value_t *v1, co
     njs_int_t     ret;
     const u_char  *start1, *start2;
 
+    njs_assert(njs_is_string(v1));
+    njs_assert(njs_is_string(v2));
+
     size1 = v1->short_string.size;
 
     if (size1 != NJS_STRING_LONG) {
diff -r 61357fb10f4a -r 23607989a28b src/njs_vm.c
--- a/src/njs_vm.c	Wed Dec 07 18:11:56 2022 -0800
+++ b/src/njs_vm.c	Wed Dec 07 18:11:57 2022 -0800
@@ -1308,6 +1308,13 @@ njs_vm_value_to_bytes(njs_vm_t *vm, njs_
 
 
 njs_int_t
+njs_vm_string_compare(const njs_value_t *v1, const njs_value_t *v2)
+{
+    return njs_string_cmp(v1, v2);
+}
+
+
+njs_int_t
 njs_vm_value_string_copy(njs_vm_t *vm, njs_str_t *retval,
     njs_value_t *value, uintptr_t *next)
 {



More information about the nginx-devel mailing list