Re: getopt usage

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 8/13/2009 7:32 AM:
> Gnulib recently separated POSIX getopt from GNU getopt extensions, and
> marked the getopt module obsolete.  This fixes m4 to work with the latest
> gnulib.git again.

And in the process, caused a regression on BSD which doesn't properly
honor the GNU extension of leading '-' in the optstring argument when
POSIXLY_CORRECT is set.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksQrJ8ACgkQ84KuGfSFAYDWAQCfQj0nwUdGpQR68NYeICedIdFa
K2IAnjeXPLnQw7OIfh9qxzMa58jnF8KJ
=8wsp
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch434 (text/plain, 1.7 KB)
From a6c565c6f4b934be334dd9ada97b215595d10103 Mon Sep 17 00:00:00 2001
From: Eric Blake <[email protected]>
Date: Fri, 27 Nov 2009 21:45:33 -0700
Subject: [PATCH] Work around BSD getopt bug.

* gnulib: Update.
* doc/m4.texinfo (Command line files): Add test.

Signed-off-by: Eric Blake <[email protected]>
---
 ChangeLog      |    4 ++++
 doc/m4.texinfo |   16 ++++++++++++++++
 gnulib         |    2 +-
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80f0d6c..0c9b193 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-11-28  Eric Blake  <[email protected]>

+	Work around BSD getopt bug.
+	* gnulib: Update.
+	* doc/m4.texinfo (Command line files): Add test.
+
 	Use fastmap for better regex performance.
 	* src/input.c (word_start): Delete.
 	(pop_wrapup): Free memory on exit.
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 2cf86d4..550fa4a 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -989,6 +989,22 @@ Command line files
 @error{}bye
 @result{}0
 @end example
+
+@comment Test that we obey POSIX semantics with -D interspersed with
+@comment files, even with POSIXLY_CORRECT (BSD getopt gets it wrong).
+
+$ @kbd{m4 }
+@example
+ifdef(`__unix__', ,
+      `errprint(` skipping: syscmd does not have unix semantics
+')m4exit(`77')')dnl
+changequote(`[', `]')dnl
+syscmd([POSIXLY_CORRECT=1 ']__program__[' -Dbar=hello foo -Dbar=world foo])dnl
+@result{}hello
+@result{}world
+sysval
+@result{}0
+@end example
 @end ignore

 @node Syntax
diff --git a/gnulib b/gnulib
index 23cd741..c0c5acf 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 23cd74133c81b80d335c701848b71d85a53402c6
+Subproject commit c0c5acfbe255f5542bc1c81c7aec223d95e504a6
-- 
1.6.5.rc1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.