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

Bug#579557: XFig.pm: incorrect sample code in documentation, $fig->{'object'} is not numeric

Package: fig2sty
Version: 1:0.1-12
Severity: minor

POD of Xfig.pm writes in the synopsys:

 # Parse a Fig file

 die "Can't read file $figname" if ($fig->{'object'} < 0);

However $fig->{'object'} is numeric (i.e. -1) in case of error only.
Otherwise it may be one of 'color', 'ellipse', 'polyline', 'spline',
'text', 'arc' or 'compund'.

Unfortunately usage the above example code produces a warning
if parsefile() method is executed succesfully and Perl runs with
warnings enabled. It is like this:

 Argument "compound" isn't numeric in numeric lt (<) at ...

Returning undef in case of error would be much more perlish
but there is no way to change the return value of -1 without
breaking existing programs.

A new error indicator is required,
or at least the documentation should be fixed somehow e.g.

 die "Can't read file $figname" if $fig->{'object'} !~ /^\w+$/;


-- System Information:
Debian Release: 5.0.4
  APT prefers stable
  APT policy: (700, 'stable'), (500, 'proposed-updates')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/bash

Versions of packages fig2sty depends on:
ii  perl                     5.10.0-19lenny2 Larry Wall's Practical Extraction 

fig2sty recommends no packages.

fig2sty suggests no packages.

-- debconf-show failed

Reply to: