Skip to content

Commit

Permalink
Resolve Perl #131522: Spurious "Assuming NOT a POSIX class" warning
Browse files Browse the repository at this point in the history
  • Loading branch information
demerphq committed Jun 18, 2017
1 parent 3aa3d69 commit bab0f8e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions regcomp.c
Expand Up @@ -13991,6 +13991,13 @@ S_populate_ANYOF_from_invlist(pTHX_ regnode *node, SV** invlist_ptr)
REPORT_LOCATION_ARGS(p))); \
} \
} STMT_END
#define CLEAR_POSIX_WARNINGS() \
if (posix_warnings && RExC_warn_text) \
av_clear(RExC_warn_text)

#define CLEAR_POSIX_WARNINGS_AND_RETURN(ret) \
CLEAR_POSIX_WARNINGS(); \
return ret

STATIC int
S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
Expand Down Expand Up @@ -14063,7 +14070,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
*
* The syntax for a legal posix class is:
*
* qr/(?xa: \[ : \^? [:lower:]{4,6} : \] )/
* qr/(?xa: \[ : \^? [[:lower:]]{4,6} : \] )/
*
* What this routine considers syntactically to be an intended posix class
* is this (the comments indicate some restrictions that the pattern
Expand All @@ -14088,7 +14095,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
* # for it to be considered to be
* # an intended posix class.
* \h*
* [:punct:]? # The closing class character,
* [[:punct:]]? # The closing class character,
* # possibly omitted. If not a colon
* # nor semi colon, the class name
* # must be even closer to a valid
Expand Down Expand Up @@ -14131,8 +14138,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,

PERL_ARGS_ASSERT_HANDLE_POSSIBLE_POSIX;

if (posix_warnings && RExC_warn_text)
av_clear(RExC_warn_text);
CLEAR_POSIX_WARNINGS();

if (p >= e) {
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
Expand Down Expand Up @@ -14224,7 +14230,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
*updated_parse_ptr = (char *) temp_ptr;
}

return OOB_NAMEDCLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(OOB_NAMEDCLASS);
}
}

Expand Down Expand Up @@ -14294,7 +14300,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
/* We consider something like [^:^alnum:]] to not have been intended to
* be a posix class, but XXX maybe we should */
if (complement) {
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(NOT_MEANT_TO_BE_A_POSIX_CLASS);
}

complement = 1;
Expand All @@ -14321,7 +14327,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
* this leaves this construct looking like [:] or [:^], which almost
* certainly weren't intended to be posix classes */
if (has_opening_bracket) {
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(NOT_MEANT_TO_BE_A_POSIX_CLASS);
}

/* But this function can be called when we parse the colon for
Expand All @@ -14338,7 +14344,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
/* XXX We are currently very restrictive here, so this code doesn't
* consider the possibility that, say, /[alpha.]]/ was intended to
* be a posix class. */
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(NOT_MEANT_TO_BE_A_POSIX_CLASS);
}

/* Here we have something like 'foo:]'. There was no initial colon,
Expand Down Expand Up @@ -14508,7 +14514,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
}

/* Otherwise, it can't have meant to have been a class */
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(NOT_MEANT_TO_BE_A_POSIX_CLASS);
}

/* If we ran off the end, and the final character was a punctuation
Expand Down Expand Up @@ -14558,7 +14564,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
* class name. (We can do this on the first pass, as any second pass
* will yield an even shorter name) */
if (name_len < 3) {
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(NOT_MEANT_TO_BE_A_POSIX_CLASS);
}

/* Find which class it is. Initially switch on the length of the name.
Expand Down Expand Up @@ -14717,7 +14723,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
}

/* Here neither pass found a close-enough class name */
return NOT_MEANT_TO_BE_A_POSIX_CLASS;
CLEAR_POSIX_WARNINGS_AND_RETURN(NOT_MEANT_TO_BE_A_POSIX_CLASS);
}

probably_meant_to_be:
Expand Down Expand Up @@ -14759,7 +14765,7 @@ S_handle_possible_posix(pTHX_ RExC_state_t *pRExC_state,
/* If it is a known class, return the class. The class number
* #defines are structured so each complement is +1 to the normal
* one */
return class_number + complement;
CLEAR_POSIX_WARNINGS_AND_RETURN(class_number + complement);
}
else if (! check_only) {

Expand Down

0 comments on commit bab0f8e

Please sign in to comment.