diff options
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/man.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/toys/pending/man.c b/toys/pending/man.c index 57f77c61..912be8b5 100644 --- a/toys/pending/man.c +++ b/toys/pending/man.c @@ -29,18 +29,31 @@ static void newln() if (TT.any && TT.cell != 2) putchar('\n'); // gawk alias TT.any = TT.cell = 0; } -static void put(char *x) { while (*x && *x != '\n') TT.any = putchar(*x++); } +static void put(char *x) +{ + while (*x && *x != '\n') TT.any = putchar(*x++); +} -static void s(char *x, char *y) { // Substitute with same length or shorter. +// Substitute with same length or shorter. +static void s(char *x, char *y) +{ int i = strlen(x), j = strlen(y), k, l; + for (k = 0; TT.line[k]; k++) if (!strncmp(x, &TT.line[k], i)) { memmove(&TT.line[k], y, j); for (l = k += j; TT.line[l]; l++) TT.line[l] = TT.line[l + i - j]; } } -static char start(char *x) { return !strncmp(x, TT.line, strlen(x)); } -static void trim(char *x) { if (start(x)) while (*x++) TT.line++; } +static char start(char *x) +{ + return !strncmp(x, TT.line, strlen(x)); +} + +static void trim(char *x) +{ + if (start(x)) while (*x++) TT.line++; +} static void do_man(FILE *fp) { |