From: Igor Sysoev Date: Wed, 9 Nov 2016 12:04:40 +0000 (+0300) Subject: Style and small miscellaneous fixes. X-Git-Tag: 0.1.5~10 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=f84ebe0a01c1afcca2551c2fbde702e601cb2794;p=njs.git Style and small miscellaneous fixes. --- diff --git a/njs/njs_disassembler.c b/njs/njs_disassembler.c index ab2d25fe..a8e9405e 100644 --- a/njs/njs_disassembler.c +++ b/njs/njs_disassembler.c @@ -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--; diff --git a/njs/njs_string.c b/njs/njs_string.c index 9ca72024..96095b52 100644 --- a/njs/njs_string.c +++ b/njs/njs_string.c @@ -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), }, { diff --git a/njs/njs_vm.c b/njs/njs_vm.c index d62f925a..bc3589e2 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -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; diff --git a/njs/njs_vm.h b/njs/njs_vm.h index ab8ec7ca..82081725 100644 --- a/njs/njs_vm.h +++ b/njs/njs_vm.h @@ -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); diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index e84cf46b..ce162718 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -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"); diff --git a/nxt/nxt_rbtree.c b/nxt/nxt_rbtree.c index 042576e2..24cb4e6f 100644 --- a/nxt/nxt_rbtree.c +++ b/nxt/nxt_rbtree.c @@ -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) diff --git a/nxt/nxt_utf8.h b/nxt/nxt_utf8.h index 4a744ed5..b6305bfc 100644 --- a/nxt/nxt_utf8.h +++ b/nxt/nxt_utf8.h @@ -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))) diff --git a/nxt/test/random_unit_test.c b/nxt/test/random_unit_test.c index fce247a2..13836a6b 100644 --- a/nxt/test/random_unit_test.c +++ b/nxt/test/random_unit_test.c @@ -15,7 +15,7 @@ static nxt_int_t -random_unit_test() +random_unit_test(void) { nxt_uint_t n; nxt_random_t r;