On Fri, Oct 12, 2012 at 4:10 PM, David Korn <d...@research.att.com> wrote: [CC:'ing the ast-developers@-list again (since IMO such debugging stuff should happen there...)] > cc: g...@research.att.com > Subject: Re: Re: Re: [ast-developers] Suse 12.1 test failures in options.sh > (was: Re: ast-ksh 2012-08-13 alpha) > -------- > > >> Any idea why this only seems to happen for multibyte locales (e.g. >> that |name| is |NULL| in such a case) ? >> > > No idea how this can happen. ENVNOD is initialized in sh/init.c to > $HOME/.kshrc and can be changed from the environment. > > sh_mactry() calls sh_mactrim() to expand the value and it uses stkfreeze() > to get the string which should never be NULL. > > If I could reproduce, I would try using gdb to see how this happened.
Erm... it turns out the code is exactly doing what it is supposed to do... and the problem happens in the "C" locale, too. I tried this test patch for debugging: -- snip -- diff -r -u original/src/cmd/ksh93/sh/main.c build_i386_64bit_debug/src/cmd/ksh93/sh/main.c --- src/cmd/ksh93/sh/main.c 2012-09-23 03:44:13.000000000 +0200 +++ src/cmd/ksh93/sh/main.c 2012-10-12 23:41:32.747197058 +0200 @@ -224,7 +224,9 @@ else #endif { - if(name = sh_mactry(shp,nv_getval(ENVNOD))) + char *xrawname=nv_getval(ENVNOD); + char *mactryname=sh_mactry(shp,xrawname); + if(name=mactryname) name = *name ? strdup(name) : (char*)0; #if SHOPT_SYSRC if(!strmatch(name, "?(.)/./*")) -- snip -- Per gdb |mactryname| returns an empty, non-|NULL| string (e.g. "") and the next statement, e.g. the |name = *name ? strdup(name) : (char*)0;| turns this into a |NULL| pointer. The problem is that |strmatch()| is allergic to |NULL| passed as string (which is IMO a good thing) ... which means my original was pointing into the right direction (but was slightly incorrect because if |name| is |NULL| ~/.kshrc should be executed). Below is the right fix: -- snip -- diff -r -u original/src/cmd/ksh93/sh/main.c build_i386_64bit_debug/src/cmd/ksh93/sh/main.c --- src/cmd/ksh93/sh/main.c 2012-09-23 03:44:13.000000000 +0200 +++ src/cmd/ksh93/sh/main.c 2012-10-12 23:58:07.278778604 +0200 @@ -227,7 +227,7 @@ if(name = sh_mactry(shp,nv_getval(ENVNOD))) name = *name ? strdup(name) : (char*)0; #if SHOPT_SYSRC - if(!strmatch(name, "?(.)/./*")) + if(!(name && strmatch(name, "?(.)/./*"))) sh_source(shp, iop, e_sysrc); #endif -- snip -- ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.ma...@nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;) _______________________________________________ ast-developers mailing list ast-developers@research.att.com https://mailman.research.att.com/mailman/listinfo/ast-developers