.
[gnulib.git] / lib / posixtm.y
index bb5b40e..e2e9985 100644 (file)
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /* Written by Jim Kingdon and David MacKenzie. */
 %{
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* The following block of alloca-related preprocessor directives is here
+   solely to allow compilation by non GNU-C compilers of the C parser
+   produced from this file by old versions of bison.  Newer versions of
+   bison include a block similar to this one in bison.simple.  */
+
 #ifdef __GNUC__
 #define alloca __builtin_alloca
 #else
-#ifdef sparc
+#ifdef HAVE_ALLOCA_H
 #include <alloca.h>
 #else
 #ifdef _AIX
  #pragma alloca
 #else
-char *alloca ();
+void *alloca ();
 #endif
 #endif
 #endif
 
 #include <stdio.h>
 #include <sys/types.h>
+
+#ifdef TM_IN_SYS_TIME
+#include <sys/time.h>
+#else
 #include <time.h>
+#endif
+
+/* Some old versions of bison generate parsers that use bcopy.
+   That loses on systems that don't provide the function, so we have
+   to redefine it here.  */
+#if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
+#define bcopy(from, to, len) memcpy ((to), (from), (len))
+#endif
 
 #define YYDEBUG 1
 
@@ -45,9 +67,56 @@ static struct tm t;
 
 time_t mktime ();
 
-#define yyparse posixtime_yyparse
+/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
+   as well as gratuitiously global symbol names, so we can have multiple
+   yacc generated parsers in the same program.  Note that these are only
+   the variables produced by yacc.  If other parser generators (bison,
+   byacc, etc) produce additional global names that conflict at link time,
+   then those parser generators need to be fixed instead of adding those
+   names to this list. */
+
+#define yymaxdepth pt_maxdepth
+#define yyparse pt_parse
+#define yylex   pt_lex
+#define yyerror pt_error
+#define yylval  pt_lval
+#define yychar  pt_char
+#define yydebug pt_debug
+#define yypact  pt_pact
+#define yyr1    pt_r1
+#define yyr2    pt_r2
+#define yydef   pt_def
+#define yychk   pt_chk
+#define yypgo   pt_pgo
+#define yyact   pt_act
+#define yyexca  pt_exca
+#define yyerrflag pt_errflag
+#define yynerrs pt_nerrs
+#define yyps    pt_ps
+#define yypv    pt_pv
+#define yys     pt_s
+#define yy_yys  pt_yys
+#define yystate pt_state
+#define yytmp   pt_tmp
+#define yyv     pt_v
+#define yy_yyv  pt_yyv
+#define yyval   pt_val
+#define yylloc  pt_lloc
+#define yyreds  pt_reds          /* With YYDEBUG defined */
+#define yytoks  pt_toks          /* With YYDEBUG defined */
+#define yylhs   pt_yylhs
+#define yylen   pt_yylen
+#define yydefred pt_yydefred
+#define yydgoto pt_yydgoto
+#define yysindex pt_yysindex
+#define yyrindex pt_yyrindex
+#define yygindex pt_yygindex
+#define yytable  pt_yytable
+#define yycheck  pt_yycheck
+
 static int yylex ();
 static int yyerror ();
+
 %}
 
 %token DIGIT