Eric Blake <ebb9 <at> byu.net> writes: Fixes for some (but not all) of Elbert's m4-specific test failures.
> -esyscmd: [EMAIL PROTECTED] > +esyscmd: [\0] > > OK, a testsuite bug - I assumed that 'printf "[\0]"' is portable, but on > your platform, it prints literal \0 rather than the correct NUL byte. But > not a bug in m4. I might be able to work around it by avoiding that test > if __unix__ is not defined. Or come up with an alternative way to > generate a NUL byte. Done in the patch below, and tested with mingw. Basically, since I'm testing that M4 can handle NUL bytes, I can use M4 to generate NUL bytes :) The approach avoids shell metacharacters in the argument to esyscmd (which break on at least mingw, because of how braindead its system(3) is), so hopefully it also works for OS/2. > > @ ../doc/m4.texinfo:4947: Origin of test > ./136.diversions: stdout mismatch > @ ../doc/m4.texinfo:6358: Origin of test > ./184.sysval: stdout mismatch > > All cases where I already skip the test on platforms that do not obey unix > semantics. In other words, once I submit a patch that makes your platform > trigger the __os2__ macro rather than __unix__, these tests should be > resolved. Also done in the patch below. Previous reports about OS/2 triggered the #defines in m4.h of OS2 but not UNIX, but it appears Elbert's system triggered both. > > @ ../doc/m4.texinfo:6308: Origin of test > ./183.sysval: stdout mismatch > -2 > +255 > > Weird - I called system("exit 2") but discovered an exit status of 255. > Do you know how to make your platform exit with a known exit status? Even > mingw does the right thing for a simple 'exit 2'! I'm not sure how to > work around this bug (maybe just leave the testsuite failure in place). No idea what to do here without some debug results from Elbert. > > @ ../doc/m4.texinfo:6483: Origin of test > ./186.mkstemp: stdout mismatch > +rm: cannot lstat `foo??????': No such file or directory > > Ouch. I assume that I created a temporary file, but now I can't remove > it, particularly since the other mkstemp tests passed? Do file globs work > from your command line? Can you check whether a file checks/foo* with 6 > random characters still exists in your test directory? Done in the patch below. Since I can't rely on globbing, I used a subdirectory instead. But I'm not sure if it will matter on OS/2 that I used /, not \, as the directory separator, so this hunk of the patch still might not work. >From 7541b497e801dc872e8034cddba77c5fa29b110f Mon Sep 17 00:00:00 2001 From: Eric Blake <[EMAIL PROTECTED]> Date: Fri, 11 Apr 2008 09:53:29 -0600 Subject: [PATCH] Improve OS/2+emx build. * src/m4.h [__EMX__]: OS/2 does not have a Unix-compatible system(3), no matter what other macros it pre-defined. * doc/m4.texinfo (Mkstemp): Rework test to avoid globbing failure on OS/2. * src/builtin.c (predefined_tab): Ensure all possible system identifiers are defined, not just the first; the testsuite will catch if multiple identifiers mistakenly made it through. * examples/null.m4 (esyscmd): Don't rely on printf to generate NUL byte. * examples/null.out (esyscmd): Check for esyscmd success. * THANKS: Update. Reported by Elbert Pol. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> --- ChangeLog | 14 ++++++++++++++ THANKS | 1 + doc/m4.texinfo | 10 ++++++---- examples/null.m4 | 4 +++- examples/null.out | 2 +- src/builtin.c | 9 ++++++--- src/m4.h | 1 + 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d37aefc..c5685ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2008-04-11 Eric Blake <[EMAIL PROTECTED]> + Improve OS/2+emx build. + * src/m4.h [__EMX__]: OS/2 does not have a Unix-compatible + system(3), no matter what other macros it pre-defined. + * doc/m4.texinfo (Mkstemp): Rework test to avoid globbing failure + on OS/2. + * src/builtin.c (predefined_tab): Ensure all possible system + identifiers are defined, not just the first; the testsuite will + catch if multiple identifiers mistakenly made it through. + * examples/null.m4 (esyscmd): Don't rely on printf to generate NUL + byte. + * examples/null.out (esyscmd): Check for esyscmd success. + * THANKS: Update. + Reported by Elbert Pol. + Fix mingw build. * src/builtin.c (define_user_macro): Avoid compiler warning. * NEWS: Tweak 1.4.10b entry. diff --git a/THANKS b/THANKS index 01c560f..ab08e6d 100644 diff --git a/doc/m4.texinfo b/doc/m4.texinfo index 690ea79..4a523c6 100644 --- a/doc/m4.texinfo +++ b/doc/m4.texinfo @@ -6481,11 +6481,13 @@ sysval @c the expansion. @example -syscmd(`rm -f foo??????')sysval +syscmd(`rm -rf foodir')sysval @result{}0 -len(mkstemp(`fooXXXXX')) [EMAIL PROTECTED] -syscmd(`rm foo??????')sysval +syscmd(`mkdir foodir')sysval [EMAIL PROTECTED] +len(mkstemp(`foodir/fooXXXXX')) [EMAIL PROTECTED] +syscmd(`rm -r foodir')sysval @result{}0 @end example diff --git a/examples/null.m4 b/examples/null.m4 index 79f4715..7cf123f 100644 --- a/examples/null.m4 +++ b/examples/null.m4 @@ -1,3 +1,5 @@ +dnl Use `m4 -DNUL to print a NUL byte surrounded in [], then exit +ifdef(`NUL', `[]m4exit`'')dnl # This file tests m4 behavior on NUL bytes. dnl Use `m4 -Dm4exit' to test rest of file. NUL not a number, needs to warn m4exit(`22')dnl @@ -47,7 +49,7 @@ errprint(`errprint:' --, `-- ')dnl dnl Passed to esyscmd: not tested yet. NUL truncates string, needs to warn dnl Generated from esyscmd: -`esyscmd:' esyscmd(`printf "[\\0]"') +`esyscmd:' esyscmd(__program__` -DNUL '__file__) sysval dnl First argument of eval: not tested yet. NUL not a number, needs to warn dnl Other arguments of eval: not tested yet, needs to warn dnl First argument to format: not tested yet diff --git a/examples/null.out b/examples/null.out index aca4b78..cd3764f 100644 --- a/examples/null.out +++ b/examples/null.out @@ -6,7 +6,7 @@ user: .--.--,11.--,11. builtin: 3 defn: odd name: $1 divert: -- -esyscmd: [] +esyscmd: [] 0 ifdef: yes: -- oops: -- ifelse: yes: -- index: 2 -1 -1 8 diff --git a/src/builtin.c b/src/builtin.c index 12ce2c0..e9856a8 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -154,11 +154,14 @@ predefined_tab[] = { #if UNIX { "unix", "__unix__", "" }, -#elif W32_NATIVE +#endif +#if W32_NATIVE { "windows", "__windows__", "" }, -#elif OS2 +#endif +#if OS2 { "os2", "__os2__", "" }, -#else +#endif +#if !UNIX && !W32_NATIVE && !OS2 # warning Platform macro not provided #endif { NULL, "__gnu__", "" }, diff --git a/src/m4.h b/src/m4.h index 3e7fc76..54dd9da 100644 --- a/src/m4.h +++ b/src/m4.h @@ -69,6 +69,7 @@ /* Canonicalize OS/2 recognition macro. */ #ifdef __EMX__ # define OS2 1 +# undef UNIX #endif /* Used for version mismatch, when -R detects a frozen file it can't parse. */ -- 1.5.5 _______________________________________________ Bug-m4 mailing list Bug-m4@gnu.org http://lists.gnu.org/mailman/listinfo/bug-m4