[Libguestfs] [PATCH 2/2] builder: add "[ignored]" to parsing errors for .conf files
Richard W.M. Jones
rjones at redhat.com
Tue Apr 22 16:12:44 UTC 2014
On Tue, Apr 22, 2014 at 05:41:44PM +0200, Pino Toscano wrote:
> Parsing sources .conf files is not a fatal error (that file would just
> be ignored), so explicitly state that such parsing errors are ignored.
>
> This should address the last bit in RHBZ#1077817.
> ---
> builder/sources.ml | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builder/sources.ml b/builder/sources.ml
> index e7644a2..be1c27d 100644
> --- a/builder/sources.ml
> +++ b/builder/sources.ml
> @@ -35,7 +35,7 @@ let parse_conf ~prog ~debug file =
> if debug then (
> eprintf (f_"%s: trying to read %s\n") prog file;
> );
> - let sections = Ini_reader.read_ini ~prog file in
> + let sections = Ini_reader.read_ini ~prog ~error_suffix:"[ignored]" file in
>
> let sources = List.fold_right (
> fun (n, fields) acc ->
> --
The patches are fine, and so ACK.
There is a possible problem in that the string isn't translated. (I'm
not totally clear if yyerror passes in a translated 'msg', and in any
case the fprintf doesn't call gettext, so maybe this is not relevant).
If translating the message is desirable, then possibly something like:
Ini_reader.read_init ~prog ~ignore_errors:true file
with the ~ignore_errors flag causing the string to be printed like
this:
if (! Bool_val (ignore_errorsv)) {
fprintf (stderr, _("%s%s%ssyntax error at line %d: %s\n"), ..);
} else {
fprintf (stderr, _("%s%s%ssyntax error at line %d: %s (ignored)\n"), ..);
}
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
More information about the Libguestfs
mailing list