summaryrefslogtreecommitdiff
path: root/src/regparse.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-05-02 17:28:55 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-05-02 17:28:55 +0200
commit83ea1be016fd5fc27ee721cf62a18716675815dc (patch)
tree5d566283b63e5d719cd9715628dd9573b230f140 /src/regparse.c
parent10abcf77cc24dfae451d96310b4391dad35906ed (diff)
New upstream version 6.8.2upstream/6.8.2
Diffstat (limited to 'src/regparse.c')
-rw-r--r--src/regparse.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/regparse.c b/src/regparse.c
index 6e95a14..64923ad 100644
--- a/src/regparse.c
+++ b/src/regparse.c
@@ -525,7 +525,7 @@ onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
typedef struct {
OnigEncoding enc;
- int type; // callout type: single or not
+ int type; /* callout type: single or not */
UChar* s;
UChar* end;
} st_callout_name_key;
@@ -1583,7 +1583,7 @@ onig_set_callout_of_name(OnigEncoding enc, OnigCalloutType callout_type,
}
}
- r = id; // return id
+ r = id;
return r;
}
@@ -1637,24 +1637,36 @@ onig_get_callout_tag_end(regex_t* reg, int callout_num)
extern OnigCalloutType
onig_get_callout_type_by_name_id(int name_id)
{
+ if (name_id < 0 || name_id >= GlobalCalloutNameList->n)
+ return 0;
+
return GlobalCalloutNameList->v[name_id].type;
}
extern OnigCalloutFunc
onig_get_callout_start_func_by_name_id(int name_id)
{
+ if (name_id < 0 || name_id >= GlobalCalloutNameList->n)
+ return 0;
+
return GlobalCalloutNameList->v[name_id].start_func;
}
extern OnigCalloutFunc
onig_get_callout_end_func_by_name_id(int name_id)
{
+ if (name_id < 0 || name_id >= GlobalCalloutNameList->n)
+ return 0;
+
return GlobalCalloutNameList->v[name_id].end_func;
}
extern int
onig_get_callout_in_by_name_id(int name_id)
{
+ if (name_id < 0 || name_id >= GlobalCalloutNameList->n)
+ return 0;
+
return GlobalCalloutNameList->v[name_id].in;
}
@@ -1685,6 +1697,9 @@ get_callout_opt_default_by_name_id(int name_id, int index)
extern UChar*
onig_get_callout_name_by_name_id(int name_id)
{
+ if (name_id < 0 || name_id >= GlobalCalloutNameList->n)
+ return 0;
+
return GlobalCalloutNameList->v[name_id].name;
}
@@ -2689,7 +2704,7 @@ make_absent_engine(Node** node, int pre_save_right_id, Node* absent,
for (i = 0; i < 4; i++) ns[i] = NULL_NODE;
ns[1] = absent;
- ns[3] = step_one; // for err
+ ns[3] = step_one; /* for err */
r = node_new_save_gimmick(&ns[0], SAVE_S, env);
if (r != 0) goto err;
@@ -5341,8 +5356,11 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
if (num_type != IS_NOT_NUM) {
if (num_type == IS_REL_NUM) {
gnum = backref_rel_to_abs(gnum, env);
- if (gnum < 0)
+ if (gnum < 0) {
+ onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_NAME_REFERENCE,
+ prev, name_end);
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
+ }
}
tok->u.call.by_number = 1;
tok->u.call.gnum = gnum;
@@ -5563,8 +5581,11 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
else {
if (num_type == IS_REL_NUM) {
gnum = backref_rel_to_abs(gnum, env);
- if (gnum < 0)
+ if (gnum < 0) {
+ onig_scan_env_set_error_string(env,
+ ONIGERR_UNDEFINED_NAME_REFERENCE, name, name_end);
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
+ }
}
tok->u.call.by_number = 1;
tok->u.call.gnum = gnum;
@@ -6583,7 +6604,6 @@ parse_callout_of_contents(Node** np, int cterm, UChar** src, UChar* end, ScanEnv
PFETCH_S(c);
}
else if (c == '>') { /* no needs (default) */
- //in = ONIG_CALLOUT_IN_PROGRESS;
if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
PFETCH_S(c);
}
@@ -6823,7 +6843,7 @@ parse_callout_of_name(Node** np, int cterm, UChar** src, UChar* end, ScanEnv* en
OnigEncoding enc = env->enc;
UChar* p = *src;
- //PFETCH_READY;
+ /* PFETCH_READY; */
if (PEND) return ONIGERR_INVALID_CALLOUT_PATTERN;
node = 0;
@@ -7053,12 +7073,12 @@ parse_enclosure(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
- if (PPEEK_IS('|')) { // (?~|generator|absent)
+ if (PPEEK_IS('|')) { /* (?~|generator|absent) */
PINC;
if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
head_bar = 1;
- if (PPEEK_IS(')')) { // (?~|) : range clear
+ if (PPEEK_IS(')')) { /* (?~|) : range clear */
PINC;
r = make_range_clear(np, env);
if (r != 0) return r;
@@ -7083,7 +7103,7 @@ parse_enclosure(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
if (NODE_TYPE(top) != NODE_ALT || IS_NULL(NODE_CDR(top))) {
expr = NULL_NODE;
is_range_cutter = 1;
- //return ONIGERR_INVALID_ABSENT_GROUP_GENERATOR_PATTERN;
+ /* return ONIGERR_INVALID_ABSENT_GROUP_GENERATOR_PATTERN; */
}
else {
absent = NODE_CAR(top);
@@ -7778,7 +7798,7 @@ parse_exp(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
len = 1;
while (1) {
if (len >= ONIGENC_MBC_MINLEN(env->enc)) {
- if (len == enclen(env->enc, STR_(*np)->s)) {//should not enclen_end()
+ if (len == enclen(env->enc, STR_(*np)->s)) {/* should not enclen_end() */
r = fetch_token(tok, src, end, env);
NODE_STRING_CLEAR_RAW(*np);
goto string_end;