Use 'const' in string iterations.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2016-03-31 10:17:50 +02:00
parent 9dad7dbfba
commit c98cb65373
16 changed files with 70 additions and 66 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ lit_char_hex_to_int (ecma_char_t c) /**< code unit, corresponding to
* @return true if decoding was successful, false otherwise
*/
bool
lit_read_code_unit_from_hex (lit_utf8_byte_t *buf_p, /**< buffer with characters */
lit_read_code_unit_from_hex (const lit_utf8_byte_t *buf_p, /**< buffer with characters */
lit_utf8_size_t number_of_characters, /**< number of characters to be read */
ecma_char_ptr_t out_code_unit_p) /**< [out] decoded result */
{
+1 -1
View File
@@ -216,7 +216,7 @@ extern bool lit_char_is_hex_digit (ecma_char_t);
extern uint32_t lit_char_hex_to_int (ecma_char_t);
/* read a hex encoded code point from a zero terminated buffer */
bool lit_read_code_unit_from_hex (lit_utf8_byte_t *, lit_utf8_size_t, ecma_char_ptr_t);
bool lit_read_code_unit_from_hex (const lit_utf8_byte_t *, lit_utf8_size_t, ecma_char_ptr_t);
/**
* Null character
+10 -9
View File
@@ -1,4 +1,5 @@
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -591,10 +592,8 @@ lit_read_prev_code_unit_from_utf8 (const lit_utf8_byte_t *buf_p, /**< buffer wit
{
JERRY_ASSERT (buf_p);
lit_utf8_byte_t *current_p = (lit_utf8_byte_t *) buf_p;
lit_utf8_decr (&current_p);
return lit_read_code_unit_from_utf8 (current_p, code_point);
lit_utf8_decr (&buf_p);
return lit_read_code_unit_from_utf8 (buf_p, code_point);
} /* lit_read_prev_code_unit_from_utf8 */
/**
@@ -603,7 +602,7 @@ lit_read_prev_code_unit_from_utf8 (const lit_utf8_byte_t *buf_p, /**< buffer wit
* @return next code unit
*/
ecma_char_t
lit_utf8_read_next (lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
lit_utf8_read_next (const lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
{
JERRY_ASSERT (*buf_p);
ecma_char_t ch;
@@ -619,7 +618,7 @@ lit_utf8_read_next (lit_utf8_byte_t **buf_p) /**< [in,out] buffer with character
* @return previous code unit
*/
ecma_char_t
lit_utf8_read_prev (lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
lit_utf8_read_prev (const lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
{
JERRY_ASSERT (*buf_p);
ecma_char_t ch;
@@ -666,7 +665,7 @@ lit_utf8_peek_prev (const lit_utf8_byte_t *buf_p) /**< [in,out] buffer with char
* Increase cesu-8 encoded string pointer by one code unit.
*/
void
lit_utf8_incr (lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
lit_utf8_incr (const lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
{
JERRY_ASSERT (*buf_p);
@@ -677,15 +676,17 @@ lit_utf8_incr (lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
* Decrease cesu-8 encoded string pointer by one code unit.
*/
void
lit_utf8_decr (lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
lit_utf8_decr (const lit_utf8_byte_t **buf_p) /**< [in,out] buffer with characters */
{
JERRY_ASSERT (*buf_p);
lit_utf8_byte_t *current_p = *buf_p;
const lit_utf8_byte_t *current_p = *buf_p;
do
{
current_p--;
}
while ((*(current_p) & LIT_UTF8_EXTRA_BYTE_MASK) == LIT_UTF8_EXTRA_BYTE_MARKER);
*buf_p = current_p;
} /* lit_utf8_decr */
+5 -4
View File
@@ -1,4 +1,5 @@
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -181,12 +182,12 @@ lit_utf8_size_t lit_read_code_unit_from_utf8 (const lit_utf8_byte_t *,
lit_utf8_size_t lit_read_prev_code_unit_from_utf8 (const lit_utf8_byte_t *,
ecma_char_t *);
ecma_char_t lit_utf8_read_next (lit_utf8_byte_t **);
ecma_char_t lit_utf8_read_prev (lit_utf8_byte_t **);
ecma_char_t lit_utf8_read_next (const lit_utf8_byte_t **);
ecma_char_t lit_utf8_read_prev (const lit_utf8_byte_t **);
ecma_char_t lit_utf8_peek_next (const lit_utf8_byte_t *);
ecma_char_t lit_utf8_peek_prev (const lit_utf8_byte_t *);
void lit_utf8_incr (lit_utf8_byte_t **);
void lit_utf8_decr (lit_utf8_byte_t **);
void lit_utf8_incr (const lit_utf8_byte_t **);
void lit_utf8_decr (const lit_utf8_byte_t **);
/* print */
void lit_put_ecma_char (ecma_char_t);