[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Command line parsing of ls with genparse
From: |
Michael Geng |
Subject: |
Re: [PATCH] Command line parsing of ls with genparse |
Date: |
Wed, 29 Aug 2007 21:34:22 +0200 |
User-agent: |
Mutt/1.5.9i |
On Tue, Aug 28, 2007 at 01:21:46PM -0700, Eric Blake-1 wrote:
>
> > 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!
>
> That seems wrong to me. Isn't it really:
>
> ls$(EXEEXT) directly depends on ls.o and ls-clp.o
> ls.o directly depends on ls.c and ls-clp.h
> ls-clp.o directly depends on ls-clp.c and ls-clp.h
> ls-clp.c directly depends on ls.gp
> ls-clp.h directly depends on ls.gp
> ls.gp directly depends on ls.c
>
> No cycle there, even though ls.c is an indirect
> dependency of ls$(EXEEXT) through more than one
> leg of the transitive closure.
You are right. I verified this and it builds properly with the
following modifications on src/Makefile.am:
--- coreutils-6.9.orig/src/Makefile.am 2007-03-20 08:24:27.000000000 +0100
+++ coreutils-6.9/src/Makefile.am 2007-08-29 21:14:29.000000000 +0200
@@ -48,7 +48,7 @@
EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
groups.sh wheel-gen.pl extract-magic c99-to-c89.diff
BUILT_SOURCES =
-CLEANFILES = $(SCRIPTS) su
+CLEANFILES = $(SCRIPTS) su *.gp *-clp.c *-clp.h
AM_CPPFLAGS = -I$(top_srcdir)/lib
@@ -185,14 +185,16 @@
__SOURCES = lbracket.c
cp_SOURCES = cp.c copy.c cp-hash.c
-dir_SOURCES = ls.c ls-dir.c
-vdir_SOURCES = ls.c ls-vdir.c
-ls_SOURCES = ls.c ls-ls.c
+dir_SOURCES = ls.c ls-dir.c ls-clp.c ls-clp.h
+vdir_SOURCES = ls.c ls-vdir.c ls-clp.c ls-clp.h
+ls_SOURCES = ls.c ls-ls.c ls-clp.c ls-clp.h
chown_SOURCES = chown.c chown-core.c
chgrp_SOURCES = chgrp.c chown-core.c
mv_SOURCES = mv.c copy.c cp-hash.c remove.c
rm_SOURCES = rm.c remove.c
+tail_SOURCES = tail.c tail-clp.c
+wc_SOURCES = wc.c wc-clp.c
md5sum_SOURCES = md5sum.c
md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
@@ -363,3 +365,14 @@
| grep -Ev -f $$t && \
{ echo 'the above variables should have static scope' 1>&2; \
exit 1; } || :
+
+ls.$(OBJEXT): ls-clp.c ls-clp.h
+tail.$(OBJEXT): ls-clp.c tail-clp.h
+wc.$(OBJEXT): ls-clp.c wc-clp.h
+
+%-clp.c %-clp.h: %.gp
+ genparse --longmembers --internationalize -o $(*F)-clp $<
+
+%.gp: %.c
+ sed -n -e '/genparse file starts here/,/genparse file ends here/p' <
$(*F).c | \
+ sed -e '/genparse file ends here/d' -n -e '2,$$p' > $@
Michael