Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / util / trimblanks.c
blob334245f1cb9e3702cb330b660d6b01ecfb4228fe
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* trimblanks 3
6 /* SUMMARY
7 /* skip leading whitespace
8 /* SYNOPSIS
9 /* #include <stringops.h>
11 /* char *trimblanks(string, len)
12 /* char *string;
13 /* int len;
14 /* DESCRIPTION
15 /* trimblanks() returns a pointer to the beginning of the trailing
16 /* whitespace in \fIstring\fR, or a pointer to the string terminator
17 /* when the string contains no trailing whitespace.
18 /* The \fIlen\fR argument is either zero or the string length.
19 /* LICENSE
20 /* .ad
21 /* .fi
22 /* The Secure Mailer license must be distributed with this software.
23 /* AUTHOR(S)
24 /* Wietse Venema
25 /* IBM T.J. Watson Research
26 /* P.O. Box 704
27 /* Yorktown Heights, NY 10598, USA
28 /*--*/
30 /* System library. */
32 #include "sys_defs.h"
33 #include <ctype.h>
35 /* Utility library. */
37 #include "stringops.h"
39 char *trimblanks(char *string, int len)
41 char *curr;
43 if (len) {
44 curr = string + len;
45 } else {
46 for (curr = string; *curr != 0; curr++)
47 /* void */ ;
49 while (curr > string && ISSPACE(curr[-1]))
50 curr -= 1;
51 return (curr);