[goffice] go_url_encode: make this a thin wrapper around glib code.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] go_url_encode: make this a thin wrapper around glib code.
- Date: Fri, 16 Mar 2012 17:31:46 +0000 (UTC)
commit f5948a6d5cafdcede5a9b95e0b844103deb300d2
Author: Morten Welinder <terra gnome org>
Date: Fri Mar 16 13:30:45 2012 -0400
go_url_encode: make this a thin wrapper around glib code.
This removes the last code from Yukihiro Nakai whom we have been
unable to contact.
ChangeLog | 2 ++
goffice/utils/go-file.c | 28 ++++++----------------------
goffice/utils/go-file.h | 2 +-
3 files changed, 9 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3a7112c..9f7da62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
* goffice/utils/go-file.c (go_url_show): Remove. (Use
go_gtk_url_show instead.)
+ (go_url_encode): Make this a thin wrapper over
+ g_uri_escape_string.
* goffice/gtk/goffice-gtk.c (go_gtk_help_button_init): Hook up
cb_help normally, ie., not swapped.
diff --git a/goffice/utils/go-file.c b/goffice/utils/go-file.c
index 92c5e68..ccd2ab1 100644
--- a/goffice/utils/go-file.c
+++ b/goffice/utils/go-file.c
@@ -1,9 +1,7 @@
-/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* go-file.c :
*
- * Copyright (C) 2004,2009-2010 Morten Welinder (terra gnome org)
- * Copyright (C) 2004 Yukihiro Nakai <nakai gnome gr jp>
+ * Copyright (C) 2004,2009-2012 Morten Welinder (terra gnome org)
* Copyright (C) 2003, Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
@@ -910,7 +908,7 @@ go_file_get_date_changed (char const *uri)
/**
* go_url_encode:
- * @text: The constant text to be encoded
+ * @uri_fragment: The uri part to be encoded
* @type: 0 : mailto, 1: file or http
*
* url-encode a string according to RFC 2368.
@@ -918,38 +916,24 @@ go_file_get_date_changed (char const *uri)
* Returns: an encoded string which the caller is responsible for freeing.
**/
gchar*
-go_url_encode (gchar const *text, int type)
+go_url_encode (gchar const *uri_fragment, int type)
{
char const *good;
- static char const hex[16] = "0123456789ABCDEF";
- GString* result;
- g_return_val_if_fail (text != NULL, NULL);
- g_return_val_if_fail (*text != '\0', NULL);
+ g_return_val_if_fail (*uri_fragment != '\0', NULL);
switch (type) {
case 0: /* mailto: */
good = ".-_@";
break;
case 1: /* file: or http: */
- good = "!$&'()*+,-./:= _";
+ good = G_URI_RESERVED_CHARS_ALLOWED_IN_PATH;
break;
default:
return NULL;
}
- result = g_string_new (NULL);
- while (*text) {
- unsigned char c = *text++;
- if (g_ascii_isalnum (c) || strchr (good, c))
- g_string_append_c (result, c);
- else {
- g_string_append_c (result, '%');
- g_string_append_c (result, hex[c >> 4]);
- g_string_append_c (result, hex[c & 0xf]);
- }
- }
- return g_string_free (result, FALSE);
+ return g_uri_escape_string (uri_fragment, good, FALSE);
}
/**
diff --git a/goffice/utils/go-file.h b/goffice/utils/go-file.h
index 62fb57c..4c9236d 100644
--- a/goffice/utils/go-file.h
+++ b/goffice/utils/go-file.h
@@ -86,7 +86,7 @@ time_t go_file_get_date_changed (char const *uri);
gint go_file_access (char const *uri, gint mode);
-gchar *go_url_encode (gchar const *text, int type);
+gchar *go_url_encode (gchar const *uri, int type);
gboolean go_url_check_extension (gchar const *uri,
gchar const *std_ext,
gchar **new_uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]