[Top][All Lists]

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

[PATCH] Command line parsing of ls with genparse

From: Michael Geng
Subject: [PATCH] Command line parsing of ls with genparse
Date: Tue, 28 Aug 2007 19:22:24 +0200
User-agent: Mutt/1.5.9i

Hi Jim, hello mailing list,

attached is a patch which generates command line parsers for the 
ls, tail and wc commands with genparse. You need the latest
Genparse version (0.6.9) if you want to compile it yourself.
You can download this version, see the updated manual or have
a look at the generated parser files for the ls, tail or wc 
commands from http://genparse.sourceforge.net/.

I also embedded the genparse file as a comment into the C code,
as you suggested in a previous mail, Jim. The Genparse file 
ls.gp for example is embedded at the bottom of ls.c. I added 
appropriate commands to Makefile.am so that these files get
extracted automatically. Unfortunately there are 2 problems 
with that:

1. The usage function for the ls command has the following 
   explanation for the -F, --classify command liune switch:
   "append indicator (one of */=>@|) to entries". Unfortunately
   it contains "*/" which closes the comment. That's a problem
   because we want to embed the Genparse file as a comment,
   so "*/" and "/*" is making problems now. That appears as a 
   minor problem to me however.

2. ls.c depends ls-clp.h (the generated parser)
   ls-clp.h depends on ls.gp (the genparse file)
   ls.gp depends on ls.c because ls.gp is embedded as a comment in ls.c
   -> There is a circular dependency!

There was another problem with the ls command: It has the following
parameters listed in the usage function:

      --indicator-style=WORD  append indicator with style WORD to entry 
                               none (default), slash (-p),\n\
                               file-type (--file-type), classify (-F)\n\


  -p, --indicator-style=slash\n\
                             append / indicator to directories\n\

I changed the latter to 

  -p                         like --indicator-style=slash
                               append / indicator to directories

because in the original version genparse would have difficulties
with a duplicate parameter --indicator-style. Note that this is
only a problem with the comments, the behavior did not change.


Attachment: genparse-ls-tail-wc.patch
Description: Text document

reply via email to

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