Make string constants const char * const (#2458)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
This commit is contained in:
1 parent
81f37cf134
commit
fb35e34801
5 files changed
+18
-18
No files matched your search
@@ -151,7 +151,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
|
|||||||
|
|
||||||
if (globals_p->snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
|
if (globals_p->snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
|
||||||
{
|
{
|
||||||
const char *error_message_p = "Maximum snapshot size reached.";
|
const char * const error_message_p = "Maximum snapshot size reached.";
|
||||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ static void
|
|||||||
static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< snapshot globals */
|
static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< snapshot globals */
|
||||||
ecma_value_t literal) /**< literal form the literal pool */
|
ecma_value_t literal) /**< literal form the literal pool */
|
||||||
{
|
{
|
||||||
const char *error_prefix_p = "Unsupported static snapshot literal: ";
|
const char * const error_prefix_p = "Unsupported static snapshot literal: ";
|
||||||
|
|
||||||
ecma_string_t *error_message_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) error_prefix_p,
|
ecma_string_t *error_message_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) error_prefix_p,
|
||||||
(lit_utf8_size_t) strlen (error_prefix_p));
|
(lit_utf8_size_t) strlen (error_prefix_p));
|
||||||
@@ -329,7 +329,7 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
|
|||||||
|
|
||||||
if (globals_p->snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
|
if (globals_p->snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
|
||||||
{
|
{
|
||||||
const char *error_message_p = "Maximum snapshot size reached.";
|
const char * const error_message_p = "Maximum snapshot size reached.";
|
||||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
|
|||||||
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
|
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
|
||||||
{
|
{
|
||||||
/* Regular expression literals are not supported. */
|
/* Regular expression literals are not supported. */
|
||||||
const char *error_message_p = "Regular expression literals are not supported.";
|
const char * const error_message_p = "Regular expression literals are not supported.";
|
||||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
|
|||||||
compiled_code_p,
|
compiled_code_p,
|
||||||
((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG))
|
((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG))
|
||||||
{
|
{
|
||||||
const char *error_message_p = "Snapshot buffer too small.";
|
const char * const error_message_p = "Snapshot buffer too small.";
|
||||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
|
|||||||
&literals_num))
|
&literals_num))
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (lit_map_p == NULL);
|
JERRY_ASSERT (lit_map_p == NULL);
|
||||||
const char *error_message_p = "Cannot allocate memory for literals.";
|
const char * const error_message_p = "Cannot allocate memory for literals.";
|
||||||
return jerry_create_error (JERRY_ERROR_COMMON, (const jerry_char_t *) error_message_p);
|
return jerry_create_error (JERRY_ERROR_COMMON, (const jerry_char_t *) error_message_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,7 +859,7 @@ jerry_generate_snapshot (const jerry_char_t *resource_name_p, /**< script resour
|
|||||||
|
|
||||||
if ((generate_snapshot_opts & ~(allowed_opts)) != 0)
|
if ((generate_snapshot_opts & ~(allowed_opts)) != 0)
|
||||||
{
|
{
|
||||||
const char *error_message_p = "Unsupported generate snapshot flags specified.";
|
const char * const error_message_p = "Unsupported generate snapshot flags specified.";
|
||||||
return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,8 +912,8 @@ jerry_snapshot_result (const uint32_t *snapshot_p, /**< snapshot */
|
|||||||
return ecma_create_error_reference_from_context ();
|
return ecma_create_error_reference_from_context ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * const invalid_version_error_p = "Invalid snapshot version or unsupported features present";
|
const char * const invalid_version_error_p = "Invalid snapshot version or unsupported features present";
|
||||||
static const char * const invalid_format_error_p = "Invalid snapshot format";
|
const char * const invalid_format_error_p = "Invalid snapshot format";
|
||||||
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
|
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
|
||||||
|
|
||||||
if (snapshot_size <= sizeof (jerry_snapshot_header_t))
|
if (snapshot_size <= sizeof (jerry_snapshot_header_t))
|
||||||
@@ -1697,7 +1697,7 @@ jerry_parse_and_save_literals (const jerry_char_t *source_p, /**< script source
|
|||||||
/* Save literal count. */
|
/* Save literal count. */
|
||||||
destination_p = jerry_append_chars_to_buffer (destination_p,
|
destination_p = jerry_append_chars_to_buffer (destination_p,
|
||||||
buffer_end_p,
|
buffer_end_p,
|
||||||
(const char *) "jerry_length_t literal_count = ",
|
"jerry_length_t literal_count = ",
|
||||||
0);
|
0);
|
||||||
|
|
||||||
destination_p = jerry_append_number_to_buffer (destination_p, buffer_end_p, literal_count);
|
destination_p = jerry_append_number_to_buffer (destination_p, buffer_end_p, literal_count);
|
||||||
@@ -1727,7 +1727,7 @@ jerry_parse_and_save_literals (const jerry_char_t *source_p, /**< script source
|
|||||||
|
|
||||||
destination_p = jerry_append_chars_to_buffer (destination_p,
|
destination_p = jerry_append_chars_to_buffer (destination_p,
|
||||||
buffer_end_p,
|
buffer_end_p,
|
||||||
(const char *) "};\n\njerry_length_t literal_sizes[",
|
"};\n\njerry_length_t literal_sizes[",
|
||||||
0);
|
0);
|
||||||
|
|
||||||
destination_p = jerry_append_number_to_buffer (destination_p, buffer_end_p, literal_count);
|
destination_p = jerry_append_number_to_buffer (destination_p, buffer_end_p, literal_count);
|
||||||
@@ -1769,7 +1769,7 @@ jerry_parse_and_save_literals (const jerry_char_t *source_p, /**< script source
|
|||||||
|
|
||||||
if (is_c_format)
|
if (is_c_format)
|
||||||
{
|
{
|
||||||
destination_p = jerry_append_chars_to_buffer (destination_p, buffer_end_p, (const char *) "};\n", 0);
|
destination_p = jerry_append_chars_to_buffer (destination_p, buffer_end_p, "};\n", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
JMEM_FINALIZE_LOCAL_ARRAY (literal_array);
|
JMEM_FINALIZE_LOCAL_ARRAY (literal_array);
|
||||||
@@ -1811,7 +1811,7 @@ jerry_generate_function_snapshot (const jerry_char_t *resource_name_p, /**< scri
|
|||||||
|
|
||||||
if ((generate_snapshot_opts & ~(allowed_opts)) != 0)
|
if ((generate_snapshot_opts & ~(allowed_opts)) != 0)
|
||||||
{
|
{
|
||||||
const char *error_message_p = "Unsupported generate snapshot flags specified.";
|
const char * const error_message_p = "Unsupported generate snapshot flags specified.";
|
||||||
return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -628,12 +628,12 @@ static ecma_value_t
|
|||||||
ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */
|
ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */
|
||||||
const char *format_p) /**< format buffer */
|
const char *format_p) /**< format buffer */
|
||||||
{
|
{
|
||||||
const char *day_names_p[8] =
|
static const char * const day_names_p[8] =
|
||||||
{
|
{
|
||||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *month_names_p[13] =
|
static const char * const month_names_p[13] =
|
||||||
{
|
{
|
||||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error typ
|
|||||||
|
|
||||||
#ifdef JERRY_ENABLE_LINE_INFO
|
#ifdef JERRY_ENABLE_LINE_INFO
|
||||||
/* The "stack" identifier is not a magic string. */
|
/* The "stack" identifier is not a magic string. */
|
||||||
const char *stack_id_p = "stack";
|
const char * const stack_id_p = "stack";
|
||||||
|
|
||||||
ecma_string_t *stack_str_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) stack_id_p, 5);
|
ecma_string_t *stack_str_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) stack_id_p, 5);
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ vm_get_backtrace (uint32_t max_depth) /**< maximum backtrace depth, 0 = unlimite
|
|||||||
|
|
||||||
if (ecma_string_is_empty (str_p))
|
if (ecma_string_is_empty (str_p))
|
||||||
{
|
{
|
||||||
const char *unknown_str_p = "<unknown>:";
|
const char * const unknown_str_p = "<unknown>:";
|
||||||
str_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) unknown_str_p,
|
str_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) unknown_str_p,
|
||||||
(lit_utf8_size_t) strlen (unknown_str_p));
|
(lit_utf8_size_t) strlen (unknown_str_p));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ jerryx_handler_print (const jerry_value_t func_obj_val, /**< function object */
|
|||||||
(void) func_obj_val; /* unused */
|
(void) func_obj_val; /* unused */
|
||||||
(void) this_p; /* unused */
|
(void) this_p; /* unused */
|
||||||
|
|
||||||
static const char *null_str = "\\u0000";
|
const char * const null_str = "\\u0000";
|
||||||
|
|
||||||
jerry_value_t ret_val = jerry_create_undefined ();
|
jerry_value_t ret_val = jerry_create_undefined ();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user