From 9ecdc22a66cc3614b2274fd91000aafce7a5f549 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 21 Apr 2019 02:36:49 -0500 Subject: man: Whitespace --- toys/pending/man.c | 21 +++++++++++++++++---- 1 file 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) { -- cgit v1.2.3