[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-grep] restructure patch for review
From: |
Claudio Fontana |
Subject: |
[bug-grep] restructure patch for review |
Date: |
Mon, 7 Mar 2005 00:54:25 +0100 (CET) |
Hello,
I would like to show you this patch,
whose aim is to begin to make grep more maintenable
for the future.
* main() function has been drastically cut, with all
options related data and functions moved to grepopt.c
and grepopt.h . Other functionalities that were
formerly blobbed in main() have now a nicely named
function (get_program_name ..)
* I have written support for prioritizing action
options in grep. This means that it's easier to deal
with current and future posix constraints ('-q > -l,
-l > ...'). It's a simple mask, where low value
actions have more priority. See grepopt.c, grepopt.h
* the chaotic grep recursion has been restructured
following Stepan's design (grep_parameter, grep_stdin,
grep_fd, grep_dir). A lot of duplicated code removed,
and a lot of function exit points have been collapsed
into one. Things can be further improved here.
* dosbuf.c is not brutally included in grep.c anymore,
it now exposes a clean interface to grep.c using
dosbuf.h.
* prline madness has been addressed, with one small
function and one auxiliary function called only for
partial line printing, named prline_part().
* search.c translation table for kwsinit() is now
built once and for all before compiling any regex.
This avoids the need to loop each time in kwsinit().
* Gcompile and Ecompile functionality has been merged.
They now call EGcompile_aux with an additional syntax
parameter, where only the base syntax (RE_SYNTAX_GREP,
RE_SYNTAX_POSIX_EGREP, RE_SYNTAX_AWK...) must be
specified. A lot of duplication was thus removed.
When doing these changes I found myself in a specific
area where existing patches were available.
I included the changes for RE_ICASE in
lib/posix/regex.h also available in the redhat
2.5.1-oi patch,
http://cvs.fedora.redhat.com/viewcvs/devel/grep/grep-2.5.1-oi.patch
This was inevitable to be able to decently restructure
Gcompile, Ecompile and prline without breaking
correctness.
Idea for further work: in my opinion the recursion can
be cleaned much more, and all functions modifying the
global options regarding grep state (buffering,
descriptor, current file name, etc) should document
their behaviour (with a small comment). I would also
advocate wrapping all those global variables in a
struct in grep.c, namely struct grep_state s;
I tested the patch to my best. I am not very familiar
with the procedure, however here it is.
http://cmdftp.sourceforge.net/grep-restructure.patch
Built using diff -Naur, so apply using -p1
Claudio
___________________________________
Nuovo Yahoo! Messenger: E' molto più divertente: Audibles, Avatar, Webcam,
Giochi, Rubrica
Scaricalo ora!
http://it.messenger.yahoo.it
- [bug-grep] restructure patch for review,
Claudio Fontana <=
- Re: restructure patch for review [bug-grep], Charles Levert, 2005/03/07
- Re: restructure patch for review [bug-grep], Claudio Fontana, 2005/03/07
- Re: restructure patch for review [bug-grep], Charles Levert, 2005/03/07
- Re: restructure patch for review [bug-grep], Claudio Fontana, 2005/03/07
- Re: restructure patch for review [bug-grep], Charles Levert, 2005/03/07
- Re: restructure patch for review [bug-grep], Claudio Fontana, 2005/03/07
- Re: restructure patch for review [bug-grep], Tim Waugh, 2005/03/08
- Re: restructure patch for review [bug-grep], Stepan Kasal, 2005/03/08
[bug-grep] Plan for grep, Stepan Kasal, 2005/03/08