bug-coreutils
[Top][All Lists]
Advanced

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

Command line parsing of ls with genparse: inline code


From: Michael Geng
Subject: Command line parsing of ls with genparse: inline code
Date: Sat, 19 Jan 2008 18:16:00 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hi,

when I posted a patch around Christmas which showed how genparse 
could generate the parser code for the ping command of the inetutils
Alfred Szmidt replied that in that example there are 2 loops (see
http://lists.gnu.org/archive/html/bug-inetutils/2007-12/msg00007.html):

1. The switch statement which sets the arg_t struct with the 
   results of getopt_long in ping-clp.c

2. A list of if-clauses which sets the already existing variables
   in ping.c from the arg_t struct

I now released a new version of genparse (0.7.6) which allows to put
the generated parser code inline of existing code, replacing almost
exactly the existing C code. This version has 2 extensions:

1. A __CODE__(statements) directive which allows to let the user define 
   the code which is executed in the switch statement which evaluates
   the results of getopt_long.

2. A global directive #no_struct. If specified in the genparse file 
   then no arg_t struct struct is generated. 

I uploaded a patch which shows how this works for the ls command of 
the coreutils. It transforms ls.c.in which has the genparse file inline
into ls.c which has almost exactly the same command line parser code 
inline as the present version of ls.c. The patch is targeted to today's 
git version of the coreutils. I verified that it passes make distcheck.

Please use the following links:

patch:   
http://genparse.sourceforge.net/coreutils/genparse-ls-inline-git-01-19-2008.patch
ls.c.in: http://genparse.sourceforge.net/coreutils/ls.c.in (included in the 
patch)
ls.c     http://genparse.sourceforge.net/coreutils/ls.c    (included in the 
patch)

How do you think about it?

Michael




reply via email to

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