We did some specs for new main loop.

I/O is slow
    print rarely,
    print late;
    read early too!
temporarily assume:
prepopulate [q{},q{}]xB
requirement:  print '--' unless first

side case: if stdout is autoflush, do so also
invariant:  match is set iff there is a match in the buffer someplace

our buffer structure is:
a print buffer and B + A + 1 entries
    (which are supposed to be line references to not copy)
and we will also include a prefix string

[[prefix(), \$_,] ... ]
struct of prefix() @TBD -- may include \$Filename as well as $., ':' or '-'.
Defer output formatting to printbuf-appender

if in_matched_context, append shift of line buf onto printbuf
else discard shift of line buf
endif

append current_line to line buf
   with prefix() struct or whatnot struct'ed with it

if the current_line matches
    we set in_matched_context =true
   and count_not_matched=0
else
    ++count_not_matched
    and if count_not_matched == B
        start print
     else
##  if(count_not_matched == (A + B + 1))
    if(count_not_matched > (A + B + 1))   ## fix off by one
             set_separator()
            in_matched_context=0; # clear_matched()
       end if
end if

###FLUSH BUFF THING -- no flush logic anymore.

we need the logic for when you shift onto the print buffer:
     if match is true, we print only iff we can start print

## DROPPED the print flag (formerly thought separate )
## also DROPPED when a+b+1, stop_print()

concern:  if we have match, match, match ...
concern:  if we have match, line, match, line, match ...
did we solve that?

if EOF (and in_matched_context) , shift everything to print buffer and print

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to