paren-balanced case patterns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Does anyone have any feelings on this?  It's a simple macro to allow one
to write case patterns with both open and close parentheses, to make tools
like emacs play more nicely with your source code.

-Dan
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.135
diff -u -r1.135 m4sh.m4
--- lib/m4sugar/m4sh.m4	5 Feb 2005 07:58:43 -0000	1.135
+++ lib/m4sugar/m4sh.m4	8 Feb 2005 19:37:38 -0000
@@ -423,6 +423,16 @@
 # This section is lexicographically sorted.
 
 
+# AS_CASE_PATTERN(PATTERN...)
+# ---------------------------
+# Expands to the pattern portion of a case clause.  This just separate all
+# arguments from one another by ` | ' and terminates them with ` ) '.  This is
+# just a nicety to make m4sh source code look more balanced.  Note that since
+# having zero arguments would be erroneous, this macro outputs itself when
+# given no arguments, which should then be noticed an an unexpanded macro.
+m4_define([AS_CASE_PATTERN],
+[m4_if($#,0,[[$0]],$#,1,[[$1 ) ]],[[$1 | ]$0(m4_shift($@))])])
+
 # AS_EXIT([EXIT-CODE = 1])
 # ------------------------
 # Exit and set exit code to EXIT-CODE in the way that it's seen
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux