mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-10 11:14:05 +02:00
regex: Add FIRSTLINE compile flag
This option exists since PCRE 6.0.
This commit is contained in:
@@ -121,6 +121,7 @@
|
|||||||
G_REGEX_RAW | \
|
G_REGEX_RAW | \
|
||||||
G_REGEX_NO_AUTO_CAPTURE | \
|
G_REGEX_NO_AUTO_CAPTURE | \
|
||||||
G_REGEX_OPTIMIZE | \
|
G_REGEX_OPTIMIZE | \
|
||||||
|
G_REGEX_FIRSTLINE | \
|
||||||
G_REGEX_DUPNAMES | \
|
G_REGEX_DUPNAMES | \
|
||||||
G_REGEX_NEWLINE_CR | \
|
G_REGEX_NEWLINE_CR | \
|
||||||
G_REGEX_NEWLINE_LF | \
|
G_REGEX_NEWLINE_LF | \
|
||||||
@@ -160,6 +161,7 @@ G_STATIC_ASSERT (G_REGEX_ANCHORED == PCRE_ANCHORED);
|
|||||||
G_STATIC_ASSERT (G_REGEX_DOLLAR_ENDONLY == PCRE_DOLLAR_ENDONLY);
|
G_STATIC_ASSERT (G_REGEX_DOLLAR_ENDONLY == PCRE_DOLLAR_ENDONLY);
|
||||||
G_STATIC_ASSERT (G_REGEX_UNGREEDY == PCRE_UNGREEDY);
|
G_STATIC_ASSERT (G_REGEX_UNGREEDY == PCRE_UNGREEDY);
|
||||||
G_STATIC_ASSERT (G_REGEX_NO_AUTO_CAPTURE == PCRE_NO_AUTO_CAPTURE);
|
G_STATIC_ASSERT (G_REGEX_NO_AUTO_CAPTURE == PCRE_NO_AUTO_CAPTURE);
|
||||||
|
G_STATIC_ASSERT (G_REGEX_FIRSTLINE == PCRE_FIRSTLINE);
|
||||||
G_STATIC_ASSERT (G_REGEX_DUPNAMES == PCRE_DUPNAMES);
|
G_STATIC_ASSERT (G_REGEX_DUPNAMES == PCRE_DUPNAMES);
|
||||||
G_STATIC_ASSERT (G_REGEX_NEWLINE_CR == PCRE_NEWLINE_CR);
|
G_STATIC_ASSERT (G_REGEX_NEWLINE_CR == PCRE_NEWLINE_CR);
|
||||||
G_STATIC_ASSERT (G_REGEX_NEWLINE_LF == PCRE_NEWLINE_LF);
|
G_STATIC_ASSERT (G_REGEX_NEWLINE_LF == PCRE_NEWLINE_LF);
|
||||||
|
@@ -258,6 +258,8 @@ GQuark g_regex_error_quark (void);
|
|||||||
* @G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will
|
* @G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will
|
||||||
* be used many times, then it may be worth the effort to optimize it
|
* be used many times, then it may be worth the effort to optimize it
|
||||||
* to improve the speed of matches.
|
* to improve the speed of matches.
|
||||||
|
* @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the
|
||||||
|
* first newline. Since: 2.34
|
||||||
* @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not
|
* @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not
|
||||||
* be unique. This can be helpful for certain types of pattern when it
|
* be unique. This can be helpful for certain types of pattern when it
|
||||||
* is known that only one instance of the named subpattern can ever be
|
* is known that only one instance of the named subpattern can ever be
|
||||||
@@ -297,6 +299,7 @@ typedef enum
|
|||||||
G_REGEX_RAW = 1 << 11,
|
G_REGEX_RAW = 1 << 11,
|
||||||
G_REGEX_NO_AUTO_CAPTURE = 1 << 12,
|
G_REGEX_NO_AUTO_CAPTURE = 1 << 12,
|
||||||
G_REGEX_OPTIMIZE = 1 << 13,
|
G_REGEX_OPTIMIZE = 1 << 13,
|
||||||
|
G_REGEX_FIRSTLINE = 1 << 18,
|
||||||
G_REGEX_DUPNAMES = 1 << 19,
|
G_REGEX_DUPNAMES = 1 << 19,
|
||||||
G_REGEX_NEWLINE_CR = 1 << 20,
|
G_REGEX_NEWLINE_CR = 1 << 20,
|
||||||
G_REGEX_NEWLINE_LF = 1 << 21,
|
G_REGEX_NEWLINE_LF = 1 << 21,
|
||||||
|
@@ -2326,6 +2326,9 @@ main (int argc, char *argv[])
|
|||||||
TEST_MATCH("a#\nb", G_REGEX_EXTENDED, G_REGEX_MATCH_NEWLINE_CR, "a", -1, 0, 0, FALSE);
|
TEST_MATCH("a#\nb", G_REGEX_EXTENDED, G_REGEX_MATCH_NEWLINE_CR, "a", -1, 0, 0, FALSE);
|
||||||
TEST_MATCH("a#\nb", G_REGEX_EXTENDED | G_REGEX_NEWLINE_CR, 0, "a", -1, 0, 0, TRUE);
|
TEST_MATCH("a#\nb", G_REGEX_EXTENDED | G_REGEX_NEWLINE_CR, 0, "a", -1, 0, 0, TRUE);
|
||||||
|
|
||||||
|
TEST_MATCH("line\nbreak", G_REGEX_MULTILINE, 0, "this is a line\nbreak", -1, 0, 0, TRUE);
|
||||||
|
TEST_MATCH("line\nbreak", G_REGEX_MULTILINE | G_REGEX_FIRSTLINE, 0, "first line\na line\nbreak", -1, 0, 0, FALSE);
|
||||||
|
|
||||||
/* This failed with PCRE 7.2 (gnome bug #455640) */
|
/* This failed with PCRE 7.2 (gnome bug #455640) */
|
||||||
TEST_MATCH(".*$", 0, 0, "\xe1\xbb\x85", -1, 0, 0, TRUE);
|
TEST_MATCH(".*$", 0, 0, "\xe1\xbb\x85", -1, 0, 0, TRUE);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user