]> thyrsus.com Git - imgsizer.git/commitdiff
MCT's 1.9 patch.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 9 Mar 2001 05:52:52 +0000 (05:52 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 9 Mar 2001 05:52:52 +0000 (05:52 +0000)
imgsizer

index 4b6e38d556e0044bae9434c3da38377761fe3963..12677a320a317c588f54fb0405a2d595376d69af 100755 (executable)
--- a/imgsizer
+++ b/imgsizer
 #    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>
@@ -207,7 +215,12 @@ sub dirname
 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;
@@ -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.