From eae092e02b89d2c31d052c8ebde7b89973649936 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 8 Jun 2017 08:46:54 -0700 Subject: [PATCH] Initialize keystring as empty string. Declare help string as const. Print the helpstring through a %s format rather than using it directly. Don't bother to check the address of allocated keystring for NULL. modified: main.c --- src/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index abec01a..94c05c3 100644 --- a/src/main.c +++ b/src/main.c @@ -263,7 +263,7 @@ extern int maxpages; extern int *Lisp_errno; extern int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ -char keystring[128]; +char keystring[128] = {""}; #define FALSE 0 #define TRUE !FALSE @@ -287,7 +287,7 @@ extern void dispatch(); int dosdisplaymode = 0; int twobuttonflag = FALSE; int eurokbd = TRUE; /* Assume eurokbd by default. */ -char *helpstring = +const char *helpstring = "\n\ medley [sysout-name] [] ...\n\ Where are:\n\ @@ -305,7 +305,7 @@ Where are:\n\ -info Print general info about the system\n\ -help Print this message\n"; #elif XWINDOW -char *helpstring = +const char *helpstring = "\n\ either setenv LDESRCESYSOUT or do:\n\ medley [] []\n\ @@ -317,7 +317,7 @@ char *helpstring = -g[eometry] ] The Medley screen geometry\n\ -sc[reen] x] The Medley screen geometry\n"; #else /* not DOS, not XWINDOW */ -char *helpstring = +const char *helpstring = "\n\ either setenv LDESRCESYSOUT or do:\n\ lde[ether] [sysout-name] [-k access-key] []\n\ @@ -382,7 +382,7 @@ char **argv; } if (argv[i] && ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "-HELP") == 0))) { - fprintf(stderr, helpstring); + fprintf(stderr, "%s", helpstring); exit(0); } @@ -400,7 +400,7 @@ char **argv; #endif /* DOS */ || access(sysout_name, R_OK)) { fprintf(stderr, "Couldn't find a sysout to run;\n"); - fprintf(stderr, helpstring); + fprintf(stderr, "%s", helpstring); exit(1); } /* OK, sysout name is now in sysout_name, and i is moved past a supplied name */ @@ -514,8 +514,7 @@ char **argv; } #endif /* DOS */ - if (keystring) /* key given, so safe to copy */ - strcpy(keytyped, keystring); + strcpy(keytyped, keystring); if (keytester(keystring)) { /* keytester destroys keystring */ fprintf(stderr, "Sorry, invalid or expired access key.\n");