diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-14 22:17:51 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-14 22:17:51 +0800 |
commit | 623ba9a279db035339ac8ae5030683c1e79b8618 (patch) | |
tree | 82b610030315c26a99a65a006fb2bceba0cdb280 /e-util | |
parent | 310189326247ec07951b30c52abc69050be5d2b9 (diff) | |
download | gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.tar gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.tar.gz gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.tar.bz2 gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.tar.lz gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.tar.xz gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.tar.zst gsoc2013-evolution-623ba9a279db035339ac8ae5030683c1e79b8618.zip |
Added e_strdup_strip which returns a copy of the string with the leading
2000-05-14 Christopher James Lahey <clahey@helixcode.com>
* e-util.c, e-util.h: Added e_strdup_strip which returns a copy of
the string with the leading and trailing spaces removed.
svn path=/trunk/; revision=3026
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 5 | ||||
-rw-r--r-- | e-util/e-util.c | 18 | ||||
-rw-r--r-- | e-util/e-util.c-8611 | 18 | ||||
-rw-r--r-- | e-util/e-util.h | 2 | ||||
-rw-r--r-- | e-util/e-util.h-29002 | 2 |
5 files changed, 45 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 367885919f..015d840969 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,8 @@ +2000-05-14 Christopher James Lahey <clahey@helixcode.com> + + * e-util.c, e-util.h: Added e_strdup_strip which returns a copy of + the string with the leading and trailing spaces removed. + 2000-05-11 NotZed <NotZed@HelixCode.com> * e-sexp.c (e_sexp_finalise): Destroy the g_scanner when cleaning up. diff --git a/e-util/e-util.c b/e-util/e-util.c index d5603d3dfa..33c10aba5c 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -25,6 +25,7 @@ #include <errno.h> #include <fcntl.h> #include <unistd.h> +#include <ctype.h> #include "e-util.h" @@ -45,6 +46,23 @@ g_int_compare(const void *x, const void *y) return -1; } +char * +e_strdup_strip(char *string) +{ + int i; + int length = 0; + int initial = 0; + for ( i = 0; string[i]; i++ ) { + if (initial == i && isspace(string[i])) { + initial ++; + } + if (!isspace(string[i])) { + length = i - initial + 1; + } + } + return g_strndup(string + initial, length); +} + void e_free_object_list (GList *list) { diff --git a/e-util/e-util.c-8611 b/e-util/e-util.c-8611 index d5603d3dfa..33c10aba5c 100644 --- a/e-util/e-util.c-8611 +++ b/e-util/e-util.c-8611 @@ -25,6 +25,7 @@ #include <errno.h> #include <fcntl.h> #include <unistd.h> +#include <ctype.h> #include "e-util.h" @@ -45,6 +46,23 @@ g_int_compare(const void *x, const void *y) return -1; } +char * +e_strdup_strip(char *string) +{ + int i; + int length = 0; + int initial = 0; + for ( i = 0; string[i]; i++ ) { + if (initial == i && isspace(string[i])) { + initial ++; + } + if (!isspace(string[i])) { + length = i - initial + 1; + } + } + return g_strndup(string + initial, length); +} + void e_free_object_list (GList *list) { diff --git a/e-util/e-util.h b/e-util/e-util.h index b8d49c9928..2043235cf7 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -34,6 +34,8 @@ typedef enum { int g_str_compare(const void *x, const void *y); int g_int_compare(const void *x, const void *y); +char *e_strdup_strip(char *string); + void e_free_object_list (GList *list); char *e_read_file(const char *filename); diff --git a/e-util/e-util.h-29002 b/e-util/e-util.h-29002 index b8d49c9928..2043235cf7 100644 --- a/e-util/e-util.h-29002 +++ b/e-util/e-util.h-29002 @@ -34,6 +34,8 @@ typedef enum { int g_str_compare(const void *x, const void *y); int g_int_compare(const void *x, const void *y); +char *e_strdup_strip(char *string); + void e_free_object_list (GList *list); char *e_read_file(const char *filename); |