X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=glib%2Fgregex.c;h=41bf67e3f531a1865f1bee47aba32c81a54706c0;hb=904ec5534cdc45d9b90e86a467e97af3b1bdd66d;hp=fa3a18fe68fc8ad9f084745153ad5323855a9c59;hpb=4f327d6379c3eb8f9dcd5127349c06f1d34b1155;p=platform%2Fupstream%2Fglib.git
diff --git a/glib/gregex.c b/glib/gregex.c
index fa3a18f..41bf67e 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -42,9 +42,9 @@
* SECTION:gregex
* @title: Perl-compatible regular expressions
* @short_description: matches strings against regular expressions
- * @see_also:
+ * @see_also: [Regular expression syntax][glib-regex-syntax]
*
- * The g_regex_*() functions implement regular
+ * The g_regex_*() functions implement regular
* expression pattern matching using syntax and semantics similar to
* Perl regular expression.
*
@@ -98,7 +98,7 @@
* '\U' always matches 'U' instead of being an error in the pattern. Finally,
* pattern matching is modified so that back references to an unset subpattern
* group produces a match with the empty string instead of an error. See
- * man:pcreapi(3) for more information.
+ * pcreapi(3) for more information.
*
* Creating and manipulating the same #GRegex structure from different
* threads is not a problem as #GRegex does not modify its internal
@@ -106,8 +106,9 @@
* is not threadsafe.
*
* The regular expressions low-level functionalities are obtained through
- * the excellent PCRE library
- * written by Philip Hazel.
+ * the excellent
+ * [PCRE](http://www.pcre.org/)
+ * library written by Philip Hazel.
*/
/* Mask of all the possible values for GRegexCompileFlags. */
@@ -878,7 +879,7 @@ g_match_info_get_match_count (const GMatchInfo *match_info)
* There were formerly some restrictions on the pattern for partial matching.
* The restrictions no longer apply.
*
- * See man:pcrepartial for more information on partial matching.
+ * See pcrepartial(3) for more information on partial matching.
*
* Returns: %TRUE if the match was partial, %FALSE otherwise
*
@@ -960,7 +961,7 @@ g_match_info_expand_references (const GMatchInfo *match_info,
* @match_info: #GMatchInfo structure
* @match_num: number of the sub expression
*
- * Retrieves the text matching the @match_num'th capturing
+ * Retrieves the text matching the @match_num'th capturing
* parentheses. 0 is the full text of the match, 1 is the first paren
* set, 2 the second, and so on.
*
@@ -1015,7 +1016,7 @@ g_match_info_fetch (const GMatchInfo *match_info,
* @end_pos: (out) (allow-none): pointer to location where to store
* the end position, or %NULL
*
- * Retrieves the position in bytes of the @match_num'th capturing
+ * Retrieves the position in bytes of the @match_num'th capturing
* parentheses. 0 is the full text of the match, 1 is the first
* paren set, 2 the second, and so on.
*
@@ -1102,7 +1103,7 @@ get_matched_substring_number (const GMatchInfo *match_info,
* Retrieves the text matching the capturing parentheses named @name.
*
* If @name is a valid sub pattern name but it didn't match anything
- * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
+ * (e.g. sub pattern "X", matching "b" against "(?Pa)?b")
* then an empty string is returned.
*
* The string is fetched from the string passed to the match function,
@@ -1143,7 +1144,7 @@ g_match_info_fetch_named (const GMatchInfo *match_info,
* Retrieves the position in bytes of the capturing parentheses named @name.
*
* If @name is a valid sub pattern name but it didn't match anything
- * (e.g. sub pattern "X", matching "b" against "(?P<X>a)?b")
+ * (e.g. sub pattern "X", matching "b" against "(?Pa)?b")
* then @start_pos and @end_pos are set to -1 and %TRUE is returned.
*
* Returns: %TRUE if the position was fetched, %FALSE otherwise.
@@ -1520,6 +1521,29 @@ g_regex_get_has_cr_or_lf (const GRegex *regex)
}
/**
+ * g_regex_get_max_lookbehind:
+ * @regex: a #GRegex structure
+ *
+ * Gets the number of characters in the longest lookbehind assertion in the
+ * pattern. This information is useful when doing multi-segment matching using
+ * the partial matching facilities.
+ *
+ * Returns: the number of characters in the longest lookbehind assertion.
+ *
+ * Since: 2.38
+ */
+gint
+g_regex_get_max_lookbehind (const GRegex *regex)
+{
+ gint max_lookbehind;
+
+ pcre_fullinfo (regex->pcre_re, regex->extra,
+ PCRE_INFO_MAXLOOKBEHIND, &max_lookbehind);
+
+ return max_lookbehind;
+}
+
+/**
* g_regex_get_compile_flags:
* @regex: a #GRegex
*
@@ -1615,16 +1639,16 @@ g_regex_match_simple (const gchar *pattern,
* To retrieve all the non-overlapping matches of the pattern in
* string you can use g_match_info_next().
*
- * |[
+ * |[
* static void
* print_uppercase_words (const gchar *string)
* {
- * /* Print all uppercase-only words. */
+ * // Print all uppercase-only words.
* GRegex *regex;
* GMatchInfo *match_info;
- *
+ *
* regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
- * g_regex_match (regex, string, 0, &match_info);
+ * g_regex_match (regex, string, 0, &match_info);
* while (g_match_info_matches (match_info))
* {
* gchar *word = g_match_info_fetch (match_info, 0);
@@ -1688,23 +1712,23 @@ g_regex_match (const GRegex *regex,
* To retrieve all the non-overlapping matches of the pattern in
* string you can use g_match_info_next().
*
- * |[
+ * |[
* static void
* print_uppercase_words (const gchar *string)
* {
- * /* Print all uppercase-only words. */
+ * // Print all uppercase-only words.
* GRegex *regex;
* GMatchInfo *match_info;
* GError *error = NULL;
- *
+ *
* regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
- * g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
+ * g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
* while (g_match_info_matches (match_info))
* {
* gchar *word = g_match_info_fetch (match_info, 0);
* g_print ("Found: %s\n", word);
* g_free (word);
- * g_match_info_next (match_info, &error);
+ * g_match_info_next (match_info, &error);
* }
* g_match_info_free (match_info);
* g_regex_unref (regex);
@@ -1800,15 +1824,15 @@ g_regex_match_all (const GRegex *regex,
* Using the standard algorithm for regular expression matching only
* the longest match in the string is retrieved, it is not possible
* to obtain all the available matches. For instance matching
- * "<a> <b> <c>" against the pattern "<.*>"
- * you get "<a> <b> <c>".
+ * " " against the pattern "<.*>"
+ * you get " ".
*
* This function uses a different algorithm (called DFA, i.e. deterministic
* finite automaton), so it can retrieve all the possible matches, all
* starting at the same point in the string. For instance matching
- * "<a> <b> <c>" against the pattern "<.*>"
- * you would obtain three matches: "<a> <b> <c>",
- * "<a> <b>" and "<a>".
+ * " " against the pattern "<.*>;"
+ * you would obtain three matches: " ",
+ * " " and "".
*
* The number of matched strings is retrieved using
* g_match_info_get_match_count(). To obtain the matched strings and
@@ -2670,40 +2694,20 @@ interpolation_list_needs_match (GList *list)
*
* Replaces all occurrences of the pattern in @regex with the
* replacement text. Backreferences of the form '\number' or
- * '\g<number>' in the replacement text are interpolated by the
- * number-th captured subexpression of the match, '\g<name>' refers
- * to the captured subexpression with the given name. '\0' refers to the
- * complete match, but '\0' followed by a number is the octal representation
- * of a character. To include a literal '\' in the replacement, write '\\'.
+ * '\g' in the replacement text are interpolated by the
+ * number-th captured subexpression of the match, '\g' refers
+ * to the captured subexpression with the given name. '\0' refers
+ * to the complete match, but '\0' followed by a number is the octal
+ * representation of a character. To include a literal '\' in the
+ * replacement, write '\\'.
+ *
* There are also escapes that changes the case of the following text:
*
- *
- * \l
- *
- * Convert to lower case the next character
- *
- *
- * \u
- *
- * Convert to upper case the next character
- *
- *
- * \L
- *
- * Convert to lower case till \E
- *
- *
- * \U
- *
- * Convert to upper case till \E
- *
- *
- * \E
- *
- * End case modification
- *
- *
- *
+ * - \l: Convert to lower case the next character
+ * - \u: Convert to upper case the next character
+ * - \L: Convert to lower case till \E
+ * - \U: Convert to upper case till \E
+ * - \E: End case modification
*
* If you do not need to use backreferences use g_regex_replace_literal().
*
@@ -2832,7 +2836,7 @@ g_regex_replace_literal (const GRegex *regex,
*
* The following example uses g_regex_replace_eval() to replace multiple
* strings at once:
- * |[
+ * |[
* static gboolean
* eval_cb (const GMatchInfo *info,
* GString *res,
@@ -2849,7 +2853,7 @@ g_regex_replace_literal (const GRegex *regex,
* return FALSE;
* }
*
- * /* ... */
+ * ...
*
* GRegex *reg;
* GHashTable *h;
@@ -2866,7 +2870,7 @@ g_regex_replace_literal (const GRegex *regex,
* res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
* g_hash_table_destroy (h);
*
- * /* ... */
+ * ...
* ]|
*
* Returns: a newly allocated string containing the replacements