[njs] Style and small miscellaneous fixes.
Igor Sysoev
igor at sysoev.ru
Thu Mar 24 15:16:56 UTC 2016
details: http://hg.nginx.org/njs/rev/5995bd7637ff
branches:
changeset: 85:5995bd7637ff
user: Igor Sysoev <igor at sysoev.ru>
date: Wed Mar 23 15:27:10 2016 +0300
description:
Style and small miscellaneous fixes.
diffstat:
njs/njs_string.c | 6 ++++++
njs/njs_string.h | 2 +-
njs/njs_vm.c | 1 -
njs/njs_vm.h | 5 ++++-
njs/test/njs_unit_test.c | 15 +++++++++++++++
nxt/test/lvlhsh_unit_test.c | 10 +++++-----
nxt/test/rbtree_unit_test.c | 6 +++---
nxt/test/utf8_unit_test.c | 10 +++++-----
8 files changed, 39 insertions(+), 16 deletions(-)
diffs (196 lines):
diff -r 4deb6b538b48 -r 5995bd7637ff njs/njs_string.c
--- a/njs/njs_string.c Wed Mar 23 12:10:44 2016 +0300
+++ b/njs/njs_string.c Wed Mar 23 15:27:10 2016 +0300
@@ -547,6 +547,7 @@ njs_string_prototype_concat(njs_vm_t *vm
/*
* String.fromUTF8(start[, end]).
+ * The method converts an UTF-8 encoded byte string to an Unicode string.
*/
static njs_ret_t
@@ -599,6 +600,7 @@ njs_string_prototype_from_utf8(njs_vm_t
/*
* String.toUTF8(start[, end]).
+ * The method serializes Unicode string to an UTF-8 encoded byte string.
*/
static njs_ret_t
@@ -621,6 +623,7 @@ njs_string_prototype_to_utf8(njs_vm_t *v
/*
* String.fromBytes(start[, end]).
+ * The method converts a byte string to an Unicode string.
*/
static njs_ret_t
@@ -676,6 +679,9 @@ njs_string_prototype_from_bytes(njs_vm_t
/*
* String.toBytes(start[, end]).
+ * The method serializes an Unicode string to a byte string.
+ * The method returns null if a character larger than 255 is
+ * encountered in the Unicode string.
*/
static njs_ret_t
diff -r 4deb6b538b48 -r 5995bd7637ff njs/njs_string.h
--- a/njs/njs_string.h Wed Mar 23 12:10:44 2016 +0300
+++ b/njs/njs_string.h Wed Mar 23 15:27:10 2016 +0300
@@ -55,7 +55,7 @@
* 3) if the length is less than NJS_STRING_MAP_OFFSET.
*
* The current implementation does not support Unicode surrogate pairs.
- * If offset in map points to surrogate pair, it the previous offset
+ * If offset in map points to surrogate pair then the previous offset
* should be used and so on until start of the string.
*/
diff -r 4deb6b538b48 -r 5995bd7637ff njs/njs_vm.c
--- a/njs/njs_vm.c Wed Mar 23 12:10:44 2016 +0300
+++ b/njs/njs_vm.c Wed Mar 23 15:27:10 2016 +0300
@@ -133,7 +133,6 @@ const njs_value_t njs_string_nan =
const njs_value_t njs_string_string = njs_string("string");
const njs_value_t njs_string_object = njs_string("object");
const njs_value_t njs_string_function = njs_string("function");
-const njs_value_t njs_string_native = njs_string("[native code]");
const njs_value_t njs_exception_syntax_error = njs_string("SyntaxError");
const njs_value_t njs_exception_reference_error = njs_string("ReferenceError");
diff -r 4deb6b538b48 -r 5995bd7637ff njs/njs_vm.h
--- a/njs/njs_vm.h Wed Mar 23 12:10:44 2016 +0300
+++ b/njs/njs_vm.h Wed Mar 23 15:27:10 2016 +0300
@@ -41,7 +41,10 @@
#define NJS_APPLIED NXT_DONE
-/* The order of the enum is used in njs_vmcode_typeof() */
+/*
+ * The order of the enum is used in njs_vmcode_typeof()
+ * and njs_object_prototype_to_string().
+ */
typedef enum {
NJS_NULL = 0x00,
diff -r 4deb6b538b48 -r 5995bd7637ff njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed Mar 23 12:10:44 2016 +0300
+++ b/njs/test/njs_unit_test.c Wed Mar 23 15:27:10 2016 +0300
@@ -404,6 +404,15 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("'3' -+-+-+ '1' + '1' / '3' * '6' + '2'"),
nxt_string("42") },
+ { nxt_string("((+!![])+(+!![])+(+!![])+(+!![])+[])+((+!![])+(+!![])+[])"),
+ nxt_string("42") },
+
+ { nxt_string("1+[[]+[]]-[]+[[]-[]]-1"),
+ nxt_string("9") },
+
+ { nxt_string("[[]+[]]-[]+[[]-[]]"),
+ nxt_string("00") },
+
{ nxt_string("'true' == true"),
nxt_string("false") },
@@ -3796,6 +3805,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("Function.constructor === Function"),
nxt_string("true") },
+ { nxt_string("function f() {} f.__proto__ === Function.prototype"),
+ nxt_string("true") },
+
{ nxt_string("RegExp()"),
nxt_string("/(?:)/") },
@@ -3823,6 +3835,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("RegExp.constructor === Function"),
nxt_string("true") },
+ { nxt_string("/./.__proto__ === RegExp.prototype"),
+ nxt_string("true") },
+
{ nxt_string("Object.prototype.toString.call()"),
nxt_string("[object Undefined]") },
diff -r 4deb6b538b48 -r 5995bd7637ff nxt/test/lvlhsh_unit_test.c
--- a/nxt/test/lvlhsh_unit_test.c Wed Mar 23 12:10:44 2016 +0300
+++ b/nxt/test/lvlhsh_unit_test.c Wed Mar 23 15:27:10 2016 +0300
@@ -193,16 +193,16 @@ static const nxt_mem_proto_t mem_cache_
static nxt_int_t
lvlhsh_unit_test(nxt_uint_t n)
{
- uintptr_t key;
+ uintptr_t key;
nxt_uint_t i;
nxt_lvlhsh_t lh;
nxt_lvlhsh_each_t lhe;
nxt_mem_cache_pool_t *pool;
- const size_t min_chunk_size = 32;
- const size_t page_size = 1024;
- const size_t page_alignment = 128;
- const size_t cluster_size = 4096;
+ const size_t min_chunk_size = 32;
+ const size_t page_size = 1024;
+ const size_t page_alignment = 128;
+ const size_t cluster_size = 4096;
pool = nxt_mem_cache_pool_create(&mem_cache_pool_proto, NULL, NULL,
cluster_size, page_alignment,
diff -r 4deb6b538b48 -r 5995bd7637ff nxt/test/rbtree_unit_test.c
--- a/nxt/test/rbtree_unit_test.c Wed Mar 23 12:10:44 2016 +0300
+++ b/nxt/test/rbtree_unit_test.c Wed Mar 23 15:27:10 2016 +0300
@@ -16,7 +16,7 @@
typedef struct {
NXT_RBTREE_NODE (node);
- uint32_t key;
+ uint32_t key;
} nxt_rbtree_test_t;
@@ -30,8 +30,8 @@ static int nxt_cdecl rbtree_unit_test_so
static nxt_int_t
rbtree_unit_test(nxt_uint_t n)
{
- void *mark;
- uint32_t key, *keys;
+ void *mark;
+ uint32_t key, *keys;
nxt_uint_t i;
nxt_rbtree_t tree;
nxt_rbtree_node_t *node;
diff -r 4deb6b538b48 -r 5995bd7637ff nxt/test/utf8_unit_test.c
--- a/nxt/test/utf8_unit_test.c Wed Mar 23 12:10:44 2016 +0300
+++ b/nxt/test/utf8_unit_test.c Wed Mar 23 15:27:10 2016 +0300
@@ -49,7 +49,7 @@ utf8_overlong(u_char *overlong, size_t l
u_char *p, utf8[4];
size_t size;
uint32_t u, d;
- nxt_uint_t i;
+ nxt_uint_t i;
const u_char *pp;
pp = overlong;
@@ -88,7 +88,7 @@ utf8_unit_test(void)
size_t len;
int32_t n;
uint32_t u, d;
- nxt_uint_t i, k, l, m;
+ nxt_uint_t i, k, l, m;
const u_char *pp;
printf("utf8 unit test started\n");
@@ -175,9 +175,9 @@ utf8_unit_test(void)
}
n = nxt_utf8_casecmp((u_char *) "ABC АБВ ΑΒΓ",
- (u_char *) "abc абв αβγ",
- sizeof("ABC АБВ ΑΒΓ") - 1,
- sizeof("abc абв αβγ") - 1);
+ (u_char *) "abc абв αβγ",
+ sizeof("ABC АБВ ΑΒΓ") - 1,
+ sizeof("abc абв αβγ") - 1);
if (n != 0) {
printf("nxt_utf8_casecmp() failed\n");
More information about the nginx-devel
mailing list