From 86afdef45ecca68a6f4da6195cfd1e81677a80b8 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Fri, 17 May 2013 10:34:01 +0800 Subject: [PATCH] refactor handling of version and program name strings. --- Makefile | 5 ++--- display.c | 7 +------ main.c | 17 +++++++++-------- version.c | 10 ---------- version.h | 10 +++------- 5 files changed, 15 insertions(+), 34 deletions(-) delete mode 100644 version.c diff --git a/Makefile b/Makefile index 3d9922d..339e207 100644 --- a/Makefile +++ b/Makefile @@ -19,13 +19,13 @@ PROGRAM=ue SRC=basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ file.c fileio.c input.c isearch.c line.c lock.c main.c \ pklock.c posix.c random.c region.c search.c spawn.c tcap.c \ - termio.c window.c word.c names.c globals.c version.c \ + termio.c window.c word.c names.c globals.c \ wrapper.c utf8.c OBJ=basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \ file.o fileio.o input.o isearch.o line.o lock.o main.o \ pklock.o posix.o random.o region.o search.o spawn.o tcap.o \ - termio.o window.o word.o names.o globals.o version.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 @@ -156,7 +156,6 @@ tcap.o: tcap.c estruct.h edef.h termio.o: termio.c estruct.h edef.h usage.o: usage.c usage.h utf8.o: utf8.c utf8.h -version.o: version.c version.h vmsvt.o: vmsvt.c estruct.h edef.h vt52.o: vt52.c estruct.h edef.h window.o: window.c estruct.h edef.h diff --git a/display.c b/display.c index d6d3dba..e0fdc26 100644 --- a/display.c +++ b/display.c @@ -1121,12 +1121,7 @@ static void modeline(struct window *wp) n = 2; - strcpy(tline, " "); - strcat(tline, PROGRAM_NAME_LONG); - strcat(tline, " "); - strcat(tline, VERSION); - strcat(tline, ": "); - cp = &tline[0]; + cp = " " PROGRAM_NAME_LONG " " VERSION ": " ; while ((c = *cp++) != 0) { vtputc(c); ++n; diff --git a/main.c b/main.c index 6db7e75..ba2c22b 100644 --- a/main.c +++ b/main.c @@ -93,20 +93,21 @@ extern void sizesignal(int); #endif static void version( void) { - printf( "%s version %s\n", PROGRAM_NAME_LONG, VERSION) ; + fputs( PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ; } static void usage( void) { - printf( "Usage: %s filename\n", PROGRAM_NAME) ; - printf( " or: %s [options]\n\n", PROGRAM_NAME) ; - fputs( " + start at the end of file\n", stdout) ; - fputs( " + start at line \n", stdout) ; - fputs( " -g[G] go to line \n", stdout) ; - fputs( " --help display this help and exit\n", stdout) ; - fputs( " --version output version information and exit\n", stdout) ; + fputs( "Usage: " PROGRAM_NAME " filename\n" + " or: " PROGRAM_NAME " [options]\n\n" + " + start at the end of file\n" + " + start at line \n" + " -g[G] go to line \n" + " --help display this help and exit\n" + " --version output version information and exit\n", stdout) ; } + int main(int argc, char **argv) { int c = -1; /* command character */ diff --git a/version.c b/version.c deleted file mode 100644 index 45170b8..0000000 --- a/version.c +++ /dev/null @@ -1,10 +0,0 @@ -/* version.c -- inplements version.h */ - -#include "version.h" - -const char *pname_s = "ue" ; -char *pnamel_s = "uEMACS" ; - -char *version_s = "4.1.0" ; - -/* end of version.c */ diff --git a/version.h b/version.h index 8b29000..dc1d6d4 100644 --- a/version.h +++ b/version.h @@ -1,13 +1,9 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define PROGRAM_NAME pname_s -#define PROGRAM_NAME_LONG pnamel_s +#define PROGRAM_NAME "ue" +#define PROGRAM_NAME_LONG "uEMACS" -#define VERSION version_s - -extern const char *pname_s ; -extern char *pnamel_s ; -extern char *version_s ; +#define VERSION "4.1.1" #endif /* VERSION_H_ */