#include "system.h"
-
-#if defined (VMS) & !defined (__VMS_POSIX)
-# ifndef BISON_SIMPLE
-# define BISON_SIMPLE "GNU_BISON:[000000]BISON.SIMPLE"
-# endif
-# ifndef BISON_HAIRY
-# define BISON_HARIRY "GNU_BISON:[000000]BISON.HAIRY"
-# endif
-#endif
-
-#if defined (_MSC_VER)
-# ifndef BISON_SIMPLE
-# define BISON_SIMPLE "c:/usr/local/lib/bison.simple"
-# endif
-# ifndef BISON_HAIRY
-# define BISON_HAIRY "c:/usr/local/lib/bison.hairy"
-# endif
-#endif
-
#include "getargs.h"
#include "files.h"
#include "xalloc.h"
static char *tabfile;
static char *guardfile;
static char *actfile;
-
-extern char *getenv ();
-
-extern char *program_name;
\f
+/*-----------------------------------------------------------------.
+| Return a newly allocated string composed of the concatenation of |
+| the END1 first chars of STRING1, and STRING2. |
+`-----------------------------------------------------------------*/
static char *
stringappend (const char *string1, int end1, const char *string2)
{
- register char *ostring;
- register char *cp;
- register const char *cp1;
- register int i;
+ char *res;
+ char *cp;
+ const char *cp1;
+ int i;
cp1 = string2;
i = 0;
while (*cp1++)
i++;
- ostring = XCALLOC (char, i + end1 + 1);
+ res = XCALLOC (char, i + end1 + 1);
- cp = ostring;
+ cp = res;
cp1 = string1;
for (i = 0; i < end1; i++)
*cp++ = *cp1++;
while ((*cp++ = *cp1++))
;
- return ostring;
+ return res;
}
/*-----------------------------------------------------------------.
open_files (void)
{
char *name_base;
-#ifdef MSDOS
- register char *cp;
-#endif
int base_length;
int short_base_length;
-#if defined (VMS) & !defined (__VMS_POSIX)
- const char *tmp_base = "sys$scratch:b_";
-#else
- const char *tmp_base = "/tmp/b.";
-#endif
- int tmp_len;
-
-#ifdef MSDOS
- tmp_base = getenv ("TMP");
- if (tmp_base == 0)
- tmp_base = "";
- strlwr (infile);
-#endif /* MSDOS */
-
-#if (defined(_WIN32) && !defined(__CYGWIN32__))
- tmp_base = getenv ("TEMP"); /* Windows95 defines this ... */
- if (tmp_base == 0)
- tmp_base = getenv ("Temp"); /* ... while NT prefers this */
- if (tmp_base == 0)
- tmp_base = "";
- strlwr (infile);
-#endif /* _WIN32 && !__CYGWIN32__ */
-
-#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__EMX__))
- {
- char *tmp_ptr = getenv ("TMPDIR");
-
- if (tmp_ptr != 0)
- tmp_base = stringappend (tmp_ptr, strlen (tmp_ptr), "/b.");
- }
-#endif /* unix || __unix || __unix__ */
-
- tmp_len = strlen (tmp_base);
-
if (spec_outfile)
{
/* -o was specified. The precise -o name will be used for FTABLE.
name_base = XMALLOC (char, base_length + 1);
/* Append `.tab'. */
strcpy (name_base, spec_file_prefix);
-#ifdef VMS
- strcat (name_base, "_tab");
-#else
- strcat (name_base, ".tab");
-#endif
+ strcat (name_base, EXT_TAB);
#ifdef MSDOS
strlwr (name_base);
#endif /* MSDOS */
base_length -= 2;
short_base_length = base_length;
-#ifdef VMS
- name_base = stringappend (name_base, short_base_length, "_tab");
-#else
-#ifdef MSDOS
- name_base = stringappend (name_base, short_base_length, "_tab");
-#else
- name_base = stringappend (name_base, short_base_length, ".tab");
-#endif /* not MSDOS */
-#endif
+ name_base = stringappend (name_base, short_base_length, EXT_TAB);
base_length = short_base_length + 4;
}
if (verbose_flag)
{
-#ifdef MSDOS
- outfile = stringappend (name_base, short_base_length, ".out");
-#else
/* We used to use just .out if spec_name_prefix (-p) was used,
but that conflicts with Posix. */
- outfile = stringappend (name_base, short_base_length, ".output");
-#endif
+ outfile = stringappend (name_base, short_base_length, EXT_OUTPUT);
foutput = xfopen (outfile, "w");
}
else
tabfile = stringappend (name_base, base_length, ".c");
-#ifdef VMS
- attrsfile = stringappend (name_base, short_base_length, "_stype.h");
- guardfile = stringappend (name_base, short_base_length, "_guard.c");
-#else
-#ifdef MSDOS
- attrsfile = stringappend (name_base, short_base_length, ".sth");
- guardfile = stringappend (name_base, short_base_length, ".guc");
-#else
- attrsfile = stringappend (name_base, short_base_length, ".stype.h");
- guardfile = stringappend (name_base, short_base_length, ".guard.c");
-#endif /* not MSDOS */
-#endif /* not VMS */
+ attrsfile = stringappend (name_base, short_base_length, EXT_STYPE_H);
+ guardfile = stringappend (name_base, short_base_length, EXT_GUARD_C);
/* Initialize the obstacks. */
obstack_init (&action_obstack);