X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/1c570cbefde061bf4aee1d0ab99bebb9fab40846..4bee7e92bbfba118ed9504f2abd89628c2e24933:/sbr/trimcpy.c diff --git a/sbr/trimcpy.c b/sbr/trimcpy.c index 6bcf3aec..7a2ac03a 100644 --- a/sbr/trimcpy.c +++ b/sbr/trimcpy.c @@ -72,3 +72,25 @@ cpytrim (const char *sp) { return dp; } + + +/* + * rtrim() -- modify the argument to: + * -- strip trailing whitespace + * + * This code is Copyright (c) 2014, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. + */ +char * +rtrim (char *sp) { + char *cp; + + /* start at the end and zap trailing whitespace */ + for (cp = sp + strlen (sp) - 1; + cp >= sp && isspace ((unsigned char) *cp); + --cp) { continue; } + *++cp = '\0'; + + return sp; +}