mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
Moved gurifuncs from gio to glib
2007-11-27 Alexander Larsson <alexl@redhat.com> * gio/Makefile.am: * gio/gurifuncs.[ch]: * glib/Makefile.am: * glib/gstring.[ch]: * glib/gurifuncs.[ch]: Moved gurifuncs from gio to glib svn path=/trunk/; revision=5955
This commit is contained in:
parent
68c74ba68f
commit
e3607fcdf3
@ -1,3 +1,12 @@
|
|||||||
|
2007-11-27 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* gio/Makefile.am:
|
||||||
|
* gio/gurifuncs.[ch]:
|
||||||
|
* glib/Makefile.am:
|
||||||
|
* glib/gstring.[ch]:
|
||||||
|
* glib/gurifuncs.[ch]:
|
||||||
|
Moved gurifuncs from gio to glib
|
||||||
|
|
||||||
2007-11-27 Alexander Larsson <alexl@redhat.com>
|
2007-11-27 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
* gio/gfileinfo.[ch]:
|
* gio/gfileinfo.[ch]:
|
||||||
|
@ -143,7 +143,6 @@ libgio_2_0_la_SOURCES = \
|
|||||||
gthemedicon.c \
|
gthemedicon.c \
|
||||||
gunionvolumemonitor.c \
|
gunionvolumemonitor.c \
|
||||||
gunionvolumemonitor.h \
|
gunionvolumemonitor.h \
|
||||||
gurifuncs.c \
|
|
||||||
gvfs.c \
|
gvfs.c \
|
||||||
gvolume.c \
|
gvolume.c \
|
||||||
gvolumemonitor.c \
|
gvolumemonitor.c \
|
||||||
@ -211,7 +210,6 @@ gioinclude_HEADERS = \
|
|||||||
gsocketinputstream.h \
|
gsocketinputstream.h \
|
||||||
gsocketoutputstream.h \
|
gsocketoutputstream.h \
|
||||||
gthemedicon.h \
|
gthemedicon.h \
|
||||||
gurifuncs.h \
|
|
||||||
gvfs.h \
|
gvfs.h \
|
||||||
gvolume.h \
|
gvolume.h \
|
||||||
gvolumemonitor.h \
|
gvolumemonitor.h \
|
||||||
|
@ -157,6 +157,7 @@ libglib_2_0_la_SOURCES = \
|
|||||||
gunidecomp.h \
|
gunidecomp.h \
|
||||||
gunidecomp.c \
|
gunidecomp.c \
|
||||||
gunicodeprivate.h \
|
gunicodeprivate.h \
|
||||||
|
gurifuncs.c \
|
||||||
gutils.c \
|
gutils.c \
|
||||||
gdebug.h \
|
gdebug.h \
|
||||||
gprintf.c \
|
gprintf.c \
|
||||||
@ -230,6 +231,7 @@ glibsubinclude_HEADERS = \
|
|||||||
gtree.h \
|
gtree.h \
|
||||||
gtypes.h \
|
gtypes.h \
|
||||||
gunicode.h \
|
gunicode.h \
|
||||||
|
gurifuncs.h \
|
||||||
gutils.h \
|
gutils.h \
|
||||||
gwin32.h \
|
gwin32.h \
|
||||||
gprintf.h
|
gprintf.h
|
||||||
|
@ -1398,5 +1398,88 @@ g_string_append_printf (GString *string,
|
|||||||
va_end (args);
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SUB_DELIM_CHARS "!$&'()*+,;="
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
is_valid (char c, const char *reserved_chars_allowed)
|
||||||
|
{
|
||||||
|
if (g_ascii_isalnum (c) ||
|
||||||
|
c == '-' ||
|
||||||
|
c == '.' ||
|
||||||
|
c == '_' ||
|
||||||
|
c == '~')
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if (reserved_chars_allowed &&
|
||||||
|
strchr (reserved_chars_allowed, c) != NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gunichar_ok (gunichar c)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(c != (gunichar) -2) &&
|
||||||
|
(c != (gunichar) -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_string_append_uri_escaped:
|
||||||
|
* @string: a #GString
|
||||||
|
* @unescaped: a string
|
||||||
|
* @reserved_chars_allowed: a string of reserved characters allowed to be used
|
||||||
|
* @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
|
||||||
|
*
|
||||||
|
* Appends @unescaped to @string, escaped any characters that
|
||||||
|
* are reserved in URIs using URI-style escape sequences.
|
||||||
|
*
|
||||||
|
* Returns: @string
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
|
**/
|
||||||
|
GString *
|
||||||
|
g_string_append_uri_escaped (GString *string,
|
||||||
|
const char *unescaped,
|
||||||
|
const char *reserved_chars_allowed,
|
||||||
|
gboolean allow_utf8)
|
||||||
|
{
|
||||||
|
unsigned char c;
|
||||||
|
const char *end;
|
||||||
|
static const gchar hex[16] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
|
g_return_val_if_fail (unescaped != NULL, NULL);
|
||||||
|
|
||||||
|
end = unescaped + strlen (unescaped);
|
||||||
|
|
||||||
|
while ((c = *unescaped) != 0)
|
||||||
|
{
|
||||||
|
if (c >= 0x80 && allow_utf8 &&
|
||||||
|
gunichar_ok (g_utf8_get_char_validated (unescaped, end - unescaped)))
|
||||||
|
{
|
||||||
|
int len = g_utf8_skip [c];
|
||||||
|
g_string_append_len (string, unescaped, len);
|
||||||
|
unescaped += len;
|
||||||
|
}
|
||||||
|
else if (is_valid (c, reserved_chars_allowed))
|
||||||
|
{
|
||||||
|
g_string_append_c (string, c);
|
||||||
|
unescaped++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_string_append_c (string, '%');
|
||||||
|
g_string_append_c (string, hex[((guchar)c) >> 4]);
|
||||||
|
g_string_append_c (string, hex[((guchar)c) & 0xf]);
|
||||||
|
unescaped++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define __G_STRING_C__
|
#define __G_STRING_C__
|
||||||
#include "galiasdef.c"
|
#include "galiasdef.c"
|
||||||
|
@ -129,6 +129,10 @@ void g_string_append_vprintf (GString *string,
|
|||||||
void g_string_append_printf (GString *string,
|
void g_string_append_printf (GString *string,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
...) G_GNUC_PRINTF (2, 3);
|
...) G_GNUC_PRINTF (2, 3);
|
||||||
|
GString * g_string_append_uri_escaped(GString *string,
|
||||||
|
const char *unescaped,
|
||||||
|
const char *reserved_chars_allowed,
|
||||||
|
gboolean allow_utf8);
|
||||||
|
|
||||||
/* -- optimize g_strig_append_c --- */
|
/* -- optimize g_strig_append_c --- */
|
||||||
#ifdef G_CAN_INLINE
|
#ifdef G_CAN_INLINE
|
||||||
|
@ -62,6 +62,8 @@ unescape_character (const char *scanner)
|
|||||||
*
|
*
|
||||||
* Returns: an unescaped version of @escaped_string or %NULL on error.
|
* Returns: an unescaped version of @escaped_string or %NULL on error.
|
||||||
* The returned string should be freed when no longer needed.
|
* The returned string should be freed when no longer needed.
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
**/
|
**/
|
||||||
char *
|
char *
|
||||||
g_uri_unescape_segment (const char *escaped_string,
|
g_uri_unescape_segment (const char *escaped_string,
|
||||||
@ -126,6 +128,8 @@ g_uri_unescape_segment (const char *escaped_string,
|
|||||||
*
|
*
|
||||||
* Returns: an unescaped version of @escaped_string. The returned string
|
* Returns: an unescaped version of @escaped_string. The returned string
|
||||||
* should be freed when no longer needed.
|
* should be freed when no longer needed.
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
**/
|
**/
|
||||||
char *
|
char *
|
||||||
g_uri_unescape_string (const char *escaped_string,
|
g_uri_unescape_string (const char *escaped_string,
|
||||||
@ -144,6 +148,8 @@ g_uri_unescape_string (const char *escaped_string,
|
|||||||
*
|
*
|
||||||
* Returns: The "Scheme" component of the URI, or %NULL on error.
|
* Returns: The "Scheme" component of the URI, or %NULL on error.
|
||||||
* The returned string should be freed when no longer needed.
|
* The returned string should be freed when no longer needed.
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
**/
|
**/
|
||||||
char *
|
char *
|
||||||
g_uri_get_scheme (const char *uri)
|
g_uri_get_scheme (const char *uri)
|
||||||
@ -183,85 +189,6 @@ g_uri_get_scheme (const char *uri)
|
|||||||
return g_strndup (uri, p - uri - 1);
|
return g_strndup (uri, p - uri - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SUB_DELIM_CHARS "!$&'()*+,;="
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
is_valid (char c, const char *reserved_chars_allowed)
|
|
||||||
{
|
|
||||||
if (g_ascii_isalnum (c) ||
|
|
||||||
c == '-' ||
|
|
||||||
c == '.' ||
|
|
||||||
c == '_' ||
|
|
||||||
c == '~')
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (reserved_chars_allowed &&
|
|
||||||
strchr (reserved_chars_allowed, c) != NULL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gunichar_ok (gunichar c)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(c != (gunichar) -2) &&
|
|
||||||
(c != (gunichar) -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* g_string_append_uri_escaped:
|
|
||||||
* @string: a #GString to append to.
|
|
||||||
* @unescaped: the input C string of unescaped URI data.
|
|
||||||
* @reserved_chars_allowed: a string of reserve characters allowed to be used.
|
|
||||||
* @allow_utf8: set %TRUE if the return value may include UTF8 characters.
|
|
||||||
*
|
|
||||||
* Appends an escaped URI to @string.
|
|
||||||
*
|
|
||||||
* Returns: a #GString with the escaped URI appended.
|
|
||||||
**/
|
|
||||||
GString *
|
|
||||||
g_string_append_uri_escaped (GString *string,
|
|
||||||
const char *unescaped,
|
|
||||||
const char *reserved_chars_allowed,
|
|
||||||
gboolean allow_utf8)
|
|
||||||
{
|
|
||||||
unsigned char c;
|
|
||||||
const char *end;
|
|
||||||
static const gchar hex[16] = "0123456789ABCDEF";
|
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
|
||||||
g_return_val_if_fail (unescaped != NULL, NULL);
|
|
||||||
|
|
||||||
end = unescaped + strlen (unescaped);
|
|
||||||
|
|
||||||
while ((c = *unescaped) != 0)
|
|
||||||
{
|
|
||||||
if (c >= 0x80 && allow_utf8 &&
|
|
||||||
gunichar_ok (g_utf8_get_char_validated (unescaped, end - unescaped)))
|
|
||||||
{
|
|
||||||
int len = g_utf8_skip [c];
|
|
||||||
g_string_append_len (string, unescaped, len);
|
|
||||||
unescaped += len;
|
|
||||||
}
|
|
||||||
else if (is_valid (c, reserved_chars_allowed))
|
|
||||||
{
|
|
||||||
g_string_append_c (string, c);
|
|
||||||
unescaped++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_string_append_c (string, '%');
|
|
||||||
g_string_append_c (string, hex[((guchar)c) >> 4]);
|
|
||||||
g_string_append_c (string, hex[((guchar)c) & 0xf]);
|
|
||||||
unescaped++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_uri_escape_string:
|
* g_uri_escape_string:
|
||||||
* @unescaped: the unescaped input string.
|
* @unescaped: the unescaped input string.
|
||||||
@ -272,6 +199,8 @@ g_string_append_uri_escaped (GString *string,
|
|||||||
*
|
*
|
||||||
* Returns: an escaped version of @unescaped. The returned string should be
|
* Returns: an escaped version of @unescaped. The returned string should be
|
||||||
* freed when no longer needed.
|
* freed when no longer needed.
|
||||||
|
*
|
||||||
|
* Since: 2.16
|
||||||
**/
|
**/
|
||||||
char *
|
char *
|
||||||
g_uri_escape_string (const char *unescaped,
|
g_uri_escape_string (const char *unescaped,
|
@ -71,13 +71,6 @@ char * g_uri_get_scheme (const char *uri);
|
|||||||
char * g_uri_escape_string (const char *unescaped,
|
char * g_uri_escape_string (const char *unescaped,
|
||||||
const char *reserved_chars_allowed,
|
const char *reserved_chars_allowed,
|
||||||
gboolean allow_utf8);
|
gboolean allow_utf8);
|
||||||
GString *g_string_append_uri_escaped (GString *string,
|
|
||||||
const char *unescaped,
|
|
||||||
const char *reserved_chars_allowed,
|
|
||||||
gboolean allow_utf8);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in New Issue
Block a user