From c96175928811d11fc7f7fec6f5a94b7ddb8f1242 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 1 May 2013 09:21:16 +0800 Subject: [PATCH] rework version and help printing em --help now returns EXIT_SUCCESS --- Makefile | 6 +++--- main.c | 40 ++++++++++++++++++++++++---------------- version.c | 15 ++++++++++----- version.h | 11 ++++++----- 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 4449ed1..7882e0a 100644 --- a/Makefile +++ b/Makefile @@ -135,8 +135,8 @@ basic.o: basic.c estruct.h edef.h bind.o: bind.c estruct.h edef.h epath.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 -eval.o: eval.c estruct.h edef.h evar.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 exec.o: exec.c estruct.h edef.h file.o: file.c estruct.h edef.h fileio.o: fileio.c estruct.h edef.h @@ -145,7 +145,7 @@ input.o: input.c estruct.h edef.h isearch.o: isearch.c estruct.h edef.h line.o: line.c estruct.h edef.h lock.o: lock.c estruct.h edef.h -main.o: main.c estruct.h efunc.h edef.h ebind.h +main.o: main.c estruct.h efunc.h edef.h ebind.h version.h pklock.o: pklock.c estruct.h posix.o: posix.c estruct.h utf8.h random.o: random.c estruct.h edef.h diff --git a/main.c b/main.c index 08f2f19..6db7e75 100644 --- a/main.c +++ b/main.c @@ -49,6 +49,10 @@ * * 4.0 Petri Kutvonen, 1-Sep-91 * + * This modified version is now called uEmacs/rf. + * + * 4.1 Renaud Fivet, 1-May-13 + * */ #include @@ -88,17 +92,19 @@ extern void sizesignal(int); #endif #endif -void usage(int status) -{ - 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); +static void version( void) { + printf( "%s version %s\n", PROGRAM_NAME_LONG, VERSION) ; +} - exit(status); + +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) ; } int main(int argc, char **argv) @@ -139,13 +145,15 @@ int main(int argc, char **argv) signal(SIGWINCH, sizesignal); #endif #endif - if (argc == 2) { - if (strcmp(argv[1], "--help") == 0) { - usage(EXIT_FAILURE); + if( argc == 2) { + if( strcmp( argv[ 1], "--help") == 0) { + usage() ; + exit( EXIT_SUCCESS) ; } - if (strcmp(argv[1], "--version") == 0) { - version(); - exit(EXIT_SUCCESS); + + if( strcmp( argv[ 1], "--version") == 0) { + version() ; + exit( EXIT_SUCCESS) ; } } diff --git a/version.c b/version.c index d974764..9afc0ea 100644 --- a/version.c +++ b/version.c @@ -1,7 +1,12 @@ -#include +/* version.c -- inplements version.h */ + #include "version.h" -void version(void) -{ - printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION); -} +#include + +char *pname_s = "em" ; +char *pnamel_s = "uEmacs/rf" ; + +char *version_s = "4.1.0" ; + +/* end of version.c */ diff --git a/version.h b/version.h index 1647462..13800e3 100644 --- a/version.h +++ b/version.h @@ -1,12 +1,13 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define PROGRAM_NAME "em" -#define PROGRAM_NAME_LONG "uEmacs/Pk" +#define PROGRAM_NAME pname_s +#define PROGRAM_NAME_LONG pnamel_s -#define VERSION "4.0.15" +#define VERSION version_s -/* Print the version string. */ -void version(void); +extern char *pname_s ; +extern char *pnamel_s ; +extern char *version_s ; #endif /* VERSION_H_ */