diff options
author | Xin LI <delphij@FreeBSD.org> | 2017-04-25 03:28:38 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2017-04-25 03:28:38 +0000 |
commit | 1cabeb1f0c93e44ebc8a1d3a78100a962ac3f047 (patch) | |
tree | 16ac99cc7e82435551416b750a3017a6b3a2d986 /lesskey.c | |
parent | 59d1fa4298584d1670edf26ee475b9b8f6a1c7bc (diff) |
Notes
Diffstat (limited to 'lesskey.c')
-rw-r--r-- | lesskey.c | 89 |
1 files changed, 33 insertions, 56 deletions
diff --git a/lesskey.c b/lesskey.c index 298748b9a04a..47b765424fbc 100644 --- a/lesskey.c +++ b/lesskey.c @@ -213,19 +213,19 @@ char *outfile = NULL ; int linenum; int errors; +static void lk_error(char *s); + extern char version[]; void -usage() +usage(void) { fprintf(stderr, "usage: lesskey [-o output] [input]\n"); exit(1); } char * -mkpathname(dirname, filename) - char *dirname; - char *filename; +mkpathname(char *dirname, char *filename) { char *pathname; @@ -240,8 +240,7 @@ mkpathname(dirname, filename) * Figure out the name of a default file (in the user's HOME directory). */ char * -homefile(filename) - char *filename; +homefile(char *filename) { char *p; char *pathname; @@ -264,9 +263,7 @@ homefile(filename) * Parse command line arguments. */ void -parse_args(argc, argv) - int argc; - char **argv; +parse_args(int argc, char **argv) { char *arg; @@ -339,7 +336,7 @@ parse_args(argc, argv) * Initialize data structures. */ void -init_tables() +init_tables(void) { cmdtable.names = cmdnames; cmdtable.pbuffer = cmdtable.buffer; @@ -355,13 +352,11 @@ init_tables() * Parse one character of a string. */ char * -tstr(pp, xlate) - char **pp; - int xlate; +tstr(char **pp, int xlate) { - register char *p; - register char ch; - register int i; + char *p; + char ch; + int i; static char buf[10]; static char tstr_control_k[] = { SK_SPECIAL_KEY, SK_CONTROL_K, 6, 1, 1, 1, '\0' }; @@ -421,7 +416,7 @@ tstr(pp, xlate) case 'e': ch = SK_END; break; case 'x': ch = SK_DELETE; break; default: - error("illegal char after \\k"); + lk_error("illegal char after \\k"); *pp = p+1; return (""); } @@ -471,8 +466,7 @@ tstr(pp, xlate) * Skip leading spaces in a string. */ public char * -skipsp(s) - register char *s; +skipsp(char *s) { while (*s == ' ' || *s == '\t') s++; @@ -483,8 +477,7 @@ skipsp(s) * Skip non-space characters in a string. */ public char * -skipnsp(s) - register char *s; +skipnsp(char *s) { while (*s != '\0' && *s != ' ' && *s != '\t') s++; @@ -496,10 +489,9 @@ skipnsp(s) * strip off the trailing newline & any trailing # comment. */ char * -clean_line(s) - char *s; +clean_line(char *s) { - register int i; + int i; s = skipsp(s); for (i = 0; s[i] != '\n' && s[i] != '\r' && s[i] != '\0'; i++) @@ -513,12 +505,11 @@ clean_line(s) * Add a byte to the output command table. */ void -add_cmd_char(c) - int c; +add_cmd_char(int c) { if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD) { - error("too many commands"); + lk_error("too many commands"); exit(1); } *(currtable->pbuffer)++ = c; @@ -528,8 +519,7 @@ add_cmd_char(c) * Add a string to the output command table. */ void -add_cmd_str(s) - char *s; +add_cmd_str(char *s) { for ( ; *s != '\0'; s++) add_cmd_char(*s); @@ -539,8 +529,7 @@ add_cmd_str(s) * See if we have a special "control" line. */ int -control_line(s) - char *s; +control_line(char *s) { #define PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0) @@ -572,10 +561,7 @@ control_line(s) * Output some bytes. */ void -fputbytes(fd, buf, len) - FILE *fd; - char *buf; - int len; +fputbytes(FILE *fd, char *buf, int len) { while (len-- > 0) { @@ -588,9 +574,7 @@ fputbytes(fd, buf, len) * Output an integer, in special KRADIX form. */ void -fputint(fd, val) - FILE *fd; - unsigned int val; +fputint(FILE *fd, unsigned int val) { char c; @@ -610,21 +594,19 @@ fputint(fd, val) * Find an action, given the name of the action. */ int -findaction(actname) - char *actname; +findaction(char *actname) { int i; for (i = 0; currtable->names[i].cn_name != NULL; i++) if (strcmp(currtable->names[i].cn_name, actname) == 0) return (currtable->names[i].cn_action); - error("unknown action"); + lk_error("unknown action"); return (A_INVALID); } - void -error(s) - char *s; + static void +lk_error(char *s) { fprintf(stderr, "line %d: %s\n", linenum, s); errors++; @@ -632,8 +614,7 @@ error(s) void -parse_cmdline(p) - char *p; +parse_cmdline(char *p) { int cmdlen; char *actname; @@ -650,7 +631,7 @@ parse_cmdline(p) s = tstr(&p, 1); cmdlen += (int) strlen(s); if (cmdlen > MAX_CMDLEN) - error("command too long"); + lk_error("command too long"); else add_cmd_str(s); } while (*p != ' ' && *p != '\t' && *p != '\0'); @@ -667,7 +648,7 @@ parse_cmdline(p) p = skipsp(p); if (*p == '\0') { - error("missing action"); + lk_error("missing action"); return; } actname = p; @@ -702,8 +683,7 @@ parse_cmdline(p) } void -parse_varline(p) - char *p; +parse_varline(char *p) { char *s; @@ -720,7 +700,7 @@ parse_varline(p) p = skipsp(p); if (*p++ != '=') { - error("missing ="); + lk_error("missing ="); return; } @@ -739,8 +719,7 @@ parse_varline(p) * Parse a line from the lesskey file. */ void -parse_line(line) - char *line; +parse_line(char *line) { char *p; @@ -765,9 +744,7 @@ parse_line(line) } int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { FILE *desc; FILE *out; |