]> git.saurik.com Git - bison.git/blobdiff - data/c.m4
Do not create a temporary file, as that involves security and
[bison.git] / data / c.m4
index 21145a175fbe918e6805a9214fbfa3fe8fb0161d..d2684fbb0788a7994dfe248c0a08e93e9e18d736 100644 (file)
--- a/data/c.m4
+++ b/data/c.m4
@@ -1,4 +1,4 @@
-m4_divert(-1)                                                     -*- C -*-
+m4_divert(-1)                                               -*- Autoconf -*-
 
 # C M4 Macros for Bison.
 # Copyright (C) 2002 Free Software Foundation, Inc.
@@ -65,7 +65,7 @@ m4_define([b4_ints_in],
 # MIN to MAX (included).
 m4_define([b4_int_type],
 [m4_if(b4_ints_in($@,      [0],   [255]), [1], [unsigned char],
-       b4_ints_in($@,   [-128],   [128]), [1], [signed char],
+       b4_ints_in($@,   [-128],   [127]), [1], [yysigned_char],
 
        b4_ints_in($@,      [0], [65535]), [1], [unsigned short],
        b4_ints_in($@, [-32768], [32767]), [1], [short],
@@ -107,7 +107,8 @@ m4_define([b4_token_enum],
 m4_define([b4_token_defines],
 [m4_if([$@], [[]], [],
 [/* Tokens.  */
-#if defined (__STDC__) || defined (__cplusplus)
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
    /* Put the tokens into the symbol table, so that GDB and other debuggers
       know about them.  */
    enum yytokentype {
@@ -121,13 +122,36 @@ m4_map([b4_token_define], [$@])
 ])
 
 
+## --------------------- ##
+## Calling C functions.  ##
+## --------------------- ##
+
+
+# b4_c_function_call(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
+# -----------------------------------------------------------
+# Call the function NAME with arguments NAME1, NAME2 etc.
+m4_define([b4_c_function_call],
+[$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
+])
+
+
+# b4_c_args([TYPE1, NAME1], ...)
+# ------------------------------
+# Output the arguments NAME1, NAME2...
+m4_define([b4_c_args],
+[m4_map_sep([b4_c_arg], [, ], [$@])])
+
+m4_define([b4_c_arg],
+[$2])
+
+
 ## ---------------------------------------------- ##
 ## Declaring C functions in both K&R and ANSI-C.  ##
 ## ---------------------------------------------- ##
 
 
 # b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
-# ------------------------------------------------
+# ------------------------------------------------------
 # Declare the function NAME.
 m4_define([b4_c_function],
 [$2