On 19 April 2013 20:55, Glenn Fowler <[email protected]> wrote: > > this is on the todo list > > there are some internal discussions on interactions with > sfreserve() and the possibilty of supporting multiple > active sfreserve() buffers > > the idea being that if sfreserve() is mmap()ing one could > keep a chain of mmap() blocks large enough to cover a > context-sized window scrolling through the file with > data copies limited to lines that cross buffer boundaries > > there's even some thought about generalizing the > lines-crossing-buffer-boundaries code (which is always a pain > to get right and is duplicated too many places in ast code) > for some of the contiguous string api's like regnexec() > > all in the hopes of doing it the right way
grep -C works now, but have the proposed api changes be implemented? > > On Fri, 19 Apr 2013 19:05:40 +0200 Wendy Lin wrote: >> On 16 April 2013 15:04, Glenn Fowler <[email protected]> wrote: >> > >> > thanks for the report >> > the work adding -C was apparently interrupted a while back >> > its on the todo list >> > >> > this is not an easy fix for ast grep because the fast inner loop matches >> > buffers containing multiple lines and does not parse line structure until >> > a match is found >> > >> > the only time single lines are matched is when lines cross buffer >> > boundaries >> > >> > mmap()ing the entire file (topic under discussion) would make it easy but >> > would not help the very common input from pipe case >> > >> > On Tue, 16 Apr 2013 11:05:10 +0200 Wendy Lin wrote: >> >> On 13 April 2013 16:05, Wendy Lin <[email protected]> wrote: >> >> > Dear ast-devel, >> >> > >> >> > the grep -C from the latest ast-ksh (2013-04-09) does not work >> >> > compared to GNU grep 2.14 >> >> > >> >> > In GNU grep 2.14 I get this for the context option: >> >> > >> >> > seq 200 >"测试文件" >> >> > ksh -c '/usr/bin/grep --context=2 51 <"测试文件"' >> >> > 49 >> >> > 50 >> >> > 51 >> >> > 52 >> >> > 53 >> >> > -- >> >> > 149 >> >> > 150 >> >> > 151 >> >> > 152 >> >> > 153 >> >> > >> >> > But I get this from grep from ast-ksh for the context option: >> >> > >> >> > ksh -c 'builtin grep ; grep --context=2 51 <"测试文件"' >> >> > 51 >> >> > 151 >> >> > >> >> > Is this a bug or feature? >> >> > >> >> > AFAIK the -C option in ast-ksh grep should work like this: >> >> > -C 2 gives 2 lines of context before and after the match >> >> > -C ,2 gives only 2 lines of context after the match >> >> > -C 2, gives only 2 lines of contetxt before the match >> >> > >> >> > optionally AST grep should support these two long options for GNU grep >> >> > compatibility: >> >> > >> >> > --before-context=NUM print NUM lines of leading context >> >> > --after-context=NUM print NUM lines of trailing context >> >> > >> >> > What do you think? >> > >> >> Was the bug report received? >> >> > >> >> > Wendy > >> Glenn, how long will it take to get grep -C implemented? > >> Wendy > Wendy _______________________________________________ ast-developers mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-developers
