# to determine the image size instead of identify(1) from the
# ImageMagick suite.
#
-# Modified by Michael C. Toren <michael@toren.net> 18 Aug 2000;
+# Modified by Michael C. Toren <michael@toren.net> 18 Aug 2000
#
# Fixed bug where the SRC attribute's value needed to be in quotes,
# improved command line parsing (but it could still use some work),
# added -q switch to omit quotes when generating tags, and -l switch
# to generate lowercase tags. -mct
#
-# Modified by Michael C. Toren <michael@toren.net> 19 Aug 2000;
+# Modified by Michael C. Toren <michael@toren.net> 19 Aug 2000
#
# Improved the command line parsing some more, now looks for additional
-# arguments via an IMGSIZER envrionmental variable, added the -d switch
+# arguments via an IMGSIZER environmental variable, added the -d switch
# to set the DocumentRoot, -v switch to display version information,
# and -h switch to display usage information. -mct
#
+# Modified by Michael C. Toren <michael@toren.net> 23 Feb 2001
+#
+# Fixed two bugs reported by Jeroen Valcke <jeroen@valcke.com>, one
+# where the -d switch did not function properly if the img src attribute
+# was quoted, and another where the &error sub was incorrectly reporting
+# the line number an error occurred due to the input record separator
+# being set to ">".
+#
-$version = "1.8, 30 Aug 2000";
+$version = "1.9, 23 Feb 2001";
$splash = <<EOT;
imgsizer version $version, Eric S. Raymond <esr\@thyrsus.com>
sub sizefix
# Apply attrfix to the attributes in each image tag
{
+ local $line = 1;
+
while (<STDIN>) {
+
+ $line += scalar @{[ /[\n\r]/g ]};
+
if (/(<IMG\s+)(.*)>/is) {
print $`; print $1;
$tag = $2;
sub error
{
- print STDERR "\"${file}\", line $.: $_[0]\n";
+ print STDERR "\"$file\", line $line: $_[0]\n";
}
-
sub attrfix
# fix up a space-separated sequence of image attributes
{
return $attribs;
}
}
- elsif ($url =~ m!^/!) {
+ elsif ($url =~ m!^"?/!) {
$image = $root . $url; # This catches local files that are in
# virtual root, assuming we're called
# from /var/www or equivalent.