mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 08:40:19 +02:00
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.
This commit is contained in:
parent
edba440885
commit
f34d50ad6b
4 changed files with 52 additions and 71 deletions
|
@ -21,9 +21,14 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define SCM_BUILDING_DEPRECATED_CODE
|
#define SCM_BUILDING_DEPRECATED_CODE
|
||||||
|
|
||||||
#include "deprecation.h"
|
#include "deprecation.h"
|
||||||
|
#include "gc.h"
|
||||||
|
|
||||||
#include "deprecated.h"
|
#include "deprecated.h"
|
||||||
|
|
||||||
|
@ -31,7 +36,50 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Newly deprecated code goes here. */
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,8 @@ typedef ptrdiff_t scm_t_ptrdiff SCM_DEPRECATED_TYPE;
|
||||||
typedef struct scm_thread scm_i_thread SCM_DEPRECATED_TYPE;
|
typedef struct scm_thread scm_i_thread SCM_DEPRECATED_TYPE;
|
||||||
#undef SCM_DEPRECATED_TYPE
|
#undef SCM_DEPRECATED_TYPE
|
||||||
|
|
||||||
|
SCM_DEPRECATED char* scm_find_executable (const char *name);
|
||||||
|
|
||||||
void scm_i_init_deprecated (void);
|
void scm_i_init_deprecated (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,33 +53,7 @@
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
|
|
||||||
/* Concatentate str2 onto str1 at position n and return concatenated
|
#ifndef WHITE_SPACES
|
||||||
string if file exists; 0 otherwise. */
|
|
||||||
|
|
||||||
static char *
|
|
||||||
scm_cat_path (char *str1, const char *str2, long n)
|
|
||||||
{
|
|
||||||
if (!n)
|
|
||||||
n = strlen (str2);
|
|
||||||
if (str1)
|
|
||||||
{
|
|
||||||
size_t len = strlen (str1);
|
|
||||||
str1 = (char *) realloc (str1, (size_t) (len + n + 1));
|
|
||||||
if (!str1)
|
|
||||||
return 0L;
|
|
||||||
strncat (str1 + len, str2, n);
|
|
||||||
return str1;
|
|
||||||
}
|
|
||||||
str1 = (char *) scm_malloc ((size_t) (n + 1));
|
|
||||||
if (!str1)
|
|
||||||
return 0L;
|
|
||||||
str1[0] = 0;
|
|
||||||
strncat (str1, str2, n);
|
|
||||||
return str1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef LINE_INCREMENTORS
|
|
||||||
#define LINE_INCREMENTORS '\n'
|
|
||||||
#ifdef MSDOS
|
#ifdef MSDOS
|
||||||
#define WHITE_SPACES ' ':case '\t':case '\r':case '\f':case 26
|
#define WHITE_SPACES ' ':case '\t':case '\r':case '\f':case 26
|
||||||
#else
|
#else
|
||||||
|
@ -87,48 +61,6 @@ scm_cat_path (char *str1, const char *str2, long n)
|
||||||
#endif /* def MSDOS */
|
#endif /* def MSDOS */
|
||||||
#endif /* ndef LINE_INCREMENTORS */
|
#endif /* ndef LINE_INCREMENTORS */
|
||||||
|
|
||||||
#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;
|
|
||||||
|
|
||||||
/* 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 scm_cat_path (0L, tbuf, 0L);
|
|
||||||
default:
|
|
||||||
tbuf[i++] = c;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose (f);
|
|
||||||
return scm_cat_path (0L, name, 0L);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Read a \nnn-style escape. We've just read the backslash. */
|
/* Read a \nnn-style escape. We've just read the backslash. */
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "libguile/scm.h"
|
#include "libguile/scm.h"
|
||||||
|
|
||||||
|
|
||||||
SCM_API char *scm_find_executable (const char *name);
|
|
||||||
SCM_API char **scm_get_meta_args (int argc, char **argv);
|
SCM_API char **scm_get_meta_args (int argc, char **argv);
|
||||||
SCM_API int scm_count_argv (char **argv);
|
SCM_API int scm_count_argv (char **argv);
|
||||||
SCM_API void scm_shell_usage (int fatal, char *message);
|
SCM_API void scm_shell_usage (int fatal, char *message);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue