aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/iobuf.c2
-rw-r--r--util/strgutil.c48
2 files changed, 49 insertions, 1 deletions
diff --git a/util/iobuf.c b/util/iobuf.c
index 981fb2efb..ad9821972 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -350,7 +350,7 @@ iobuf_create( const char *fname )
file_filter_ctx_t *fcx;
size_t len;
- if( !fname ) {
+ if( !fname || (*fname=='-' && !fname[1]) ) {
fp = stdout;
fname = "[stdout]";
}
diff --git a/util/strgutil.c b/util/strgutil.c
index daeefe8ae..ecdcb750c 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -62,6 +62,43 @@ memistr( char *buf, size_t buflen, const char *sub )
}
+/****************
+ * remove leading and trailing white spaces
+ */
+char *
+trim_spaces( char *str )
+{
+ char *string, *p, *mark;
+
+ string = str;
+ /* find first non space character */
+ for( p=string; *p && isspace( *(byte*)p ) ; p++ )
+ ;
+ /* move characters */
+ for( (mark = NULL); (*string = *p); string++, p++ )
+ if( isspace( *(byte*)p ) ) {
+ if( !mark )
+ mark = string ;
+ }
+ else
+ mark = NULL ;
+ if( mark )
+ *mark = '\0' ; /* remove trailing spaces */
+
+ return str ;
+}
+
+
+int
+string_count_chr( const char *string, int c )
+{
+ int count;
+ for(count=0; *string; string++ )
+ if( *string == c )
+ count++;
+ return count;
+}
+
/*********************************************
********** missing string functions *********
*********************************************/
@@ -78,3 +115,14 @@ stpcpy(char *a,const char *b)
}
#endif
+#ifndef HAVE_STRLWR
+char *
+strlwr(char *s)
+{
+ char *p;
+ for(p=s; *p; p++ )
+ *p = tolower(*p);
+ return s;
+}
+#endif
+