diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/ChangeLog | 4 | ||||
-rw-r--r-- | util/errors.c | 1 | ||||
-rw-r--r-- | util/strgutil.c | 28 |
3 files changed, 33 insertions, 0 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index 39165bbe6..1f3a87a24 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,7 @@ +Sun Jan 17 11:04:33 CET 1999 Werner Koch <[email protected]> + + * strgutil.c (trim_trailing_ws): New. + Sat Jan 16 12:03:27 CET 1999 Werner Koch <[email protected]> * http.c (connect_server): Fixed stupid bug. diff --git a/util/errors.c b/util/errors.c index 003be82fd..3e9dbcf79 100644 --- a/util/errors.c +++ b/util/errors.c @@ -98,6 +98,7 @@ g10_errstr( int err ) X(BAD_URI ,N_("bad URI")) X(INVALID_URI ,N_("unsupported URI")) X(NETWORK ,N_("network error")) + X(SELFTEST_FAILED,"selftest failed") default: p = buf; sprintf(buf, "g10err=%d", err); break; } #undef X 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 ) { |