aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog4
-rw-r--r--util/strgutil.c33
2 files changed, 36 insertions, 1 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 25034cfda..422159306 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,7 @@
+2001-03-12 Werner Koch <[email protected]>
+
+ * strgutil.c (check_trailing_chars,check_trailing_ws): New.
+
2001-03-08 Werner Koch <[email protected]>
* argparse.c (default_strusage): Changed year of printed copyright
diff --git a/util/strgutil.c b/util/strgutil.c
index 1308bb0af..ba92481d5 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -247,7 +247,7 @@ trim_spaces( char *str )
-unsigned
+unsigned int
trim_trailing_chars( byte *line, unsigned len, const char *trimchars )
{
byte *p, *mark;
@@ -278,6 +278,37 @@ trim_trailing_ws( byte *line, unsigned len )
return trim_trailing_chars( line, len, " \t\r\n" );
}
+unsigned int
+check_trailing_chars( const byte *line, unsigned int len,
+ const char *trimchars )
+{
+ const byte *p, *mark;
+ unsigned int n;
+
+ for(mark=NULL, p=line, n=0; n < len; n++, p++ ) {
+ if( strchr(trimchars, *p ) ) {
+ if( !mark )
+ mark = p;
+ }
+ else
+ mark = NULL;
+ }
+
+ if( mark ) {
+ return mark - line;
+ }
+ return len;
+}
+
+/****************
+ * remove trailing white spaces and return the length of the buffer
+ */
+unsigned int
+check_trailing_ws( const byte *line, unsigned int len )
+{
+ return check_trailing_chars( line, len, " \t\r\n" );
+}
+
int