From befacf7efa649de7ee4421a154cc06a40a181cf2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sun, 17 Jan 1999 10:06:03 +0000 Subject: See ChangeLog: Sun Jan 17 11:04:33 CET 1999 Werner Koch --- util/strgutil.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'util/strgutil.c') diff --git a/util/strgutil.c b/util/strgutil.c index d5379f903..b3213dc9c 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -191,6 +191,34 @@ trim_spaces( char *str ) } + +/**************** + * remove trailing white spaces and return the length of the buffer + */ +unsigned +trim_trailing_ws( byte *line, unsigned len ) +{ + byte *p, *mark; + unsigned n; + + for(mark=NULL, p=line, n=0; n < len; n++, p++ ) { + if( strchr(" \t\r\n", *p ) ) { + if( !mark ) + mark = p; + } + else + mark = NULL; + } + + if( mark ) { + *mark = 0; + return mark - line; + } + return len; +} + + + int string_count_chr( const char *string, int c ) { -- cgit v1.2.3