]> git.kaiwu.me - njs.git/commitdiff
Style and small miscellaneous fixes.
authorIgor Sysoev <igor@sysoev.ru>
Wed, 9 Nov 2016 12:04:40 +0000 (15:04 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 9 Nov 2016 12:04:40 +0000 (15:04 +0300)
njs/njs_disassembler.c
njs/njs_string.c
njs/njs_vm.c
njs/njs_vm.h
njs/test/njs_unit_test.c
nxt/nxt_rbtree.c
nxt/nxt_utf8.h
nxt/test/random_unit_test.c

index ab2d25fe5319be9e66bf1c03fc180dd7610ae9f8..a8e9405e9d0f8d2b25b2b02921a1f7f14ede92d4 100644 (file)
@@ -151,7 +151,7 @@ njs_disassembler(njs_vm_t *vm)
     code = vm->code->start;
     n = vm->code->items;
 
-    while(n != 0) {
+    while (n != 0) {
         njs_disassemble(code->start, code->end);
         code++;
         n--;
index 9ca720241e8eac3c6c1189145d48e22f865034ea..96095b5235da62a5a0738d828c33d1451c32eebf 100644 (file)
@@ -607,7 +607,6 @@ njs_string_prototype_concat(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
     }
 
     for (i = 0; i < nargs; i++) {
-
         if (!njs_is_string(&args[i])) {
             vm->frame->trap_scratch.data.u.value = &args[i];
 
@@ -3210,7 +3209,7 @@ static const njs_object_prop_t  njs_string_prototype_properties[] =
         .type = NJS_METHOD,
         .name = njs_string("match"),
         .value = njs_native_function(njs_string_prototype_match, 0,
-                     NJS_STRING_ARG, NJS_REGEXP_ARG),
+                     NJS_STRING_OBJECT_ARG, NJS_REGEXP_ARG),
     },
 
     {
index d62f925aefb3328072a6953e7e2ca1d532c0f066..bc3589e274d407205465ee10adca0084c7cf2804 100644 (file)
@@ -79,10 +79,10 @@ static njs_ret_t njs_object_property_query(njs_vm_t *vm,
 static njs_ret_t njs_method_private_copy(njs_vm_t *vm,
     njs_property_query_t *pq);
 static nxt_noinline uint32_t njs_integer_value(double num);
-static nxt_noinline njs_ret_t njs_values_equal(njs_value_t *val1,
-    njs_value_t *val2);
-static nxt_noinline njs_ret_t njs_values_compare(njs_value_t *val1,
-    njs_value_t *val2);
+static nxt_noinline njs_ret_t njs_values_equal(const njs_value_t *val1,
+    const njs_value_t *val2);
+static nxt_noinline njs_ret_t njs_values_compare(const njs_value_t *val1,
+    const njs_value_t *val2);
 static njs_object_t *njs_function_new_object(njs_vm_t *vm, njs_value_t *value);
 static njs_ret_t njs_vmcode_method_call(njs_vm_t *vm, njs_value_t *object,
     njs_value_t *value);
@@ -1879,7 +1879,7 @@ njs_vmcode_not_equal(njs_vm_t *vm, njs_value_t *val1, njs_value_t *val2)
 
 
 static nxt_noinline njs_ret_t
-njs_values_equal(njs_value_t *val1, njs_value_t *val2)
+njs_values_equal(const njs_value_t *val1, const njs_value_t *val2)
 {
     /* Void and null are equal and not comparable with anything else. */
     if (njs_is_null_or_void(val1)) {
@@ -1967,7 +1967,7 @@ njs_vmcode_greater_or_equal(njs_vm_t *vm, njs_value_t *val1, njs_value_t *val2)
  */
 
 static nxt_noinline njs_ret_t
-njs_values_compare(njs_value_t *val1, njs_value_t *val2)
+njs_values_compare(const njs_value_t *val1, const njs_value_t *val2)
 {
     if (nxt_fast_path(njs_is_numeric(val1) || njs_is_numeric(val2))) {
 
@@ -2030,7 +2030,7 @@ njs_vmcode_strict_not_equal(njs_vm_t *vm, njs_value_t *val1, njs_value_t *val2)
 
 
 nxt_noinline nxt_bool_t
-njs_values_strict_equal(njs_value_t *val1, njs_value_t *val2)
+njs_values_strict_equal(const njs_value_t *val1, const njs_value_t *val2)
 {
     size_t        size;
     const u_char  *start1, *start2;
index ab8ec7ca7bd26174a165f0dc81bca3bee3ca45fb..82081725f9494c4b242c025f94799eefa8cd0d7c 100644 (file)
@@ -1007,7 +1007,8 @@ njs_ret_t njs_vmcode_catch(njs_vm_t *vm, njs_value_t *invld,
 njs_ret_t njs_vmcode_finally(njs_vm_t *vm, njs_value_t *invld,
     njs_value_t *retval);
 
-nxt_bool_t njs_values_strict_equal(njs_value_t *val1, njs_value_t *val2);
+nxt_bool_t njs_values_strict_equal(const njs_value_t *val1,
+    const njs_value_t *val2);
 
 njs_ret_t njs_normalize_args(njs_vm_t *vm, njs_value_t *args,
     uint8_t *args_types, nxt_uint_t nargs);
index e84cf46b874dfbef9c182a519c8e08efc4f613fb..ce16271875c0ee0d59c73db5a780413e4918deca 100644 (file)
@@ -6218,10 +6218,11 @@ main(int argc, char **argv)
         "fibo(32).length");
 
     static nxt_str_t  fibo_bytes = nxt_string(
+        "var a = '\\x80'.toBytes();"
         "function fibo(n) {"
         "    if (n > 1)"
         "        return fibo(n - 1) + fibo(n - 2)"
-        "    return '\\x80'.toBytes()"
+        "    return a"
         "}"
         "fibo(32).length");
 
index 042576e2e6313948772bb69318f455ecf63d24d1..24cb4e6f65b29f6a7d4f81ca2533ca0c4482d33d 100644 (file)
@@ -17,7 +17,8 @@
 
 
 static void nxt_rbtree_insert_fixup(nxt_rbtree_node_t *node);
-static void nxt_rbtree_delete_fixup(nxt_rbtree_t *tree, nxt_rbtree_node_t *node);
+static void nxt_rbtree_delete_fixup(nxt_rbtree_t *tree,
+    nxt_rbtree_node_t *node);
 nxt_inline void nxt_rbtree_left_rotate(nxt_rbtree_node_t *node);
 nxt_inline void nxt_rbtree_right_rotate(nxt_rbtree_node_t *node);
 nxt_inline void nxt_rbtree_parent_relink(nxt_rbtree_node_t *subst,
@@ -28,13 +29,7 @@ nxt_inline void nxt_rbtree_parent_relink(nxt_rbtree_node_t *subst,
 #define NXT_RBTREE_RED    1
 
 
-#define nxt_rbtree_set_callback_type(tree, type)                               \
-    (tree)->sentinel.spare = type
-
-#define nxt_rbtree_has_insertion_callback(tree)                                \
-    ((tree)->sentinel.spare != 0)
-
-#define nxt_rbtree_comparison_callback(tree)                                   \
+#define nxt_rbtree_comparison_callback(tree)                                  \
     ((nxt_rbtree_compare_t) (tree)->sentinel.right)
 
 
index 4a744ed5e5ff9ae464c33c5751f89125cab09cfd..b6305bfce656014ad428e55c5ba63c606d058cd7 100644 (file)
@@ -76,7 +76,6 @@ nxt_utf8_prev(const u_char *p)
 }
 
 
-
 #define nxt_utf8_size(u)                                                      \
     ((u < 0x80) ? 1 : ((u < 0x0800) ? 2 : ((u < 0x10000) ? 3 : 4)))
 
index fce247a292b55393c10658b656db0bd84296865f..13836a6b71e39787584d5cc6e169bf6ec98ff937 100644 (file)
@@ -15,7 +15,7 @@
 
 
 static nxt_int_t
-random_unit_test()
+random_unit_test(void)
 {
     nxt_uint_t    n;
     nxt_random_t  r;