From: Igor Sysoev Date: Tue, 27 Jun 2017 08:17:54 +0000 (+0300) Subject: Style fixes and small miscellaneous changes. X-Git-Tag: 0.1.11~1 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=9ebb29a9f8e7825a6f801d556d49b5ff60e4d276;p=njs.git Style fixes and small miscellaneous changes. --- diff --git a/nginx/ngx_http_js_module.c b/nginx/ngx_http_js_module.c index 668b7192..306c5f3b 100644 --- a/nginx/ngx_http_js_module.c +++ b/nginx/ngx_http_js_module.c @@ -139,7 +139,7 @@ static ngx_command_t ngx_http_js_commands[] = { { ngx_string("js_set"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE2, ngx_http_js_set, - NGX_HTTP_LOC_CONF_OFFSET, + 0, 0, NULL }, diff --git a/njs/njs_date.c b/njs/njs_date.c index be3b9a12..b1c4aa0d 100644 --- a/njs/njs_date.c +++ b/njs/njs_date.c @@ -1052,8 +1052,8 @@ njs_date_prototype_to_iso_string(njs_vm_t *vm, njs_value_t *args, year = tm.tm_year + 1900; size = snprintf((char *) buf, NJS_ISO_DATE_TIME_LEN, - (year < 0) ? "%07d-%02d-%02dT%02d:%02d:%02d.%03dZ": - "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", + (year < 0) ? "%07d-%02d-%02dT%02d:%02d:%02d.%03dZ" + : "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", year, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, (int) ((int64_t) time % 1000)); diff --git a/njs/njs_number.c b/njs/njs_number.c index aaf539dc..a4678188 100644 --- a/njs/njs_number.c +++ b/njs/njs_number.c @@ -89,7 +89,7 @@ njs_number_dec_parse(u_char **start, u_char *end) num = 0; while (p < end) { - /* Values below '0' become >= 208. */ + /* Values less than '0' become >= 208. */ c = *p - '0'; if (nxt_slow_path(c > 9)) { @@ -106,7 +106,7 @@ njs_number_dec_parse(u_char **start, u_char *end) scale = 1; for (p++; p < end; p++) { - /* Values below '0' become >= 208. */ + /* Values less than '0' become >= 208. */ c = *p - '0'; if (nxt_slow_path(c > 9)) { @@ -135,7 +135,7 @@ njs_number_dec_parse(u_char **start, u_char *end) } } - /* Values below '0' become >= 208. */ + /* Values less than '0' become >= 208. */ c = *e - '0'; if (nxt_fast_path(c <= 9)) { @@ -143,7 +143,7 @@ njs_number_dec_parse(u_char **start, u_char *end) p = e + 1; while (p < end) { - /* Values below '0' become >= 208. */ + /* Values less than '0' become >= 208. */ c = *p - '0'; if (nxt_slow_path(c > 9)) { @@ -180,11 +180,11 @@ njs_number_hex_parse(u_char **start, u_char *end) while (p < end) { c = (u_char) (*p | 0x20); - /* Values below '0' become >= 208. */ + /* Values less than '0' become >= 208. */ c = c - '0'; if (c > 9) { - /* Values below 'a' become >= 159. */ + /* Values less than 'a' become >= 159. */ c = c - ('a' - '0'); if (nxt_slow_path(c > 5)) { @@ -800,7 +800,7 @@ njs_number_parse_int(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, n = njs_number_radix_parse(&p, end, radix); if (n >= 0) { - num = (minus) ? -n : n; + num = minus ? -n : n; } } diff --git a/njs/njs_object.c b/njs/njs_object.c index e2d9d06c..d90054d9 100644 --- a/njs/njs_object.c +++ b/njs/njs_object.c @@ -915,8 +915,8 @@ njs_object_is_extensible(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, return NXT_ERROR; } - retval = args[1].data.u.object->extensible ? &njs_string_true : - &njs_string_false; + retval = args[1].data.u.object->extensible ? &njs_string_true + : &njs_string_false; vm->retval = *retval; diff --git a/njs/njs_string.c b/njs/njs_string.c index 85378194..287cba8a 100644 --- a/njs/njs_string.c +++ b/njs/njs_string.c @@ -2555,11 +2555,11 @@ static njs_ret_t njs_string_replace_search(njs_vm_t *vm, njs_value_t *args, njs_string_replace_t *r) { - int captures[2]; - u_char *p, *end; - size_t size; - njs_ret_t ret; - nxt_str_t search; + int captures[2]; + u_char *p, *end; + size_t size; + njs_ret_t ret; + nxt_str_t search; njs_string_get(&args[1], &search); @@ -2908,7 +2908,7 @@ njs_ret_t njs_primitive_value_to_string(njs_vm_t *vm, njs_value_t *dst, const njs_value_t *src) { - const njs_value_t *value; + const njs_value_t *value; switch (src->type) { @@ -2945,10 +2945,10 @@ njs_primitive_value_to_string(njs_vm_t *vm, njs_value_t *dst, double njs_string_to_number(njs_value_t *value, nxt_bool_t parse_float) { - u_char *p, *start, *end; - double num; - size_t size; - nxt_bool_t minus; + u_char *p, *start, *end; + double num; + size_t size; + nxt_bool_t minus; const size_t infinity = sizeof("Infinity") - 1; @@ -3716,8 +3716,8 @@ njs_value_index(njs_vm_t *vm, njs_parser_t *parser, const njs_value_t *src) lhq.value = value; lhq.pool = vm->mem_cache_pool; - values_hash = parser->runtime ? &vm->values_hash: - &vm->shared->values_hash; + values_hash = parser->runtime ? &vm->values_hash + : &vm->shared->values_hash; ret = nxt_lvlhsh_insert(values_hash, &lhq); diff --git a/nxt/nxt_lvlhsh.c b/nxt/nxt_lvlhsh.c index 18325b71..6794cacb 100644 --- a/nxt/nxt_lvlhsh.c +++ b/nxt/nxt_lvlhsh.c @@ -848,8 +848,8 @@ nxt_lvlhsh_bucket_each(nxt_lvlhsh_each_t *lhe) if (lhe->entries == 0) { next = *nxt_lvlhsh_next_bucket(lhe->proto, lhe->bucket); - lhe->bucket = (next == NULL) ? NXT_LVLHSH_BUCKET_DONE: - nxt_lvlhsh_bucket(lhe->proto, next); + lhe->bucket = (next == NULL) ? NXT_LVLHSH_BUCKET_DONE + : nxt_lvlhsh_bucket(lhe->proto, next); lhe->entries = nxt_lvlhsh_bucket_entries(lhe->proto, next); lhe->entry = 0; diff --git a/nxt/nxt_lvlhsh.h b/nxt/nxt_lvlhsh.h index b969928e..cf655203 100644 --- a/nxt/nxt_lvlhsh.h +++ b/nxt/nxt_lvlhsh.h @@ -93,7 +93,7 @@ typedef struct { typedef struct { - void *slot; + void *slot; } nxt_lvlhsh_t; @@ -179,15 +179,7 @@ typedef struct { (lhe)->proto = _proto; \ } while (0) -NXT_EXPORT void *nxt_lvlhsh_each(nxt_lvlhsh_t *lh, nxt_lvlhsh_each_t *le); - - -NXT_EXPORT void *nxt_lvlhsh_alloc(void *data, size_t size, nxt_uint_t nalloc); -NXT_EXPORT void nxt_lvlhsh_free(void *data, void *p, size_t size); - -NXT_EXPORT void *nxt_lvlhsh_pool_alloc(void *ctx, size_t size, - nxt_uint_t nalloc); -NXT_EXPORT void nxt_lvlhsh_pool_free(void *ctx, void *p, size_t size); +NXT_EXPORT void *nxt_lvlhsh_each(nxt_lvlhsh_t *lh, nxt_lvlhsh_each_t *lhe); #endif /* _NXT_LVLHSH_H_INCLUDED_ */ diff --git a/nxt/nxt_rbtree.c b/nxt/nxt_rbtree.c index 390464f6..90d3a55a 100644 --- a/nxt/nxt_rbtree.c +++ b/nxt/nxt_rbtree.c @@ -349,7 +349,6 @@ nxt_rbtree_delete_fixup(nxt_rbtree_t *tree, nxt_rbtree_node_t *node) * Prefetching parent nodes does not help here according * to microbenchmarks. */ - parent = node->parent; if (node == parent->left) { diff --git a/nxt/nxt_utf8.c b/nxt/nxt_utf8.c index b959c85e..d487d40a 100644 --- a/nxt/nxt_utf8.c +++ b/nxt/nxt_utf8.c @@ -35,7 +35,7 @@ nxt_utf8_encode(u_char *p, uint32_t u) if (u < 0x0800) { *p++ = (u_char) (( u >> 6) | 0xC0); - *p++ = (u_char) (( u & 0x3f) | 0x80); + *p++ = (u_char) (( u & 0x3F) | 0x80); return p; }