Skip to content

Style fixes for RegExp. Rename RegExp tests to match current style. #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions jerry-core/ecma/operations/ecma-regexp-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ utf8_backtrack (const ecma_char_t* str_p)
{
/* FIXME: fix this, when unicode support is finished! */
return --str_p;
}
} /* utf8_backtrack */

/**
* Helper to get an input character and increase string pointer.
Expand All @@ -228,7 +228,7 @@ get_input_char (const ecma_char_t** char_p)
const ecma_char_t ch = **char_p;
(*char_p)++;
return ch;
}
} /* get_input_char */

/**
* Helper to get current input character, won't increase string pointer.
Expand All @@ -238,7 +238,7 @@ lookup_input_char (const ecma_char_t* str_p)
{
/* FIXME: fix this, when unicode support is finished! */
return *str_p;
}
} /* lookup_input_char */

/**
* Helper to get previous input character, won't decrease string pointer.
Expand All @@ -248,7 +248,7 @@ lookup_prev_char (const ecma_char_t* str_p)
{
/* FIXME: fix this, when unicode support is finished! */
return *(--str_p);
}
} /* lookup_prev_char */

/**
* Helper to check that a unicode character is a word character or not.
Expand All @@ -264,7 +264,7 @@ regexp_is_wordchar (const ecma_char_t ch)
return true;
}
return false;
}
} /* regexp_is_wordchar */

/**
* Recursive function for RegExp matching
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/parser/js/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ consume_char (void)
} \
while (0)

static uint32_t
uint32_t
hex_to_int (char hex)
{
switch (hex)
Expand Down
2 changes: 2 additions & 0 deletions jerry-core/parser/js/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ typedef struct
*/
#define TOKEN_EMPTY_INITIALIZER {0, TOK_EMPTY, 0}

uint32_t hex_to_int (char hex);

void lexer_init (const char *, size_t, bool);
void lexer_free (void);

Expand Down
42 changes: 6 additions & 36 deletions jerry-core/parser/regexp/re-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ecma-helpers.h"
#include "ecma-try-catch-macro.h"
#include "jrt-libc-includes.h"
#include "lexer.h"
#include "re-parser.h"
#include "syntax-errors.h"

Expand All @@ -27,44 +28,13 @@
#define RE_LOOKUP(str_p, lookup) *(str_p + lookup)
#define RE_ADVANCE(str_p, advance) do { str_p += advance; } while (0)

static uint32_t
hex_to_int (ecma_char_t hex)
{
switch (hex)
{
case '0': return 0x0;
case '1': return 0x1;
case '2': return 0x2;
case '3': return 0x3;
case '4': return 0x4;
case '5': return 0x5;
case '6': return 0x6;
case '7': return 0x7;
case '8': return 0x8;
case '9': return 0x9;
case 'a':
case 'A': return 0xA;
case 'b':
case 'B': return 0xB;
case 'c':
case 'C': return 0xC;
case 'd':
case 'D': return 0xD;
case 'e':
case 'E': return 0xE;
case 'f':
case 'F': return 0xF;
default: JERRY_UNREACHABLE ();
}
}

static ecma_char_t
get_ecma_char (ecma_char_t** char_p)
{
ecma_char_t ch = **char_p;
RE_ADVANCE (*char_p, 1);
return ch;
}
} /* get_ecma_char */

/**
* Parse RegExp iterators
Expand Down Expand Up @@ -152,7 +122,7 @@ parse_re_iterator (ecma_char_t *pattern_p, /**< RegExp pattern */
return ret_value;
}
digits++;
qmin = qmin * 10 + hex_to_int (ch1);
qmin = qmin * 10 + hex_to_int ((char) ch1);
}
else if (ch1 == ',')
{
Expand Down Expand Up @@ -231,7 +201,7 @@ parse_re_iterator (ecma_char_t *pattern_p, /**< RegExp pattern */
}

return ret_value;
}
} /* parse_re_iterator */

/**
* Count the number of groups in pattern
Expand Down Expand Up @@ -279,7 +249,7 @@ re_count_num_of_groups (re_parser_ctx_t *parser_ctx_p) /**< RegExp parser contex
}
}
}
}
} /* re_count_num_of_groups */

/**
* Read the input pattern and parse the range of character class
Expand Down Expand Up @@ -691,7 +661,7 @@ re_parse_next_token (re_parser_ctx_t *parser_ctx_p, /**< RegExp parser context *
{
break;
}
number = number * 10 + hex_to_int (digit);
number = number * 10 + hex_to_int ((char) digit);
index++;
}
while (true);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.