we will not be taking this patch because the next beta will have
PATH-based mechanisms for accessing builtins from plugin libraries other than 
-lcmd

this will allow script testers to access builtins from -lcmdtst by modifying 
PATH
in a way equivalent to how script testers would access new binaries by 
modifying PATH

I mentioned this before but I'll repeat for emphasis
while we think the grep and xargs builtins are correct
they are still beta
and given that builtins have full access to all ksh resources
even an otherwise innoccuous bug not detected in the standalone grep
could wreak havoc in ksh from builtin grep
30+ years of writing standalone apps numbs one to the amount of cruft _exit() 
takes care of
and we should all be a bit skeptical since dgk and I are using experience with 
-lcmdtst(grep,xargs)
to update the documents on how to code ksh builtins

now to the nmake question

look at src/cmd/ksh93/Makefile: you'll notice the SHOPT_* vars are defined 
using == assignments
this makes SHOPT_* "state variables"

the "%.o : %.c" metarule (in $INSTALLROOT/lib/make/Makerules.mk) is set up to 
expand
in CCFLAGS any state vars referenced by the %.c file into properly quoted 
-Dvar=value

if CCFLAGS is expanded outside of a metarule scope no state variables will be 
expanded

a similar mechanism expands only those -I options corresponding to header files 
actually
included by the %.c

so, given
        SHOPT_EXTRA_BUILTINS == 1
this test in the global makfile scope will always fail
        if CCFLAGS == "*SHOPT_EXTRA_BUILTINS=1*"

you would need to define SHOPT_EXTRA_BUILTINS the same in 2 different makefiles
this is a situation we try to avoid because normal day-today building
does not use "bin/package make", and putting something like SHOPT_EXTRA_BUILTINS
on the command line could (and most likely would) lead to separate builds
with different SHOPT_EXTRA_BUILTINS settings

if you really want to do this then the libcmd makefile already has provisions 
for
allowing ksh to enable all -lcmd builtins in the ksh93 build

limit the SHOPT_EXTRA_BUILTINS logic to the libcmd makefile
cmdlist.h will contain
        CMDLIST(foo)
for each b_foo() built in libcmd.a

then in the ksh93 makefile enable
        SHOPT_CMDLIB_HDR == 1
and data/builtins.h will #include <cmdlist.h> with CMDLIST() defined to
initialize the builtin table

finally we can compare the coordinated build changes to src/lib/libcmd and 
src/cmd/ksh93
to the changes required by src/cmd/kshlib/cmdtst:
all cmdtst changes are localized to src/cmd/kshlib/cmdtst

the main difference from the user perspective is that the cmdtst user will need 
to
set up sibling bin and lib directories and add the bin dir to PATH before any
other bin dir that contains grep or the other -lcmdtst builtins

        bin/.paths
                BUILTIN_LIB=cmdtst
                LD_LIBRARY_PATH=../lib
        lib/cmdtst.so

On Thu, 3 May 2012 23:57:40 +0200 Irek Szczesniak wrote:
> On Thu, May 3, 2012 at 6:07 PM, Irek Szczesniak <[email protected]> wrote:
> > On Thu, May 3, 2012 at 5:44 PM, Glenn Fowler <[email protected]> wrote:
> >>
> >> thanks
> >> I had done Shbltin_t* for b_xargs() but that was newer than the
> >> builtin grep src I was working off of
> >
> > Ok. Next stop: Patch for SHOPT_EXPERIMENTALBUILTINS

> Glenn, do you know why the patch below does not work? It seems the
> nmake if doesn't find the SHOPT_EXTRA_BUILTIN substring in CCFLAGS:
> ==================
> diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c
> index 95f10f8..935e249 100644
> --- a/src/cmd/ksh93/data/builtins.c
> +++ b/src/cmd/ksh93/data/builtins.c
> @@ -138,6 +138,14 @@ const struct shtable3 shtab_builtins[] =
>       CMDLIST(uname)
>       CMDLIST(wc)
>       CMDLIST(sync)
> +#ifdef SHOPT_EXTRA_BUILTINS
> +     CMDLIST(egrep)
> +     CMDLIST(fgrep)
> +     CMDLIST(grep)
> +     CMDLIST(pgrep)
> +     CMDLIST(xgrep)
> +     CMDLIST(xargs)
> +#endif
>  #endif
>  #if SHOPT_REGRESS
>       "__regress__",          NV_BLTIN|BLT_ENV,       bltin(__regress__),
> diff --git a/src/lib/libcmd/Makefile b/src/lib/libcmd/Makefile
> index 3cecffd..6fc29e8 100644
> --- a/src/lib/libcmd/Makefile
> +++ b/src/lib/libcmd/Makefile
> @@ -17,6 +17,10 @@ CHMOD = $(STDCHMOD|"chmod")

>  HOSTTYPE == "$(CC.HOSTTYPE)"

> +if CCFLAGS == "*SHOPT_EXTRA_BUILTINS=1*"
> +     EXTRA_BUILTINS = grep.c xargs.c
> +end
> +
>  cmd 1.2 :LIBRARY: RELEASE cmdinit.c \
>       cmd.h rev.h wc.h \
>       basename.c cat.c chgrp.c chmod.c chown.c cksum.c cmp.c \
> @@ -25,6 +29,7 @@ cmd 1.2 :LIBRARY: RELEASE cmdinit.c \
>       mkfifo.c mktemp.c mv.c paste.c pathchk.c pids.c rev.c rm.c \
>       rmdir.c stty.c sum.c sync.c tail.c tee.c tty.c uname.c uniq.c \
>       vmstate.c wc.c revlib.c wclib.c sumlib.o \
> +     $(EXTRA_BUILTINS) \
>       fts_fix.c lib.c \
>       -lfsg -lmd

> ==================

> Irek

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to