[njs] Adding const qualifiers to njs_string_prototype_split() and friends.
Dmitry Volyntsev
xeioex at nginx.com
Fri Feb 15 15:51:42 UTC 2019
details: https://hg.nginx.org/njs/rev/e1bfc7be7c55
branches:
changeset: 780:e1bfc7be7c55
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Thu Feb 14 21:19:51 2019 +0300
description:
Adding const qualifiers to njs_string_prototype_split() and friends.
diffstat:
njs/njs.h | 2 +-
njs/njs_array.c | 2 +-
njs/njs_array.h | 4 ++--
njs/njs_regexp.c | 4 ++--
njs/njs_regexp.h | 4 ++--
njs/njs_string.c | 14 +++++++-------
njs/njs_string.h | 2 +-
nxt/nxt_pcre.c | 6 +++---
nxt/nxt_regex.h | 2 +-
9 files changed, 20 insertions(+), 20 deletions(-)
diffs (168 lines):
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs.h
--- a/njs/njs.h Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs.h Thu Feb 14 21:19:51 2019 +0300
@@ -232,7 +232,7 @@ NXT_EXPORT void njs_vm_retval_set(njs_vm
NXT_EXPORT u_char * njs_string_alloc(njs_vm_t *vm, njs_value_t *value,
uint32_t size, uint32_t length);
NXT_EXPORT njs_ret_t njs_string_create(njs_vm_t *vm, njs_value_t *value,
- u_char *start, uint32_t size, uint32_t length);
+ const u_char *start, uint32_t size, uint32_t length);
NXT_EXPORT nxt_int_t njs_value_string_copy(njs_vm_t *vm, nxt_str_t *retval,
const njs_value_t *value, uintptr_t *next);
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs_array.c
--- a/njs/njs_array.c Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs_array.c Thu Feb 14 21:19:51 2019 +0300
@@ -184,7 +184,7 @@ njs_array_add(njs_vm_t *vm, njs_array_t
njs_ret_t
-njs_array_string_add(njs_vm_t *vm, njs_array_t *array, u_char *start,
+njs_array_string_add(njs_vm_t *vm, njs_array_t *array, const u_char *start,
size_t size, size_t length)
{
njs_ret_t ret;
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs_array.h
--- a/njs/njs_array.h Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs_array.h Thu Feb 14 21:19:51 2019 +0300
@@ -17,8 +17,8 @@
njs_array_t *njs_array_alloc(njs_vm_t *vm, uint32_t length, uint32_t spare);
njs_ret_t njs_array_add(njs_vm_t *vm, njs_array_t *array, njs_value_t *value);
-njs_ret_t njs_array_string_add(njs_vm_t *vm, njs_array_t *array, u_char *start,
- size_t size, size_t length);
+njs_ret_t njs_array_string_add(njs_vm_t *vm, njs_array_t *array,
+ const u_char *start, size_t size, size_t length);
njs_ret_t njs_array_expand(njs_vm_t *vm, njs_array_t *array, uint32_t prepend,
uint32_t size);
njs_ret_t njs_array_constructor(njs_vm_t *vm, njs_value_t *args,
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs_regexp.c
--- a/njs/njs_regexp.c Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs_regexp.c Thu Feb 14 21:19:51 2019 +0300
@@ -389,8 +389,8 @@ njs_regexp_compile_trace_handler(nxt_tra
nxt_int_t
-njs_regexp_match(njs_vm_t *vm, nxt_regex_t *regex, u_char *subject, size_t len,
- nxt_regex_match_data_t *match_data)
+njs_regexp_match(njs_vm_t *vm, nxt_regex_t *regex, const u_char *subject,
+ size_t len, nxt_regex_match_data_t *match_data)
{
nxt_int_t ret;
nxt_trace_handler_t handler;
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs_regexp.h
--- a/njs/njs_regexp.h Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs_regexp.h Thu Feb 14 21:19:51 2019 +0300
@@ -25,8 +25,8 @@ njs_token_t njs_regexp_literal(njs_vm_t
njs_value_t *value);
njs_regexp_pattern_t *njs_regexp_pattern_create(njs_vm_t *vm,
u_char *string, size_t length, njs_regexp_flags_t flags);
-nxt_int_t njs_regexp_match(njs_vm_t *vm, nxt_regex_t *regex, u_char *subject,
- size_t len, nxt_regex_match_data_t *match_data);
+nxt_int_t njs_regexp_match(njs_vm_t *vm, nxt_regex_t *regex,
+ const u_char *subject, size_t len, nxt_regex_match_data_t *match_data);
njs_regexp_t *njs_regexp_alloc(njs_vm_t *vm, njs_regexp_pattern_t *pattern);
njs_ret_t njs_regexp_prototype_exec(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused);
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs_string.c
--- a/njs/njs_string.c Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs_string.c Thu Feb 14 21:19:51 2019 +0300
@@ -77,7 +77,7 @@ static njs_ret_t njs_string_prototype_pa
static njs_ret_t njs_string_match_multiple(njs_vm_t *vm, njs_value_t *args,
njs_regexp_pattern_t *pattern);
static njs_ret_t njs_string_split_part_add(njs_vm_t *vm, njs_array_t *array,
- njs_utf8_t utf8, u_char *start, size_t size);
+ njs_utf8_t utf8, const u_char *start, size_t size);
static njs_ret_t njs_string_replace_regexp(njs_vm_t *vm, njs_value_t *args,
njs_string_replace_t *r);
static njs_ret_t njs_string_replace_regexp_function(njs_vm_t *vm,
@@ -111,10 +111,11 @@ static njs_ret_t njs_string_decode(njs_v
njs_ret_t
-njs_string_create(njs_vm_t *vm, njs_value_t *value, u_char *start,
+njs_string_create(njs_vm_t *vm, njs_value_t *value, const u_char *start,
uint32_t size, uint32_t length)
{
- u_char *dst, *src;
+ u_char *dst;
+ const u_char *src;
njs_string_t *string;
value->type = NJS_STRING;
@@ -153,7 +154,7 @@ njs_string_create(njs_vm_t *vm, njs_valu
value->long_string.data = string;
- string->start = start;
+ string->start = (u_char *) start;
string->length = length;
string->retain = 1;
}
@@ -2729,12 +2730,11 @@ njs_string_prototype_split(njs_vm_t *vm,
njs_index_t unused)
{
int ret, *captures;
- u_char *p, *start, *next;
size_t size;
uint32_t limit;
njs_utf8_t utf8;
njs_array_t *array;
- const u_char *end;
+ const u_char *p, *start, *next, *end;
njs_regexp_utf8_t type;
njs_string_prop_t string, split;
njs_regexp_pattern_t *pattern;
@@ -2887,7 +2887,7 @@ done:
static njs_ret_t
njs_string_split_part_add(njs_vm_t *vm, njs_array_t *array, njs_utf8_t utf8,
- u_char *start, size_t size)
+ const u_char *start, size_t size)
{
ssize_t length;
diff -r dde9a253361e -r e1bfc7be7c55 njs/njs_string.h
--- a/njs/njs_string.h Thu Feb 14 17:01:26 2019 +0300
+++ b/njs/njs_string.h Thu Feb 14 21:19:51 2019 +0300
@@ -100,7 +100,7 @@ typedef enum {
nxt_inline uint32_t
-njs_string_length(njs_utf8_t utf8, u_char *start, size_t size)
+njs_string_length(njs_utf8_t utf8, const u_char *start, size_t size)
{
ssize_t length;
diff -r dde9a253361e -r e1bfc7be7c55 nxt/nxt_pcre.c
--- a/nxt/nxt_pcre.c Thu Feb 14 17:01:26 2019 +0300
+++ b/nxt/nxt_pcre.c Thu Feb 14 21:19:51 2019 +0300
@@ -209,13 +209,13 @@ nxt_pcre_default_free(void *p, void *mem
nxt_int_t
-nxt_regex_match(nxt_regex_t *regex, u_char *subject, size_t len,
+nxt_regex_match(nxt_regex_t *regex, const u_char *subject, size_t len,
nxt_regex_match_data_t *match_data, nxt_regex_context_t *ctx)
{
int ret;
- ret = pcre_exec(regex->code, regex->extra, (char *) subject, len, 0, 0,
- match_data->captures, match_data->ncaptures);
+ ret = pcre_exec(regex->code, regex->extra, (const char *) subject, len,
+ 0, 0, match_data->captures, match_data->ncaptures);
/* PCRE_ERROR_NOMATCH is -1. */
diff -r dde9a253361e -r e1bfc7be7c55 nxt/nxt_regex.h
--- a/nxt/nxt_regex.h Thu Feb 14 17:01:26 2019 +0300
+++ b/nxt/nxt_regex.h Thu Feb 14 21:19:51 2019 +0300
@@ -35,7 +35,7 @@ NXT_EXPORT nxt_regex_match_data_t *nxt_r
nxt_regex_context_t *ctx);
NXT_EXPORT void nxt_regex_match_data_free(nxt_regex_match_data_t *match_data,
nxt_regex_context_t *ctx);
-NXT_EXPORT nxt_int_t nxt_regex_match(nxt_regex_t *regex, u_char *subject,
+NXT_EXPORT nxt_int_t nxt_regex_match(nxt_regex_t *regex, const u_char *subject,
size_t len, nxt_regex_match_data_t *match_data, nxt_regex_context_t *ctx);
NXT_EXPORT int *nxt_regex_captures(nxt_regex_match_data_t *match_data);
More information about the nginx-devel
mailing list