aboutsummaryrefslogtreecommitdiffstats
path: root/camel/gstring-util.c
diff options
context:
space:
mode:
authorMichael Zucci <zucchi@src.gnome.org>2000-05-03 04:37:06 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-03 04:37:06 +0800
commit44575d972d94ce00b0e7c5d46bbb59761d5c840d (patch)
treed2624f4d14afb5aebc8b2ef0f323db27258a5080 /camel/gstring-util.c
parentcf99b8eec231365fedce7d7930ded14334da3741 (diff)
downloadgsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.tar
gsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.tar.gz
gsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.tar.bz2
gsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.tar.lz
gsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.tar.xz
gsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.tar.zst
gsoc2013-evolution-44575d972d94ce00b0e7c5d46bbb59761d5c840d.zip
> * gmime-utils.[ch]: What the hell, remove it. This will break the
> nntp provider (but its broken anyway). The mime parser can be > used instead though. > Removed from all code including it (but none were using it). > > * gmime-utils.c (_store_header_pair_from_string): Removed bizarre > string_dichotomy version of this. This code is somewhat redundant > now, and is headed for death anyway. > > * gstring-util.c (g_string_dichotomy): Same with this one. > (g_string_clone): Removed a memory leak, g_string_new() allocates > its own memory. > (g_string_append_g_string): Allow to append an empty gstring onto > another gstring, dont abort()! > > * string-utils.c (string_dichotomy): Removed this incredibly weird > function. > > * camel-folder.c (_create): Replaced the rather obtuse use of > "string_dichotomy" function with a simple strrchr(). Still not > sure it'll work. > > * camel-folder-summary.c: cvs removed a long-removed file. svn path=/trunk/; revision=2753
Diffstat (limited to 'camel/gstring-util.c')
-rw-r--r--camel/gstring-util.c119
1 files changed, 3 insertions, 116 deletions
diff --git a/camel/gstring-util.c b/camel/gstring-util.c
index ebfd569e8e..a0c1345b71 100644
--- a/camel/gstring-util.c
+++ b/camel/gstring-util.c
@@ -59,120 +59,9 @@ g_string_equals (GString *string1, GString *string2)
GString *
g_string_clone (GString *string)
{
- return g_string_new (g_strdup (string->str) );
+ return g_string_new (string->str);
}
-
-
-
-/**
- * g_string_dichotomy:
- * @sep : separator
- * @prefix: pointer to be field by the prefix object
- * the prefix is not returned when the given pointer is NULL
- * @suffix: pointer to be field by the suffix object
- * the suffix is not returned when the given pointer is NULL
- *
- * Return the strings before and/or after
- * the last occurence of the specified separator
- *
- * This routine returns the string before and/or after
- * a character given as an argument.
- * if the separator is the last character, prefix and/or
- * suffix is set to NULL and result is set to 'l'
- * if the separator is not in the list, prefix and/or
- * suffix is set to NULL and result is set to 'n'
- * When the operation succedeed, the return value is 'o'
- *
- * @Return Value : result of the operation ('o', 'l' or 'n')
- *
- **/
-gchar
-g_string_dichotomy (GString *string, gchar sep, GString **prefix, GString **suffix,
- GStringDichotomyOption options)
-{
- gchar *str, *tmp;
- gint pos, len, first;
-
- g_assert (tmp=string->str);
- len = strlen (tmp);
- if (!len) {
- if (prefix)
- *prefix=NULL;
- if (suffix)
- *suffix=NULL;
- return 'n';
- }
- first = 0;
-
- if ((options & GSTRING_DICHOTOMY_STRIP_LEADING ) && (tmp[first] == sep) )
- do {first++;} while ( (first<len) && (tmp[first] == sep) );
-
- if (options & GSTRING_DICHOTOMY_STRIP_TRAILING )
- while (tmp[len-1] == sep)
- len--;
-
- if (first==len) {
- if (prefix) *prefix=NULL;
- if (suffix) *suffix=NULL;
- return 'n';
- }
-
- if (options & GSTRING_DICHOTOMY_RIGHT_DIR) {
- pos = len;
-
- do {
- pos--;
- } while ((pos>=first) && (tmp[pos]!=sep));
- } else {
- pos = first;
- do {
- pos++;
- } while ((pos<len) && (tmp[pos]!=sep));
-
- }
-
- if ( (pos<first) || (pos>=len) )
- {
- if (suffix) *suffix=NULL;
- if (prefix) *prefix=NULL;
- return 'n';
- }
-
- /* if we have stripped trailing separators, we should */
- /* never enter here */
- if (pos==len-1)
- {
- if (suffix) *suffix=NULL;
- if (prefix) *prefix=NULL;
- return 'l';
- }
- /* if we have stripped leading separators, we should */
- /* never enter here */
- if (pos==first)
- {
- if (suffix) *suffix=NULL;
- if (prefix) *prefix=NULL;
- return 'l';
- }
-
- if (prefix) /* return the prefix */
- {
- str = g_strndup(tmp,pos);
- *prefix = g_string_new(str);
- g_free(str);
- }
- if (suffix) /* return the suffix */
- {
- str = g_strdup(tmp+pos+1);
- *suffix = g_string_new(str);
- g_free(str);
- }
-
- return 'o';
-}
-
-
/**
* g_string_append_g_string : append a GString to another GString
*
@@ -185,13 +74,11 @@ g_string_append_g_string(GString *dest_string, GString *other_string)
{
g_assert(other_string);
g_assert(dest_string);
- g_assert(other_string->str);
- g_string_append(dest_string, other_string->str);
+ if (other_string->len)
+ g_string_append(dest_string, other_string->str);
}
-
-
/**
* g_string_equal_for_hash: test equality of two GStrings for hash tables
* @v: string 1