X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a11166dddca333d8d599dbed23b20b17ed7b2537..901ec1537a0ceb980398a5395751ea0e445c4ce5:/src/files.c?ds=sidebyside diff --git a/src/files.c b/src/files.c index 5073f04f..92573585 100644 --- a/src/files.c +++ b/src/files.c @@ -28,7 +28,7 @@ #include "complain.h" /* From basename.c. Almost a lie, as it returns a char *. */ -const char *base_name PARAMS ((char const *name)); +const char *base_name (char const *name); FILE *finput = NULL; @@ -111,7 +111,7 @@ xfopen (const char *name, const char *mode) ptr = fopen (name, mode); if (!ptr) - error (2, errno, _("cannot open file `%s'"), name); + error (EXIT_FAILURE, errno, _("cannot open file `%s'"), name); return ptr; } @@ -130,63 +130,10 @@ xfclose (FILE *ptr) result = fclose (ptr); if (result == EOF) - error (2, errno, _("cannot close file")); + error (EXIT_FAILURE, errno, _("cannot close file")); return result; } - - -/*------------------------------------------------------------------. -| Return the path to the skeleton which locaction might be given in | -| ENVVAR, otherwise return SKELETON_NAME. | -`------------------------------------------------------------------*/ - -const char * -skeleton_find (const char *envvar, const char *skeleton_name) -{ - const char *res = getenv (envvar); - -#if defined (MSDOS) || defined (_WIN32) - const char *cp = getenv ("INIT"); - if (!res) - { - /* Skeleton file name without path */ - const char *skel_name = strrchr (skeleton_name, '/'); - if (!skel_name) - skel_name = strrchr (skeleton_name, '\\'); - if (!skel_name) - skel_name = skeleton_name; - else - ++skel_name; - - /* File doesn't exist in current directory; try in INIT directory. */ - if (cp) - { - res = XMALLOC (char, strlen (cp) + strlen (skel_name) + 2); - sprintf (res, "%s%c%s", cp, '\\', skel_name); - } - else if (access (skel_name, 4) == 0) /* Look in current dir. */ - res = skel_name; - else - { - /* Look in program locations dir. */ - extern char *program_name; - cp = strrchr(program_name, '\\'); - if (!cp) - return skeleton_name; - else - ++cp; - res = XMALLOC (char, cp - program_name + strlen (skel_name) + 1); - strncpy (res, program_name, cp - program_name); - strcpy (res + (cp - program_name), skel_name); - } - } -#endif /* defined (MSDOS) || defined (_WIN32) */ - if (!res) - res = skeleton_name; - - return res; -} /*----------------------------------------------------------------.