From: Akim Demaille Date: Fri, 31 Mar 2000 14:56:00 +0000 (+0000) Subject: * src/files.c (tryopen, tryclose): Move to the top. X-Git-Tag: BISON-1_28b~145 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/cfe5fbc0a12e2ed5c5b35125b0ff276a940b79f2?hp=cb7db13e45ec65cda920b9b5b2519bed663d5b38 * src/files.c (tryopen, tryclose): Move to the top. Be static. --- diff --git a/ChangeLog b/ChangeLog index 78a94bfd..5298e84b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-03-31 Akim Demaille + + * src/files.c (tryopen, tryclose): Move to the top. + Be static. + 2000-03-31 Akim Demaille * src/main.c (main): Don't call `done', exit does it. diff --git a/src/files.c b/src/files.c index f77df452..e032d650 100644 --- a/src/files.c +++ b/src/files.c @@ -83,8 +83,6 @@ extern char *getenv(); 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 *)); extern char *program_name; extern int verboseflag; @@ -116,7 +114,42 @@ stringappend (char *string1, int end1, char *string2) return ostring; } +/*-----------------------------------------------------------------. +| Try to open file NAME with mode MODE, and print an error message | +| if fails. | +`-----------------------------------------------------------------*/ +static FILE * +tryopen (char *name, char *mode) +{ + FILE *ptr; + + ptr = fopen (name, mode); + if (!ptr) + error (2, errno, _("cannot open file `%s'"), name); + + return ptr; +} + +/*-------------------------------------------------------------. +| Try to close file PTR, and print an error message if fails. | +`-------------------------------------------------------------*/ + +static int +tryclose (FILE *ptr) +{ + int result; + + if (ptr == NULL) + return 0; + + result = fclose (ptr); + if (result == EOF) + error (2, errno, _("cannot close file")); + + return result; +} + /* JF this has been hacked to death. Nowaday it sets up the file names for the output files, and opens the tmp files and the parser */ void @@ -367,35 +400,6 @@ open_extra_files (void) } -/* 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) - error (2, errno, _("cannot open file `%s'"), name); - - return ptr; -} - -int -tryclose (FILE *ptr) -{ - int result; - - if (ptr == NULL) - return 0; - - result = fclose (ptr); - if (result == EOF) - error (2, errno, _("cannot close file")); - - return result; -} - void done (void) {