1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-06-18 16:35:23 +00:00

rework version and help printing

em --help now returns EXIT_SUCCESS
This commit is contained in:
Renaud 2013-05-01 09:21:16 +08:00 committed by Renaud Fivet
parent f3ce8236af
commit c961759288
4 changed files with 43 additions and 29 deletions

View File

@ -135,8 +135,8 @@ basic.o: basic.c estruct.h edef.h
bind.o: bind.c estruct.h edef.h epath.h bind.o: bind.c estruct.h edef.h epath.h
buffer.o: buffer.c estruct.h edef.h buffer.o: buffer.c estruct.h edef.h
crypt.o: crypt.c estruct.h edef.h crypt.o: crypt.c estruct.h edef.h
display.o: display.c estruct.h edef.h utf8.h display.o: display.c estruct.h edef.h utf8.h version.h
eval.o: eval.c estruct.h edef.h evar.h eval.o: eval.c estruct.h edef.h evar.h version.h
exec.o: exec.c estruct.h edef.h exec.o: exec.c estruct.h edef.h
file.o: file.c estruct.h edef.h file.o: file.c estruct.h edef.h
fileio.o: fileio.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 isearch.o: isearch.c estruct.h edef.h
line.o: line.c estruct.h edef.h line.o: line.c estruct.h edef.h
lock.o: lock.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 pklock.o: pklock.c estruct.h
posix.o: posix.c estruct.h utf8.h posix.o: posix.c estruct.h utf8.h
random.o: random.c estruct.h edef.h random.o: random.c estruct.h edef.h

40
main.c
View File

@ -49,6 +49,10 @@
* *
* 4.0 Petri Kutvonen, 1-Sep-91 * 4.0 Petri Kutvonen, 1-Sep-91
* *
* This modified version is now called uEmacs/rf.
*
* 4.1 Renaud Fivet, 1-May-13
*
*/ */
#include <stdio.h> #include <stdio.h>
@ -88,17 +92,19 @@ extern void sizesignal(int);
#endif #endif
#endif #endif
void usage(int status) static void version( void) {
{ printf( "%s version %s\n", PROGRAM_NAME_LONG, VERSION) ;
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(" +<n> start at line <n>\n", stdout);
fputs(" -g[G]<n> go to line <n>\n", stdout);
fputs(" --help display this help and exit\n", stdout);
fputs(" --version output version information and exit\n", stdout);
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( " +<n> start at line <n>\n", stdout) ;
fputs( " -g[G]<n> go to line <n>\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) int main(int argc, char **argv)
@ -139,13 +145,15 @@ int main(int argc, char **argv)
signal(SIGWINCH, sizesignal); signal(SIGWINCH, sizesignal);
#endif #endif
#endif #endif
if (argc == 2) { if( argc == 2) {
if (strcmp(argv[1], "--help") == 0) { if( strcmp( argv[ 1], "--help") == 0) {
usage(EXIT_FAILURE); usage() ;
exit( EXIT_SUCCESS) ;
} }
if (strcmp(argv[1], "--version") == 0) {
version(); if( strcmp( argv[ 1], "--version") == 0) {
exit(EXIT_SUCCESS); version() ;
exit( EXIT_SUCCESS) ;
} }
} }

View File

@ -1,7 +1,12 @@
#include <stdio.h> /* version.c -- inplements version.h */
#include "version.h" #include "version.h"
void version(void) #include <stdio.h>
{
printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION); char *pname_s = "em" ;
} char *pnamel_s = "uEmacs/rf" ;
char *version_s = "4.1.0" ;
/* end of version.c */

View File

@ -1,12 +1,13 @@
#ifndef VERSION_H_ #ifndef VERSION_H_
#define VERSION_H_ #define VERSION_H_
#define PROGRAM_NAME "em" #define PROGRAM_NAME pname_s
#define PROGRAM_NAME_LONG "uEmacs/Pk" #define PROGRAM_NAME_LONG pnamel_s
#define VERSION "4.0.15" #define VERSION version_s
/* Print the version string. */ extern char *pname_s ;
void version(void); extern char *pnamel_s ;
extern char *version_s ;
#endif /* VERSION_H_ */ #endif /* VERSION_H_ */