bug-gnulib
[Top][All Lists]
Advanced

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

Re: filenames in error messages


From: Jim Meyering
Subject: Re: filenames in error messages
Date: Thu, 07 Feb 2008 09:49:18 +0100

Eric Blake <address@hidden> wrote:
...
> resulting quoted buffer).  Sure, you can use quotearg_buffer or
> quotearg_alloc, but then you have to manage the string yourself, whereas
> it would be kind of nice being able to do
> ~ error (...,"%s", quotearg_n_style_mem (n, shell_quoting_style, str, len))

I agree.

> Is there any reason that shortcuts like quotearg_style_mem are not
> defined, in contrast with quotearg_style(s,a) short for
> quotearg_n_style(0,s,a)?

I suspect no one noticed.

> I also noticed that once you call quotearg_colon, all future calls to
> quotearg() will behave as though they were quotearg_colon unless you
> manually call set_char_quoting(NULL,':',0).  In other words,
> quotearg_colon does not remember nor restore the prior state of the colon
> character in the default quoting options.

Sounds like a bug.

> One thing I like about the "shell" quoting style is that its use of quotes
> is dependent on the contents - in the common case, where nothing needs
> quoting, the input can be reused as the output.  Along the lines of the
> problem at hand, I wonder if the GNU Coding Standards should use a style
> like the following:
>
> If the file name comes from the portable set ([-_a-zA-Z0-9./], and
> probably a few others like + that are not required by POSIX), then
> messages relative to a file can look like:
>
> program:file:line: message
>
> If the file name contains problematic characters (including the : in a
> URL, or non-printable characters), then the file name is surrounded in
> quotes, and uses C escapes for the problematic characters:
>
> program:"embedded colon:, quote\", and spaces":line: message
> program:"http://example.com/file":line: message

That sounds fine.

> Should I go ahead and hack on a new quoting style in quotearg.c that can
> be used in this manner, adding "" around the string only if an escape
> sequence or quote_these_too character is encountered?

Please do.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]