From 4958b7d2afe1764ecd0833de6e1104d4e376fd45 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 16:54:02 +0800 Subject: [PATCH] use constant strings for pathnames. --- bind.c | 9 +++++---- efunc.h | 4 ++-- epath.h | 2 +- fileio.c | 2 +- spawn.c | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bind.c b/bind.c index eb28c1f..f94db43 100644 --- a/bind.c +++ b/bind.c @@ -474,7 +474,7 @@ int startup(char *sfname) * char *fname; base file name to search for * int hflag; Look in the HOME environment variable first? */ -char *flook(char *fname, int hflag) +char *flook( const char *fname, int hflag) { char *home; /* path to home directory */ char *path; /* environmental PATH variable */ @@ -502,9 +502,10 @@ char *flook(char *fname, int hflag) #endif /* always try the current directory first */ - if (ffropen(fname) == FIOSUC) { - ffclose(); - return fname; + strcpy( fspec, fname) ; + if( ffropen( fspec) == FIOSUC) { + ffclose() ; + return fspec ; } #if ENVFUNC /* get the PATH variable */ diff --git a/efunc.h b/efunc.h index 6d0ffbc..e24bbba 100644 --- a/efunc.h +++ b/efunc.h @@ -180,7 +180,7 @@ extern int buildlist(int type, char *mstring); extern int strinc(char *source, char *sub); extern unsigned int getckey(int mflag); extern int startup(char *sfname); -extern char *flook(char *fname, int hflag); +char *flook( const char *fname, int hflag) ; extern void cmdstr(int c, char *seq); extern fn_t getbind(int c); extern char *getfname(fn_t); @@ -221,7 +221,7 @@ extern int filename(int f, int n); extern int ifile(char *fname); /* fileio.c */ -extern int ffropen(char *fn); +int ffropen( const char *fn) ; extern int ffwopen(char *fn); extern int ffclose(void); extern int ffputline(char *buf, int nbuf); diff --git a/epath.h b/epath.h index 1e85aaa..ff5b9cc 100644 --- a/epath.h +++ b/epath.h @@ -9,7 +9,7 @@ #define EPATH_H_ /* possible names and paths of help files under different OSs */ -static char *pathname[] = +static const char *pathname[] = #if MSDOS { "emacs.rc", diff --git a/fileio.c b/fileio.c index bab566e..eeadc05 100644 --- a/fileio.c +++ b/fileio.c @@ -17,7 +17,7 @@ static int eofflag; /* end-of-file flag */ /* * Open a file for reading. */ -int ffropen(char *fn) +int ffropen( const char *fn) { if ((ffp = fopen(fn, "r")) == NULL) return FIOFNF; diff --git a/spawn.c b/spawn.c index 4a7b1e5..e0d4471 100644 --- a/spawn.c +++ b/spawn.c @@ -1,4 +1,4 @@ -/* spaw.c +/* spawn.c * * Various operating system access commands. * @@ -571,7 +571,7 @@ int execprog(char *cmd) char *fcb1; /* 4 byte pointer to FCB at PSP+5Ch */ char *fcb2; /* 4 byte pointer to FCB at PSP+6Ch */ } pblock; - char *flook(); + char *flook( const char *fname, int hflag) ; /* parse the command name from the command line */ sp = prog;