cons-discuss
[Top][All Lists]
Advanced

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

scanner bug (was: cons 2.1.2 issues)


From: Brad Garcia
Subject: scanner bug (was: cons 2.1.2 issues)
Date: Fri, 3 Nov 2000 07:22:26 -0500 (EST)

On Thu, 2 Nov 2000, Zachary Deretsky wrote:

> > Notice that within the scanner function itself, you can read multiple
> > lines.  You could read the entire file, in which case the 
> > scanner would be called only once per file.
> 
> This is NOT the case.

It works for me.

Your scanner looks ok to me too.  And I looked at scan::quickscan::scan
in cons, and it seems to be fine.

So the relevant function fragment within cons is:

sub scan {
    my($self, $file) = @_;
    my($code) = $self->{code};
    my(@includes);
    # File should have been built by now. If not, we'll ignore it.
    return () unless open(SCAN, $file->rpath);
    while(<SCAN>) {
        push(@includes, grep($_ ne '', &$code));
    }
    close(SCAN);
    ...

Where $code is the name of your scanner.  This seems pretty
straightforward.  Open a file, do a while loop over the contents,
calling $code for each line, then close it.  The grep just removes
any blank entries that are returned.

And within your function, you appear to be looping over the contents
(using a "do while" loop, so that you don't miss the first line which
was already read in by scan::quickscan::scan).  But your loop appears
to not be working.  Yet, when I try your code, it seems to work fine
for me.

Question for the perl experts: when was the "do while" loop added to
perl?  I cannot find any documentation for a "do while" loop.  I'm
wondering if Zach has an older version of perl which doesn't understand
it.

In the perl documentation, there is a "do" command which takes a block
argument.  All it does is run through the code in its argument ONCE.
This could explain why his array has at most one value.

If this happens, then I would expect the "while <SCAN> ;" statement to
give a syntax error.  And if SCAN is still getting closed, I wouldn't
expect cons to call this function more than once for each file.  So I'm
still confused by this behavior.

Zach, can you add some more "print" lines to your function and try
again?  In particular, place a counter inside your do loop and print
out the value of that counter at the end.

Brad Garcia






reply via email to

[Prev in Thread] Current Thread [Next in Thread]