Remove unused code
[mmh] / sbr / trim.c
1 /*
2 ** trim.c -- strip leading and trailing whitespace ... inplace!
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10 #include <ctype.h>
11
12
13 char *
14 trim(unsigned char *cp)
15 {
16         unsigned char *sp;
17
18         /* skip over leading whitespace */
19         while (isspace(*cp)) {
20                 cp++;
21         }
22
23         /* start at the end and zap trailing whitespace */
24         for (sp = cp + strlen(cp) - 1; sp >= cp; sp--) {
25                 if (isspace(*sp)) {
26                         *sp = '\0';
27                 } else {
28                         break;
29                 }
30         }
31
32         return cp;
33 }