Source

shlomi-fish-homepage / bin / find_ascii_quotes-xmlp.pl

Full commit
shl...@iglu.org.… 34c0e6d 







shl...@iglu.org.… 0c94a7f 
shl...@iglu.org.… 34c0e6d 












shl...@iglu.org.… 4e5b869 
shl...@iglu.org.… 34c0e6d 


Shlomi Fish 44c7eaf 


shl...@iglu.org.… 34c0e6d 









shl...@iglu.org.… 0c94a7f 







shl...@iglu.org.… 34c0e6d 
#!/usr/bin/perl

use strict;
use warnings;

use XML::Parser;

binmode STDOUT, ":encoding(utf8)";

foreach my $filename (@ARGV)
{
    my $parser = XML::Parser->new(
        Handlers => {
            Char => sub {
                my ($expat, $string) = @_;

                my @lines = split /\n/, $string, -1;

                foreach my $idx (0 .. $#lines)
                {
                    my $l = $lines[$idx];

                    if ($l =~ m{["']})
                    {
                        printf {*STDOUT}
                        (
                            "%s:%d:%s\n",
                                $filename,
                                $idx+$expat->current_line(),
                                $l
                        );
                    }
                }

                return;
            },
        },
    );

    eval {
        $parser->parsefile($filename);
    };

    if (my $err = $@)
    {
        die "Error '$err' at filename '$filename'";
    }
}