From: Eric S. Raymond Date: Fri, 9 Mar 2001 05:52:52 +0000 (+0000) Subject: MCT's 1.9 patch. X-Git-Tag: 1.9 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=9ca0142105483c0f56fcafafcffc980ff848c825;p=imgsizer.git MCT's 1.9 patch. --- diff --git a/imgsizer b/imgsizer index 4b6e38d..12677a3 100755 --- a/imgsizer +++ b/imgsizer @@ -24,22 +24,30 @@ # to determine the image size instead of identify(1) from the # ImageMagick suite. # -# Modified by Michael C. Toren 18 Aug 2000; +# Modified by Michael C. Toren 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 19 Aug 2000; +# Modified by Michael C. Toren 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 23 Feb 2001 +# +# Fixed two bugs reported by Jeroen Valcke , 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 = < @@ -207,7 +215,12 @@ sub dirname sub sizefix # Apply attrfix to the attributes in each image tag { + local $line = 1; + while () { + + $line += scalar @{[ /[\n\r]/g ]}; + if (/(/is) { print $`; print $1; $tag = $2; @@ -222,10 +235,9 @@ sub sizefix 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 { @@ -250,7 +262,7 @@ sub attrfix 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.