Hello, Davide Angelocola wrote: > this module defines three functions: > chomp() strip leading whitespaces > chug() strip trailing whitespaces > strip() strip trailing and leading whitespaces
Thanks for the proposal. I think this functionality would be useful in gnulib, but it needs a bit of polishing before your code can be included: - The pretty standard name for this string manipulation is "trim", not "strip". See http://en.wikipedia.org/wiki/Trim_(programming) http://www.lisp.org/HyperSpec/Body/fun_string-tr_g-right-trim.html http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#trim() - The function should work correctly in multibyte locales. To achieve so, it should use the function iswspace() or iswblank() from <wctype.h> and the "mbiter.h" iterators for multibyte strings. - Functions which do side-effects are generally better rewritten as functions without side-effects. I.e. instead of a function char * strip2(char *s, int how) I would prefer to see a function char * strip2(const char *s, int how) that allocates its result with "xalloc.h". Bruno