Re: hub - r35036 - abiword/trunk/src/af/util/xp

From: Jean Bréfort <jean.brefort_at_normalesup.org>
Date: Mon Dec 01 2014 - 08:35:11 CET

Why not use go-file.[c,h] instead now that we always use goffice?

Jean

Le lundi 01 décembre 2014 à 03:43 +0100, cvs@abisource.com a écrit :
> Author: hub
> Date: 2014-12-01 03:43:21 +0100 (Mon, 01 Dec 2014)
> New Revision: 35036
>
> Modified:
> abiword/trunk/src/af/util/xp/ut_go_file.cpp
> abiword/trunk/src/af/util/xp/ut_go_file.h
> Log:
> Remove dead code.
>
> Modified: abiword/trunk/src/af/util/xp/ut_go_file.cpp
> ===================================================================
> --- abiword/trunk/src/af/util/xp/ut_go_file.cpp 2014-11-29 21:19:22 UTC (rev 35035)
> +++ abiword/trunk/src/af/util/xp/ut_go_file.cpp 2014-12-01 02:43:21 UTC (rev 35036)
> @@ -1209,56 +1209,6 @@
> return res;
> }
>
> -/* ------------------------------------------------------------------------- */
> -/* Adapted from gtkfilechooserdefault.c. Unfortunately it is static there. */
> -
> -GSList *
> -UT_go_file_split_urls (const char *data)
> -{
> - GSList *uris;
> - const char *p, *q;
> -
> - uris = NULL;
> -
> - p = data;
> -
> - /* We don't actually try to validate the URI according to RFC
> - * 2396, or even check for allowed characters - we just ignore
> - * comments and trim whitespace off the ends. We also
> - * allow LF delimination as well as the specified CRLF.
> - *
> - * We do allow comments like specified in RFC 2483.
> - */
> - while (p)
> - {
> - if (*p != '#')
> - {
> - while (g_ascii_isspace (*p))
> - p++;
> -
> - q = p;
> - while (*q && (*q != '\n') && (*q != '\r'))
> - q++;
> -
> - if (q > p)
> - {
> - q--;
> - while (q > p && g_ascii_isspace (*q))
> - q--;
> -
> - if (q > p)
> - uris = g_slist_prepend (uris, g_strndup (p, q - p + 1));
> - }
> - }
> - p = strchr (p, '\n');
> - if (p)
> - p++;
> - }
> -
> - uris = g_slist_reverse (uris);
> - return uris;
> -}
> -
> gboolean
> UT_go_file_exists (char const *uri)
> {
> @@ -1543,48 +1493,6 @@
> #endif
> }
>
> -/**
> - * UT_go_url_check_extension
> - * @uri : Uri
> - * @std_ext : Standard extension for the content type
> - * @new_uri : New uri
> - *
> - * Modifies given @uri by adding the extension @std_ext if needed.
> - * If no @std_ext is given or @uri already has some extension,
> - * it just copies @uri.
> - *
> - * Value in new_uri: newly allocated string which you should g_free after
> - * use, containing (optionally) modified uri.
> - *
> - * Return Value: FALSE if the uri has an extension not matching @std_ext
> - */
> -gboolean
> -UT_go_url_check_extension (gchar const *uri,
> - gchar const *std_ext,
> - gchar **new_uri)
> -{
> - gchar *base;
> - gchar *user_ext;
> - gboolean res;
> -
> - g_return_val_if_fail (uri != NULL, FALSE);
> - g_return_val_if_fail (new_uri != NULL, FALSE);
> -
> - res = TRUE;
> - base = g_path_get_basename (uri);
> - user_ext = strrchr (base, '.');
> - if (std_ext != NULL && strlen (std_ext) > 0 && user_ext == NULL)
> - *new_uri = g_strconcat (uri, ".", std_ext, NULL);
> - else {
> - if (user_ext != NULL && std_ext != NULL)
> - res = !UT_go_utf8_collate_casefold (user_ext + 1, std_ext);
> - *new_uri = g_strdup (uri);
> - }
> - g_free (base);
> -
> - return res;
> -}
> -
> gchar *
> UT_go_get_mime_type (gchar const *uri)
> {
> @@ -1601,195 +1509,9 @@
> return g_strdup ("application/octet-stream");
> }
>
> -gchar
> -*UT_go_get_mime_type_for_data (gconstpointer data, int data_size)
> -{
> -#if 0 /* defined G_OS_WIN32 */
> - LPWSTR mime_type;
> -
> - if (FindMimeFromData (NULL, NULL, (LPVOID)data, (DWORD)data_size, NULL, 0, &mime_type, 0) == NOERROR)
> - {
> - return g_utf16_to_utf8 (mime_type, -1, NULL, NULL, NULL);
> - }
> -
> - /* We try to determine mime using FindMimeFromData().
> - * However, we are not sure whether the functions will know about
> - * the necessary mime types. In the worst wase we fall back to
> - * "text/plain"
> - */
> - return g_strdup ("text/plain");
> -#else
> - UT_UNUSED(data);
> - UT_UNUSED(data_size);
> - return g_strdup ("application/octet-stream");
> -#endif
> -}
> -
> -gchar const
> -*UT_go_mime_type_get_description (gchar const *mime_type)
> -{
> - return mime_type;
> -}
> -
> /* ------------------------------------------------------------------------- */
>
> -#ifdef G_OS_WIN32
> -static gchar **saved_args;
> -static int saved_argc;
> -#endif
>
> -gchar const **
> -UT_go_shell_argv_to_glib_encoding (gint argc, gchar const **argv)
> -{
> -#ifdef G_OS_WIN32
> - gchar **args;
> - gint i;
> -
> - args = g_new (gchar *, argc);
> - if (G_WIN32_IS_NT_BASED ())
> - {
> - LPWSTR *wargs;
> - gint narg;
> - GIConv conv;
> -
> - wargs = CommandLineToArgvW (GetCommandLineW (), &narg);
> - conv = g_iconv_open ("utf-8", "utf-16le");
> - for (i = 0; i < narg; ++i)
> - args[i] = g_convert_with_iconv ((const gchar *) wargs[i], wcslen (wargs[i]) << 1, conv, NULL, NULL, NULL);
> - g_iconv_close (conv);
> - }
> - else
> - {
> - for (i = 0; i < argc; ++i)
> - args[i] = g_locale_to_utf8 (argv[i], -1, NULL, NULL, NULL);
> - }
> -
> - saved_args = args;
> - saved_argc = argc;
> -
> - return (gchar const **) args;
> -#else
> - UT_UNUSED(argc);
> - return argv;
> -#endif
> -}
> -
> -void
> -UT_go_shell_argv_to_glib_encoding_free (void)
> -{
> -#ifdef G_OS_WIN32
> - if (saved_args) {
> - gint i;
> -
> - for (i = 0; i < saved_argc; ++i)
> - g_free (saved_args[i]);
> - g_free (saved_args);
> - }
> -#endif
> -}
> -
> -/*
> - * go-glib-extras.c: Various utility routines that should have been in glib.
> - *
> - * Authors:
> - * Miguel de Icaza (miguel@gnu.org)
> - * Jukka-Pekka Iivonen (iivonen@iki.fi)
> - * Zbigniew Chyla (cyba@gnome.pl)
> - * Morten Welinder (terra@gnome.org)
> - */
> -
> -const char *
> -UT_go_guess_encoding (const char *raw, size_t len, const char *user_guess,
> - char **utf8_str)
> -{
> - int try_nb;
> - gboolean debug = FALSE;
> -
> - g_return_val_if_fail (raw != NULL, NULL);
> -
> - for (try_nb = 1; 1; try_nb++) {
> - const char *guess;
> - GError *error = NULL;
> - char *utf8_data;
> -
> - switch (try_nb) {
> - case 1: guess = user_guess; break;
> - case 2: g_get_charset (&guess); break;
> - case 3: {
> - xmlCharEncoding enc =
> - xmlDetectCharEncoding ((const unsigned char*)raw, len);
> - switch (enc) {
> - case XML_CHAR_ENCODING_ERROR:
> - case XML_CHAR_ENCODING_NONE:
> - break;
> - case XML_CHAR_ENCODING_UTF16LE:
> - /* Default would give "UTF-16". */
> - guess = "UTF-16LE";
> - break;
> - case XML_CHAR_ENCODING_UTF16BE:
> - /* Default would give "UTF-16". */
> - guess = "UTF-16BE";
> - break;
> - default:
> - guess = xmlGetCharEncodingName (enc);
> - }
> - break;
> - }
> - case 4: guess = "ASCII"; break;
> - case 5: guess = "ISO-8859-1"; break;
> - case 6: guess = "UTF-8"; break;
> - default: return NULL;
> - }
> -
> - if (!guess)
> - continue;
> -
> - if (debug)
> - g_print ("Trying %s as encoding.\n", guess);
> -
> - utf8_data = g_convert (raw, len, "UTF-8", guess,
> - NULL, NULL, &error);
> - if (!error) {
> - if (debug)
> - g_print ("Guessed %s as encoding.\n", guess);
> - if (utf8_str)
> - *utf8_str = utf8_data;
> - else
> - g_free (utf8_data);
> - return guess;
> - }
> -
> - g_error_free (error);
> - }
> -}
> -
> -/**
> - * UT_go_get_real_name :
> - *
> - * Return a utf8 encoded string with the current user name.
> - * Caller should _NOT_ g_free the result.
> - **/
> -char const *
> -UT_go_get_real_name (void)
> -{
> - /* We will leak this. */
> - static char *UT_go_real_name = NULL;
> -
> - if (UT_go_real_name == NULL) {
> - char const *name = getenv ("NAME");
> - if (name == NULL)
> - name = g_get_real_name ();
> - if (name == NULL)
> - name = g_get_user_name ();
> - if (name != NULL)
> - (void) UT_go_guess_encoding (name, strlen (name),
> - NULL, &UT_go_real_name);
> - else
> - UT_go_real_name = (char *)"unknown";
> - }
> - return UT_go_real_name;
> -}
> -
> gint
> UT_go_utf8_collate_casefold (const char *a, const char *b)
> {
>
> Modified: abiword/trunk/src/af/util/xp/ut_go_file.h
> ===================================================================
> --- abiword/trunk/src/af/util/xp/ut_go_file.h 2014-11-29 21:19:22 UTC (rev 35035)
> +++ abiword/trunk/src/af/util/xp/ut_go_file.h 2014-12-01 02:43:21 UTC (rev 35036)
> @@ -73,12 +73,9 @@
> ABI_EXPORT char *UT_go_basename_from_uri (const char *uri);
> ABI_EXPORT char *UT_go_dirname_from_uri (const char *uri, gboolean brief);
> ABI_EXPORT gboolean UT_go_directory_create (char const *uri, int mode, GError **err);
> -ABI_EXPORT gchar const **UT_go_shell_argv_to_glib_encoding (gint argc, gchar const **argv);
> -ABI_EXPORT void UT_go_shell_argv_to_glib_encoding_free (void);
>
> ABI_EXPORT GsfInput *UT_go_file_open (char const *uri, GError **err);
> ABI_EXPORT GsfOutput *UT_go_file_create (char const *uri, GError **err);
> -ABI_EXPORT GSList *UT_go_file_split_urls (char const *data);
>
> ABI_EXPORT gboolean UT_go_file_remove (char const *uri, GError **err);
>
> @@ -92,15 +89,8 @@
> ABI_EXPORT time_t UT_go_file_get_date_changed (char const *uri);
>
> ABI_EXPORT GError *UT_go_url_show (gchar const *url);
> -ABI_EXPORT gboolean UT_go_url_check_extension (gchar const *uri,
> - gchar const *std_ext,
> - gchar **new_uri);
> ABI_EXPORT gchar *UT_go_get_mime_type (gchar const *uri);
> -ABI_EXPORT gchar *UT_go_get_mime_type_for_data (gconstpointer data, int data_size);
> -ABI_EXPORT gchar const *UT_go_mime_type_get_description (gchar const *mime_type);
>
> -ABI_EXPORT const char * UT_go_guess_encoding (const char *raw, size_t len, const char *user_guess, char **utf8_str);
> -ABI_EXPORT char const * UT_go_get_real_name (void);
> ABI_EXPORT gint UT_go_utf8_collate_casefold (const char *a, const char *b);
>
> G_END_DECLS
>
> -----------------------------------------------
> To unsubscribe from this list, send a message to
> abisource-cvs-commit-request@abisource.com with the word
> unsubscribe in the message body.
Received on Mon Dec 1 08:35:22 2014

This archive was generated by hypermail 2.1.8 : Mon Dec 01 2014 - 08:35:22 CET