Split GRegex into GRegex and GMatchInfo. (#419368, Marco Barisione)

2007-04-30  Matthias Clasen  <mclasen@redhat.com>

        * glib/glib.symbols:
        * glib/gregex.[hc]: Split GRegex into GRegex and GMatchInfo.
        (#419368, Marco Barisione)

        * tests/regex-test.c: Adapt.


svn path=/trunk/; revision=5468
This commit is contained in:
Matthias Clasen 2007-04-30 16:02:26 +00:00 committed by Matthias Clasen
parent 3dd3293d87
commit a793051fda
8 changed files with 1171 additions and 2029 deletions

View File

@ -1,3 +1,11 @@
2007-04-30 Matthias Clasen <mclasen@redhat.com>
* glib/glib.symbols:
* glib/gregex.[hc]: Split GRegex into GRegex and GMatchInfo.
(#419368, Marco Barisione)
* tests/regex-test.c: Adapt.
2007-04-30 Chris Wilson <chris@chris-wilson.co.uk>
* glib/gbookmarkfile.c (g_bookmark_file_get_app_info):

View File

@ -1,3 +1,9 @@
2007-04-30 Matthias Clasen <mclasen@redhat.com>
* glib/glib-sections.txt:
* glib/tmpl/gregex.sgml: Update for the GRegex/GMatchInfo
split.
2007-04-24 Matthias Clasen <mclasen@redhat.com>
* glib/glib-sections.txt: Add g_option_context_get_help.

View File

@ -874,35 +874,31 @@ GRegex
GRegexEvalCallback
g_regex_new
g_regex_free
g_regex_optimize
g_regex_copy
g_regex_get_pattern
g_regex_clear
g_regex_get_string_number
g_regex_escape_string
g_regex_match_simple
g_regex_match
g_regex_match_full
g_regex_match_next
g_regex_match_next_full
g_regex_match_all
g_regex_match_all_full
g_regex_get_match_count
g_regex_is_partial_match
g_regex_fetch
g_regex_fetch_pos
g_regex_fetch_named
g_regex_fetch_named_pos
g_regex_fetch_all
g_regex_get_string_number
g_regex_split_simple
g_regex_split
g_regex_split_full
g_regex_split_next
g_regex_split_next_full
g_regex_expand_references
g_regex_replace
g_regex_replace_literal
g_regex_replace_eval
g_regex_escape_string
GMatchInfo
g_match_info_free
g_match_info_next
g_match_info_get_match_count
g_match_info_is_partial_match
g_match_info_expand_references
g_match_info_fetch
g_match_info_fetch_pos
g_match_info_fetch_named
g_match_info_fetch_named_pos
g_match_info_fetch_all
<SUBSECTION Private>
g_regex_error_quark
</SECTION>

View File

@ -56,10 +56,10 @@ encountered. This indicates a comment that lasts until after the next
newline.
</para>
<para>
If you have two threads manipulating the same #GRegex, they must use a
lock to synchronize their operation, as these functions are not threadsafe.
Creating and manipulating different #GRegex structures from different
threads is not a problem.
Creating and manipulating the same #GRegex structure from different
threads is not a problem as #GRegex does not modify its internal
state between creation and destruction, on the other hand #GMatchInfo is
not threadsafe.
</para>
<para>
The regular expressions low level functionalities are obtained through
@ -81,7 +81,7 @@ Error codes returned by regular expressions functions.
</para>
@G_REGEX_ERROR_COMPILE: Compilation of the regular expression in g_regex_new() failed.
@G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression in g_regex_optimize() failed.
@G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed.
@G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement string.
@G_REGEX_ERROR_MATCH: The match process failed.
@Since: 2.14
@ -139,6 +139,9 @@ flag they are considered as a raw sequence of bytes.
parentheses in the pattern. Any opening parenthesis that is not followed
by "?" behaves as if it were followed by "?:" but named parentheses can
still be used for capturing (and they acquire numbers in the usual way).
@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 to
improve the speed of matches.
@G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not
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 matched.
@ -204,17 +207,12 @@ It is called for each occurance of the pattern @regex in @string, and it
should append the replacement to @result.
</para>
<para>
Do not call on @regex functions that modify its internal state, such as
g_regex_match(); if you need it you can create a temporary copy of
@regex using g_regex_copy().
</para>
@Param1: a #GRegex.
@Param2: the string used to perform matches against.
@Param3: a #GString containing the new string.
@Param4: user data passed to g_regex_replace_eval().
@Returns: %FALSE to continue the replacement process, %TRUE to stop it.
@Param1: the #GRegex passed to g_regex_replace_eval()
@Param2: the #GMatchInfo generated by the match
@Param3: the string used to perform matches against
@Param4: a #GString containing the new string
@Param5: user data passed to g_regex_replace_eval()
@Returns: %FALSE to continue the replacement process, %TRUE to stop it
@Since: 2.14
@ -238,25 +236,6 @@ g_regex_match(); if you need it you can create a temporary copy of
@regex:
<!-- ##### FUNCTION g_regex_optimize ##### -->
<para>
</para>
@regex:
@error:
@Returns:
<!-- ##### FUNCTION g_regex_copy ##### -->
<para>
</para>
@regex:
@Returns:
<!-- ##### FUNCTION g_regex_get_pattern ##### -->
<para>
@ -266,12 +245,24 @@ g_regex_match(); if you need it you can create a temporary copy of
@Returns:
<!-- ##### FUNCTION g_regex_clear ##### -->
<!-- ##### FUNCTION g_regex_get_string_number ##### -->
<para>
</para>
@regex:
@name:
@Returns:
<!-- ##### FUNCTION g_regex_escape_string ##### -->
<para>
</para>
@string:
@length:
@Returns:
<!-- ##### FUNCTION g_regex_match_simple ##### -->
@ -294,6 +285,7 @@ g_regex_match(); if you need it you can create a temporary copy of
@regex:
@string:
@match_options:
@match_info:
@Returns:
@ -307,31 +299,7 @@ g_regex_match(); if you need it you can create a temporary copy of
@string_len:
@start_position:
@match_options:
@error:
@Returns:
<!-- ##### FUNCTION g_regex_match_next ##### -->
<para>
</para>
@regex:
@string:
@match_options:
@Returns:
<!-- ##### FUNCTION g_regex_match_next_full ##### -->
<para>
</para>
@regex:
@string:
@string_len:
@start_position:
@match_options:
@match_info:
@error:
@Returns:
@ -344,6 +312,7 @@ g_regex_match(); if you need it you can create a temporary copy of
@regex:
@string:
@match_options:
@match_info:
@Returns:
@ -357,94 +326,11 @@ g_regex_match(); if you need it you can create a temporary copy of
@string_len:
@start_position:
@match_options:
@match_info:
@error:
@Returns:
<!-- ##### FUNCTION g_regex_get_match_count ##### -->
<para>
</para>
@regex:
@Returns:
<!-- ##### FUNCTION g_regex_is_partial_match ##### -->
<para>
</para>
@regex:
@Returns:
<!-- ##### FUNCTION g_regex_fetch ##### -->
<para>
</para>
@regex:
@match_num:
@string:
@Returns:
<!-- ##### FUNCTION g_regex_fetch_pos ##### -->
<para>
</para>
@regex:
@match_num:
@start_pos:
@end_pos:
@Returns:
<!-- ##### FUNCTION g_regex_fetch_named ##### -->
<para>
</para>
@regex:
@name:
@string:
@Returns:
<!-- ##### FUNCTION g_regex_fetch_named_pos ##### -->
<para>
</para>
@regex:
@name:
@start_pos:
@end_pos:
@Returns:
<!-- ##### FUNCTION g_regex_fetch_all ##### -->
<para>
</para>
@regex:
@string:
@Returns:
<!-- ##### FUNCTION g_regex_get_string_number ##### -->
<para>
</para>
@regex:
@name:
@Returns:
<!-- ##### FUNCTION g_regex_split_simple ##### -->
<para>
@ -483,43 +369,6 @@ g_regex_match(); if you need it you can create a temporary copy of
@Returns:
<!-- ##### FUNCTION g_regex_split_next ##### -->
<para>
</para>
@regex:
@string:
@match_options:
@Returns:
<!-- ##### FUNCTION g_regex_split_next_full ##### -->
<para>
</para>
@regex:
@string:
@string_len:
@start_position:
@match_options:
@error:
@Returns:
<!-- ##### FUNCTION g_regex_expand_references ##### -->
<para>
</para>
@regex:
@string:
@string_to_expand:
@error:
@Returns:
<!-- ##### FUNCTION g_regex_replace ##### -->
<para>
@ -566,13 +415,112 @@ g_regex_match(); if you need it you can create a temporary copy of
@Returns:
<!-- ##### FUNCTION g_regex_escape_string ##### -->
<!-- ##### STRUCT GMatchInfo ##### -->
<para>
#GMatchInfo is used to retrieve information about the regular expression match
which created it.
This structure is opaque and its fields cannot be accessed directly.
</para>
@Since: 2.14
<!-- ##### FUNCTION g_match_info_free ##### -->
<para>
</para>
@string:
@length:
@match_info:
<!-- ##### FUNCTION g_match_info_next ##### -->
<para>
</para>
@match_info:
@error:
@Returns:
<!-- ##### FUNCTION g_match_info_get_match_count ##### -->
<para>
</para>
@match_info:
@Returns:
<!-- ##### FUNCTION g_match_info_is_partial_match ##### -->
<para>
</para>
@match_info:
@Returns:
<!-- ##### FUNCTION g_match_info_expand_references ##### -->
<para>
</para>
@match_info:
@string_to_expand:
@error:
@Returns:
<!-- ##### FUNCTION g_match_info_fetch ##### -->
<para>
</para>
@match_info:
@match_num:
@Returns:
<!-- ##### FUNCTION g_match_info_fetch_pos ##### -->
<para>
</para>
@match_info:
@match_num:
@start_pos:
@end_pos:
@Returns:
<!-- ##### FUNCTION g_match_info_fetch_named ##### -->
<para>
</para>
@match_info:
@name:
@Returns:
<!-- ##### FUNCTION g_match_info_fetch_named_pos ##### -->
<para>
</para>
@match_info:
@name:
@start_pos:
@end_pos:
@Returns:
<!-- ##### FUNCTION g_match_info_fetch_all ##### -->
<para>
</para>
@match_info:
@Returns:

View File

@ -1424,35 +1424,31 @@ g_get_codeset
g_regex_error_quark
g_regex_new
g_regex_free
g_regex_optimize
g_regex_copy
g_regex_get_pattern
g_regex_clear
g_regex_get_string_number
g_regex_escape_string
g_regex_match_simple
g_regex_match
g_regex_match_full
g_regex_match_next
g_regex_match_next_full
g_regex_match_all
g_regex_match_all_full
g_regex_get_match_count
g_regex_is_partial_match
g_regex_fetch
g_regex_fetch_pos
g_regex_fetch_named
g_regex_fetch_named_pos
g_regex_fetch_all
g_regex_get_string_number
g_regex_split_simple
g_regex_split
g_regex_split_full
g_regex_split_next
g_regex_split_next_full
g_regex_expand_references
g_regex_replace
g_regex_replace_literal
g_regex_replace_eval
g_regex_escape_string
g_match_info_free
g_match_info_next
g_match_info_matches
g_match_info_get_match_count
g_match_info_is_partial_match
g_match_info_expand_references
g_match_info_fetch
g_match_info_fetch_pos
g_match_info_fetch_named
g_match_info_fetch_named_pos
g_match_info_fetch_all
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
*
* Copyright (C) 1999, 2000 Scott Wimer
* Copyright (C) 2004, Matthias Clasen <mclasen@redhat.com>
* Copyright (C) 2005 - 2006, Marco Barisione <marco@barisione.org>
* Copyright (C) 2005 - 2007, Marco Barisione <marco@barisione.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -52,6 +52,7 @@ typedef enum
G_REGEX_UNGREEDY = 1 << 9,
G_REGEX_RAW = 1 << 11,
G_REGEX_NO_AUTO_CAPTURE = 1 << 12,
G_REGEX_OPTIMIZE = 1 << 13,
G_REGEX_DUPNAMES = 1 << 19,
G_REGEX_NEWLINE_CR = 1 << 20,
G_REGEX_NEWLINE_LF = 1 << 21,
@ -73,9 +74,14 @@ typedef enum
G_REGEX_MATCH_NEWLINE_ANY = 1 << 22
} GRegexMatchFlags;
typedef struct _GRegex GRegex;
typedef struct _GRegex GRegex;
typedef struct _GMatchInfo GMatchInfo;
typedef gboolean (*GRegexEvalCallback) (const GRegex*, const gchar*, GString*, gpointer);
typedef gboolean (*GRegexEvalCallback) (const GRegex *,
const GMatchInfo *,
const gchar *,
GString *,
gpointer);
GRegex *g_regex_new (const gchar *pattern,
@ -83,104 +89,72 @@ GRegex *g_regex_new (const gchar *pattern,
GRegexMatchFlags match_options,
GError **error);
void g_regex_free (GRegex *regex);
gboolean g_regex_optimize (GRegex *regex,
GError **error);
GRegex *g_regex_copy (const GRegex *regex);
const gchar *g_regex_get_pattern (const GRegex *regex);
void g_regex_clear (GRegex *regex);
gint g_regex_get_string_number (const GRegex *regex,
const gchar *name);
gchar *g_regex_escape_string (const gchar *string,
gint length);
/* Matching. */
gboolean g_regex_match_simple (const gchar *pattern,
const gchar *string,
GRegexCompileFlags compile_options,
GRegexMatchFlags match_options);
gboolean g_regex_match (GRegex *regex,
gboolean g_regex_match (const GRegex *regex,
const gchar *string,
GRegexMatchFlags match_options);
gboolean g_regex_match_full (GRegex *regex,
GRegexMatchFlags match_options,
GMatchInfo **match_info);
gboolean g_regex_match_full (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
GMatchInfo **match_info,
GError **error);
gboolean g_regex_match_next (GRegex *regex,
gboolean g_regex_match_all (const GRegex *regex,
const gchar *string,
GRegexMatchFlags match_options);
gboolean g_regex_match_next_full (GRegex *regex,
GRegexMatchFlags match_options,
GMatchInfo **match_info);
gboolean g_regex_match_all_full (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
GMatchInfo **match_info,
GError **error);
gboolean g_regex_match_all (GRegex *regex,
const gchar *string,
GRegexMatchFlags match_options);
gboolean g_regex_match_all_full (GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
GError **error);
gint g_regex_get_match_count (const GRegex *regex);
gboolean g_regex_is_partial_match (const GRegex *regex);
gchar *g_regex_fetch (const GRegex *regex,
gint match_num,
const gchar *string);
gboolean g_regex_fetch_pos (const GRegex *regex,
gint match_num,
gint *start_pos,
gint *end_pos);
gchar *g_regex_fetch_named (const GRegex *regex,
const gchar *name,
const gchar *string);
gboolean g_regex_fetch_named_pos (const GRegex *regex,
const gchar *name,
gint *start_pos,
gint *end_pos);
gchar **g_regex_fetch_all (const GRegex *regex,
const gchar *string);
gint g_regex_get_string_number (const GRegex *regex,
const gchar *name);
/* String splitting. */
gchar **g_regex_split_simple (const gchar *pattern,
const gchar *string,
GRegexCompileFlags compile_options,
GRegexMatchFlags match_options);
gchar **g_regex_split (GRegex *regex,
gchar **g_regex_split (const GRegex *regex,
const gchar *string,
GRegexMatchFlags match_options);
gchar **g_regex_split_full (GRegex *regex,
gchar **g_regex_split_full (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
gint max_tokens,
GError **error);
gchar *g_regex_split_next (GRegex *regex,
const gchar *string,
GRegexMatchFlags match_options);
gchar *g_regex_split_next_full (GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
GError **error);
gchar *g_regex_expand_references (GRegex *regex,
const gchar *string,
const gchar *string_to_expand,
GError **error);
gchar *g_regex_replace (GRegex *regex,
/* String replacement. */
gchar *g_regex_replace (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
const gchar *replacement,
GRegexMatchFlags match_options,
GError **error);
gchar *g_regex_replace_literal (GRegex *regex,
gchar *g_regex_replace_literal (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
const gchar *replacement,
GRegexMatchFlags match_options,
GError **error);
gchar *g_regex_replace_eval (GRegex *regex,
gchar *g_regex_replace_eval (const GRegex *regex,
const gchar *string,
gssize string_len,
gint start_position,
@ -188,9 +162,30 @@ gchar *g_regex_replace_eval (GRegex *regex,
GRegexEvalCallback eval,
gpointer user_data,
GError **error);
gchar *g_regex_escape_string (const gchar *string,
gint length);
/* Match info */
void g_match_info_free (GMatchInfo *match_info);
gboolean g_match_info_next (GMatchInfo *match_info,
GError **error);
gboolean g_match_info_matches (const GMatchInfo *match_info);
gint g_match_info_get_match_count (const GMatchInfo *match_info);
gboolean g_match_info_is_partial_match (const GMatchInfo *match_info);
gchar *g_match_info_expand_references(const GMatchInfo *match_info,
const gchar *string_to_expand,
GError **error);
gchar *g_match_info_fetch (const GMatchInfo *match_info,
gint match_num);
gboolean g_match_info_fetch_pos (const GMatchInfo *match_info,
gint match_num,
gint *start_pos,
gint *end_pos);
gchar *g_match_info_fetch_named (const GMatchInfo *match_info,
const gchar *name);
gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info,
const gchar *name,
gint *start_pos,
gint *end_pos);
gchar **g_match_info_fetch_all (const GMatchInfo *match_info);
G_END_DECLS

File diff suppressed because it is too large Load Diff