Skip to content

Commit daf0d6c

Browse files
k-takatanobu
authored andcommitted
Fix lgtm.com warnings
* Multiplication result may overflow 'int' before it is converted to 'OnigDistance'. * Comparison is always true because code <= 122. * This statement makes ExprStmt unreachable. * Empty block without comment k-takata/Onigmo@387ad61
1 parent bfbbcf3 commit daf0d6c

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

enc/unicode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
682682
*pp += codepoint_length;
683683

684684
if (code <= 'z') { /* ASCII comes first */
685-
if (code >= 'a' && code <= 'z') {
685+
if (code >= 'a' /*&& code <= 'z'*/) {
686686
if (flags & ONIGENC_CASE_UPCASE) {
687687
MODIFIED;
688688
if (flags & ONIGENC_CASE_FOLD_TURKISH_AZERI && code == 'i')

regcomp.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,14 +2803,11 @@ get_head_value_node(Node* node, int exact, regex_t* reg)
28032803
case NT_STR:
28042804
{
28052805
StrNode* sn = NSTR(node);
2806-
28072806
if (sn->end <= sn->s)
28082807
break;
28092808

2810-
if (exact != 0 &&
2811-
!NSTRING_IS_RAW(node) && IS_IGNORECASE(reg->options)) {
2812-
}
2813-
else {
2809+
if (exact == 0 ||
2810+
NSTRING_IS_RAW(node) || !IS_IGNORECASE(reg->options)) {
28142811
n = node;
28152812
}
28162813
}
@@ -5078,7 +5075,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env)
50785075

50795076
if (NSTRING_IS_DONT_GET_OPT_INFO(node)) {
50805077
int n = onigenc_strlen(env->enc, sn->s, sn->end);
5081-
max = ONIGENC_MBC_MAXLEN_DIST(env->enc) * (OnigDistance)n;
5078+
max = (OnigDistance )ONIGENC_MBC_MAXLEN_DIST(env->enc) * (OnigDistance)n;
50825079
}
50835080
else {
50845081
concat_opt_exact_info_str(&opt->exb, sn->s, sn->end,

regexec.c

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,7 +2742,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
27422742

27432743
/* default behavior: return first-matching result. */
27442744
goto finish;
2745-
NEXT;
27462745

27472746
CASE(OP_EXACT1) MOP_IN(OP_EXACT1);
27482747
DATA_ENSURE(1);
@@ -3316,40 +3315,36 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
33163315
if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
33173316
MOP_OUT;
33183317
JUMP;
3319-
}
3318+
}
33203319
}
33213320
goto fail;
3322-
NEXT;
33233321

33243322
CASE(OP_ASCII_WORD_BEGIN) MOP_IN(OP_ASCII_WORD_BEGIN);
33253323
if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)) {
33263324
if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end)) {
33273325
MOP_OUT;
33283326
JUMP;
3329-
}
3327+
}
33303328
}
33313329
goto fail;
3332-
NEXT;
33333330

33343331
CASE(OP_WORD_END) MOP_IN(OP_WORD_END);
33353332
if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
33363333
if (ON_STR_END(s) || !ONIGENC_IS_MBC_WORD(encode, s, end)) {
33373334
MOP_OUT;
33383335
JUMP;
3339-
}
3336+
}
33403337
}
33413338
goto fail;
3342-
NEXT;
33433339

33443340
CASE(OP_ASCII_WORD_END) MOP_IN(OP_ASCII_WORD_END);
33453341
if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end)) {
33463342
if (ON_STR_END(s) || !ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)) {
33473343
MOP_OUT;
33483344
JUMP;
3349-
}
3345+
}
33503346
}
33513347
goto fail;
3352-
NEXT;
33533348
#endif
33543349

33553350
CASE(OP_BEGIN_BUF) MOP_IN(OP_BEGIN_BUF);
@@ -3379,10 +3374,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
33793374
#endif
33803375
&& !ON_STR_END(s)) {
33813376
MOP_OUT;
3382-
JUMP;
3377+
JUMP;
33833378
}
33843379
goto fail;
3385-
NEXT;
33863380

33873381
CASE(OP_END_LINE) MOP_IN(OP_END_LINE);
33883382
if (ON_STR_END(s)) {
@@ -3398,10 +3392,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
33983392
}
33993393
else if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 1)) {
34003394
MOP_OUT;
3401-
JUMP;
3395+
JUMP;
34023396
}
34033397
goto fail;
3404-
NEXT;
34053398

34063399
CASE(OP_SEMI_END_BUF) MOP_IN(OP_SEMI_END_BUF);
34073400
if (ON_STR_END(s)) {
@@ -3433,7 +3426,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
34333426
#endif
34343427
}
34353428
goto fail;
3436-
NEXT;
34373429

34383430
CASE(OP_BEGIN_POSITION) MOP_IN(OP_BEGIN_POSITION);
34393431
if (s != msa->gpos)
@@ -3499,12 +3491,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
34993491
CASE(OP_BACKREF1) MOP_IN(OP_BACKREF1);
35003492
mem = 1;
35013493
goto backref;
3502-
NEXT;
35033494

35043495
CASE(OP_BACKREF2) MOP_IN(OP_BACKREF2);
35053496
mem = 2;
35063497
goto backref;
3507-
NEXT;
35083498

35093499
CASE(OP_BACKREFN) MOP_IN(OP_BACKREFN);
35103500
GET_MEMNUM_INC(mem, p);
@@ -3934,7 +3924,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
39343924
STACK_GET_REPEAT(mem, stkp);
39353925
si = GET_STACK_INDEX(stkp);
39363926
goto repeat_inc;
3937-
NEXT;
39383927

39393928
CASE(OP_REPEAT_INC_NG) MOP_IN(OP_REPEAT_INC_NG);
39403929
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
@@ -3970,7 +3959,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
39703959
STACK_GET_REPEAT(mem, stkp);
39713960
si = GET_STACK_INDEX(stkp);
39723961
goto repeat_inc_ng;
3973-
NEXT;
39743962

39753963
CASE(OP_PUSH_POS) MOP_IN(OP_PUSH_POS);
39763964
STACK_PUSH_POS(s, sprev, pkeep);
@@ -3995,7 +3983,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
39953983
CASE(OP_FAIL_POS) MOP_IN(OP_FAIL_POS);
39963984
STACK_POP_TIL_POS_NOT;
39973985
goto fail;
3998-
NEXT;
39993986

40003987
CASE(OP_PUSH_STOP_BT) MOP_IN(OP_PUSH_STOP_BT);
40013988
STACK_PUSH_STOP_BT;
@@ -4036,7 +4023,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
40364023
CASE(OP_FAIL_LOOK_BEHIND_NOT) MOP_IN(OP_FAIL_LOOK_BEHIND_NOT);
40374024
STACK_POP_TIL_LOOK_BEHIND_NOT;
40384025
goto fail;
4039-
NEXT;
40404026

40414027
CASE(OP_PUSH_ABSENT_POS) MOP_IN(OP_PUSH_ABSENT_POS);
40424028
/* Save the absent-start-pos and the original end-pos. */
@@ -4098,7 +4084,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
40984084
#endif
40994085
STACK_POP_TIL_ABSENT;
41004086
goto fail;
4101-
NEXT;
41024087

41034088
#ifdef USE_SUBEXP_CALL
41044089
CASE(OP_CALL) MOP_IN(OP_CALL);
@@ -4128,7 +4113,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
41284113

41294114
CASE(OP_FINISH)
41304115
goto finish;
4131-
NEXT;
41324116

41334117
CASE(OP_FAIL)
41344118
if (0) {

0 commit comments

Comments
 (0)