#include "files.h"
#include "alloc.h"
#include "gram.h"
+#include "complain.h"
FILE *finput = NULL;
FILE *foutput = NULL;
extern char *mktemp(); /* So the compiler won't complain */
extern char *getenv();
-extern void perror();
char *stringappend PARAMS((char *, int, char *));
void openfiles PARAMS((void));
void open_extra_files PARAMS((void));
FILE *tryopen PARAMS((char *, char *)); /* This might be a good idea */
int tryclose PARAMS((FILE *));
-void done PARAMS((int));
extern char *program_name;
extern int verboseflag;
strlwr (infile);
#endif /* _WIN32 && !__CYGWIN32__ */
-#if (defined(unix) || defined(__unix) || defined(__unix__))
+#if (defined(unix) || defined(__unix) || defined(__unix__) || defined(__EMX__))
{
char *tmp_ptr = getenv("TMPDIR");
finput = tryopen(infile, "r");
- if (! noparserflag)
+ if (! noparserflag)
{
filename = getenv("BISON_SIMPLE");
#ifdef MSDOS
/* use permanent name for actions file */
actfile = stringappend(name_base, short_base_length, ".act");
faction = tryopen(actfile, "w");
- }
+ }
#ifdef MSDOS
if (! noparserflag)
tryclose(fparser);
- if (! noparserflag)
+ if (! noparserflag)
{
filename = (char *) getenv ("BISON_HAIRY");
#ifdef MSDOS
}
- /* JF to make file opening easier. This func tries to open file
- NAME with mode MODE, and prints an error message if it fails. */
+/* JF to make file opening easier. This func tries to open file
+ NAME with mode MODE, and prints an error message if it fails. */
FILE *
tryopen (char *name, char *mode)
{
FILE *ptr;
- ptr = fopen(name, mode);
- if (ptr == NULL)
- {
- fprintf(stderr, "%s: ", program_name);
- perror(name);
- done(2);
- }
+ ptr = fopen (name, mode);
+ if (!ptr)
+ error (2, errno, _("cannot open file `%s'"), name);
+
return ptr;
}
result = fclose (ptr);
if (result == EOF)
- {
- fprintf (stderr, "%s: ", program_name);
- perror ("fclose");
- done (2);
- }
+ error (2, errno, _("cannot close file"));
+
return result;
}
void
-done (int k)
+done (void)
{
tryclose(faction);
tryclose(fattrs);
tryclose(fparser);
tryclose(foutput);
- /* JF write out the output file */
- if (k == 0 && ftable)
+ /* JF write out the output file */
+ if (!complain_message_count && ftable)
{
FILE *ftmp;
register int c;
delete(tmpattrsfile);
if (ftable)
delete(tmptabfile);
- if (k==0) sys$exit(SS$_NORMAL);
- sys$exit(SS$_ABORT);
+/* Don't call exit again, we're in atexit ().
+ if (!complain_message_count)
+ sys$exit(SS$_NORMAL);
+ sys$exit(SS$_ABORT); */
#else
#if (defined (MSDOS) || (defined(_WIN32) && !defined(__CYGWIN32__)))
if (actfile && ! noparserflag) unlink(actfile);
if (tmptabfile) unlink(tmptabfile);
if (tmpdefsfile) unlink(tmpdefsfile);
#endif /* MSDOS || (_WIN32 && !__CYGWIN32__) */
- exit(k);
+/* Don't call exit again, we're in atexit ().
+ exit (complain_message_count ? 1 : 0); */
#endif /* not VMS, or __VMS_POSIX */
}