Re: hub - r35036 - abiword/trunk/src/af/util/xp
Jean Bréfort <[email protected]> Mon, 01 Dec 2014 08:35:11 +0100
| Newsgroups | gmane.editors.abiword.devel |
|---|---|
| Message-ID | <[email protected]> |
Why not use go-file.[c,h] instead now that we always use goffice? Jean Le lundi 01 d=C3=A9cembre 2014 =C3=A0 03:43 +0100, [email protected] a =C3= =A9crit : > Author: hub > Date: 2014-12-01 03:43:21 +0100 (Mon, 01 Dec 2014) > New Revision: 35036 >=20 > 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. >=20 > Modified: abiword/trunk/src/af/util/xp/ut_go_file.cpp > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- 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; > } > =20 > -/* -------------------------------------------------------------------= ------ */ > -/* Adapted from gtkfilechooserdefault.c. Unfortunately it is static t= here. */ > - > -GSList * > -UT_go_file_split_urls (const char *data) > -{ > - GSList *uris; > - const char *p, *q; > - > - uris =3D NULL; > - > - p =3D 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 !=3D '#') > - { > - while (g_ascii_isspace (*p)) > - p++; > - > - q =3D p; > - while (*q && (*q !=3D '\n') && (*q !=3D '\r')) > - q++; > - > - if (q > p) > - { > - q--; > - while (q > p && g_ascii_isspace (*q)) > - q--; > - > - if (q > p) > - uris =3D g_slist_prepend (uris, g_strndup (p, q - p + 1)); > - } > - } > - p =3D strchr (p, '\n'); > - if (p) > - p++; > - } > - > - uris =3D g_slist_reverse (uris); > - return uris; > -} > - > gboolean > UT_go_file_exists (char const *uri) > { > @@ -1543,48 +1493,6 @@ > #endif > } > =20 > -/** > - * 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 a= fter > - * 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 !=3D NULL, FALSE); > - g_return_val_if_fail (new_uri !=3D NULL, FALSE); > - > - res =3D TRUE; > - base =3D g_path_get_basename (uri); > - user_ext =3D strrchr (base, '.'); > - if (std_ext !=3D NULL && strlen (std_ext) > 0 && user_ext =3D=3D NULL= ) > - *new_uri =3D g_strconcat (uri, ".", std_ext, NULL); > - else { > - if (user_ext !=3D NULL && std_ext !=3D NULL) > - res =3D !UT_go_utf8_collate_casefold (user_ext + 1, std_ext); > - *new_uri =3D 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"); > } > =20 > -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, NUL= L, 0, &mime_type, 0) =3D=3D 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; > -} > - > /* -------------------------------------------------------------------= ------ */ > =20 > -#ifdef G_OS_WIN32 > -static gchar **saved_args; > -static int saved_argc; > -#endif > =20 > -gchar const ** > -UT_go_shell_argv_to_glib_encoding (gint argc, gchar const **argv) > -{ > -#ifdef G_OS_WIN32 > - gchar **args; > - gint i; > - > - args =3D g_new (gchar *, argc); > - if (G_WIN32_IS_NT_BASED ()) > - { > - LPWSTR *wargs; > - gint narg; > - GIConv conv; > - > - wargs =3D CommandLineToArgvW (GetCommandLineW (), &narg); > - conv =3D g_iconv_open ("utf-8", "utf-16le"); > - for (i =3D 0; i < narg; ++i) > - args[i] =3D g_convert_with_iconv ((const gchar *) wargs[i], wcslen = (wargs[i]) << 1, conv, NULL, NULL, NULL); > - g_iconv_close (conv); > - } > - else > - { > - for (i =3D 0; i < argc; ++i) > - args[i] =3D g_locale_to_utf8 (argv[i], -1, NULL, NULL, NULL); > - } > - > - saved_args =3D args; > - saved_argc =3D 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 =3D 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 i= n glib. > - * > - * Authors: > - * Miguel de Icaza ([email protected]) > - * Jukka-Pekka Iivonen ([email protected]) > - * Zbigniew Chyla ([email protected]) > - * Morten Welinder ([email protected]) > - */ > - > -const char * > -UT_go_guess_encoding (const char *raw, size_t len, const char *user_gu= ess, > - char **utf8_str) > -{ > - int try_nb; > - gboolean debug =3D FALSE; > - > - g_return_val_if_fail (raw !=3D NULL, NULL); > - > - for (try_nb =3D 1; 1; try_nb++) { > - const char *guess; > - GError *error =3D NULL; > - char *utf8_data; > - > - switch (try_nb) { > - case 1: guess =3D user_guess; break; > - case 2: g_get_charset (&guess); break; > - case 3: { > - xmlCharEncoding enc =3D > - 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 =3D "UTF-16LE"; > - break; > - case XML_CHAR_ENCODING_UTF16BE: > - /* Default would give "UTF-16". */ > - guess =3D "UTF-16BE"; > - break; > - default: > - guess =3D xmlGetCharEncodingName (enc); > - } > - break; > - } > - case 4: guess =3D "ASCII"; break; > - case 5: guess =3D "ISO-8859-1"; break; > - case 6: guess =3D "UTF-8"; break; > - default: return NULL; > - } > - > - if (!guess) > - continue; > - > - if (debug) > - g_print ("Trying %s as encoding.\n", guess); > - > - utf8_data =3D 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 =3D 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 =3D NULL; > - > - if (UT_go_real_name =3D=3D NULL) { > - char const *name =3D getenv ("NAME"); > - if (name =3D=3D NULL) > - name =3D g_get_real_name (); > - if (name =3D=3D NULL) > - name =3D g_get_user_name (); > - if (name !=3D NULL) > - (void) UT_go_guess_encoding (name, strlen (name), > - NULL, &UT_go_real_name); > - else > - UT_go_real_name =3D (char *)"unknown"; > - } > - return UT_go_real_name; > -} > - > gint > UT_go_utf8_collate_casefold (const char *a, const char *b) > { >=20 > Modified: abiword/trunk/src/af/util/xp/ut_go_file.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- 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 bri= ef); > 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); > =20 > 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); > =20 > ABI_EXPORT gboolean UT_go_file_remove (char const *uri, GError **err); > =20 > @@ -92,15 +89,8 @@ > ABI_EXPORT time_t UT_go_file_get_date_changed (char const *uri); > =20 > 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, in= t data_size); > -ABI_EXPORT gchar const *UT_go_mime_type_get_description (gchar const *= mime_type); > =20 > -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); > =20 > G_END_DECLS >=20 > ----------------------------------------------- > To unsubscribe from this list, send a message to > [email protected] with the word > unsubscribe in the message body.