1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
guile/libguile/deprecated.c
Andy Wingo f34d50ad6b Deprecate scm_find_executable
* libguile/deprecated.h:
* libguile/deprecated.c (scm_find_executable): Deprecate.  Use strdup
  instead of weird scm_cat_path function.
* libguile/script.h:
* libguile/script.c: Remove old decls.
2018-10-07 16:04:59 +02:00

92 lines
1.9 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Copyright 2003-2004,2006,2008-2018
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define SCM_BUILDING_DEPRECATED_CODE
#include "deprecation.h"
#include "gc.h"
#include "deprecated.h"
#if (SCM_ENABLE_DEPRECATED == 1)
#ifndef MAXPATHLEN
#define MAXPATHLEN 80
#endif /* ndef MAXPATHLEN */
#ifndef X_OK
#define X_OK 1
#endif /* ndef X_OK */
char *
scm_find_executable (const char *name)
{
char tbuf[MAXPATHLEN];
int i = 0, c;
FILE *f;
scm_c_issue_deprecation_warning ("scm_find_executable is deprecated.");
/* fprintf(stderr, "s_f_e checking access %s ->%d\n", name, access(name, X_OK)); fflush(stderr); */
if (access (name, X_OK))
return 0L;
f = fopen (name, "r");
if (!f)
return 0L;
if ((fgetc (f) == '#') && (fgetc (f) == '!'))
{
while (1)
switch (c = fgetc (f))
{
case /*WHITE_SPACES */ ' ':
case '\t':
case '\r':
case '\f':
case EOF:
tbuf[i] = 0;
fclose (f);
return strdup (tbuf);
default:
tbuf[i++] = c;
break;
}
}
fclose (f);
return strdup (name);
}
void
scm_i_init_deprecated ()
{
#include "deprecated.x"
}
#endif /* SCM_ENABLE_DEPRECATD == 1 */