Re: [PATCH] i18n/l10n of gvfs-cat

On Thu, 2008-01-10 at 14:15 +0100, Luca Ferretti wrote:

> Index: programs/gvfs-cat.c
> ===================================================================
> --- programs/gvfs-cat.c	(revisione 1087)
> +++ programs/gvfs-cat.c	(copia locale)
> @@ -28,10 +28,14 @@
>  #include <errno.h>
>  #include <glib.h>
> +#include <glib/gi18n.h>
>  #include <gio/gio.h>
> +static gchar **locations = NULL;
> +
>  static GOptionEntry entries[] = 
>  {
> +	{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &locations, "locations", NULL},
>  	{ NULL }
>  };
>         Added a "locations" option entry. Note that gvfs-cat don't use
>         any command line option, this is useful below to check if you
>         are providing a location to cat an print a warning message.
>         Note also that, from Glib API refs: "Using G_OPTION_REMAINING
>         instead of simply scanning argv for leftover arguments has the
>         advantage that GOption takes care of necessary encoding
>         conversions for strings or filenames." See below for this too.

It looks like what G_OPTION_ARG_FILENAME does is convert from locale to
utf8 on windows and just strcpy on unix, while ARG_STRING always
converts from locale to utf8. So, using string here is wrong, and
FILENAME is ok also for uris (as they are ascii-only).

> A final note about error messages: currently gvfs-cat prints something
> like:
>         $ gvfs-cat smb://server/file.txt
>         Error opening file: No such file or directory
> IMHO could be better prepend the program name and the file name (this is
> the behavior of plain cat(1)) 
>         $ gvfs-cat smb://server/file.txt
>         gvfs-cat: smb://server/file.txt: No such file or directory

Yeah, that looks better.

> PS of course could be interesting add some cat(1) options, such as -n
> (number all output lines), -E (display $ at end of each line), -T
> (display TAB characters as ^I) and -s (never more than one single blank
> line). OK to open a bug and add commented GOptionExtry copying switch
> and comments from `cat --help`?

Well. You could also just pipe through cat if you need these?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]