From e86bdad4fc20e8da787fae657da6625777ab0a90 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 21:17:16 +0800 Subject: [PATCH] refactor epath into bind and util into eval. --- Makefile | 6 +++--- bind.c | 38 +++++++++++++++++++++++++++++++++++--- epath.h | 43 ------------------------------------------- eval.c | 3 ++- util.h | 6 ------ 5 files changed, 40 insertions(+), 56 deletions(-) delete mode 100644 epath.h delete mode 100644 util.h diff --git a/Makefile b/Makefile index 71ac13e..f13e1ee 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ termio.o window.o word.o names.o globals.o \ wrapper.o utf8.o -HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h util.h version.h +HDR=ebind.h edef.h efunc.h estruct.h evar.h version.h # DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them @@ -132,11 +132,11 @@ depend: ${SRC} ansi.o: ansi.c estruct.h edef.h basic.o: basic.c estruct.h edef.h -bind.o: bind.c estruct.h edef.h epath.h util.h +bind.o: bind.c estruct.h edef.h buffer.o: buffer.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h display.o: display.c estruct.h edef.h utf8.h version.h -eval.o: eval.c estruct.h edef.h evar.h version.h util.h +eval.o: eval.c estruct.h edef.h evar.h version.h exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h fileio.o: fileio.c estruct.h edef.h diff --git a/bind.c b/bind.c index f94db43..ba97b10 100644 --- a/bind.c +++ b/bind.c @@ -12,9 +12,41 @@ #include "estruct.h" #include "edef.h" #include "efunc.h" -#include "epath.h" #include "line.h" -#include "util.h" + + +/* possible names and paths of help files under different OSs */ +static const char *pathname[] = { +#if MSDOS + "emacs.rc", + "emacs.hlp", + "\\sys\\public\\", + "\\usr\\bin\\", + "\\bin\\", + "\\", + "" +#endif + +#if V7 | BSD | USG + ".emacsrc", + "emacs.hlp", +#if PKCODE + "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/", +#endif + "/usr/local/", "/usr/lib/", "" +#endif + +#if VMS +{ + "emacs.rc", "emacs.hlp", "", +#if PKCODE + "sys$login:", "emacs_dir:", +#endif + "sys$sysdevice:[vmstools]" +#endif +}; + +#define PATHNAME_SIZE (sizeof pathname / sizeof pathname[ 0]) int help(int f, int n) { /* give me some help!!!! @@ -536,7 +568,7 @@ char *flook( const char *fname, int hflag) #endif /* look it up via the old table method */ - for (i = 2; i < ARRAY_SIZE(pathname); i++) { + for( i = 2; i < PATHNAME_SIZE ; i++) { strcpy(fspec, pathname[i]); strcat(fspec, fname); diff --git a/epath.h b/epath.h deleted file mode 100644 index ff5b9cc..0000000 --- a/epath.h +++ /dev/null @@ -1,43 +0,0 @@ -/* EPATH.H - * - * This file contains certain info needed to locate the - * initialization (etc) files on a system dependent basis - * - * modified by Petri Kutvonen - */ -#ifndef EPATH_H_ -#define EPATH_H_ - -/* possible names and paths of help files under different OSs */ -static const char *pathname[] = -#if MSDOS -{ - "emacs.rc", - "emacs.hlp", - "\\sys\\public\\", - "\\usr\\bin\\", - "\\bin\\", - "\\", - "" -}; -#endif - -#if V7 | BSD | USG -{ - ".emacsrc", "emacs.hlp", -#if PKCODE - "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/", -#endif -"/usr/local/", "/usr/lib/", ""}; -#endif - -#if VMS -{ - "emacs.rc", "emacs.hlp", "", -#if PKCODE - "sys$login:", "emacs_dir:", -#endif -"sys$sysdevice:[vmstools]"}; -#endif - -#endif /* EPATH_H_ */ diff --git a/eval.c b/eval.c index fd4993b..27d2a63 100644 --- a/eval.c +++ b/eval.c @@ -13,11 +13,12 @@ #include "efunc.h" #include "evar.h" #include "line.h" -#include "util.h" #include "version.h" #define MAXVARS 255 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + /* User variables */ static struct user_variable uv[MAXVARS + 1]; diff --git a/util.h b/util.h deleted file mode 100644 index 49f3649..0000000 --- a/util.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef UTIL_H_ -#define UTIL_H_ - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -#endif /* UTIL_H_ */