diff options
author | nobody <nobody@localhost> | 1999-05-12 05:59:47 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 1999-05-12 05:59:47 +0800 |
commit | e3dd3105891dc1fc1f65d31397d9f9aaf8ef2868 (patch) | |
tree | 9ee46a5ef674bdf62325cdb23bc745c6c14aab51 /camel/gstring-util.c | |
parent | 6f235e02f3ac099e25dbcd6f97e7fb905dc3b869 (diff) | |
download | gsoc2013-evolution-GNUMERIC_0_26.tar gsoc2013-evolution-GNUMERIC_0_26.tar.gz gsoc2013-evolution-GNUMERIC_0_26.tar.bz2 gsoc2013-evolution-GNUMERIC_0_26.tar.lz gsoc2013-evolution-GNUMERIC_0_26.tar.xz gsoc2013-evolution-GNUMERIC_0_26.tar.zst gsoc2013-evolution-GNUMERIC_0_26.zip |
This commit was manufactured by cvs2svn to create tagGNUMERIC_0_26
'GNUMERIC_0_26'.
svn path=/tags/GNUMERIC_0_26/; revision=913
Diffstat (limited to 'camel/gstring-util.c')
-rw-r--r-- | camel/gstring-util.c | 227 |
1 files changed, 0 insertions, 227 deletions
diff --git a/camel/gstring-util.c b/camel/gstring-util.c deleted file mode 100644 index 05cdc08beb..0000000000 --- a/camel/gstring-util.c +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* gstring-util : utilities for gstring object */ - -/* - * - * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - - - -#include "gstring-util.h" -#include "camel-log.h" - - -/** - * g_string_equals : test if two string are equal - * - * @string1 : first string - * @string2 : second string - * - * @Return Value : true if the strings equal, false otherwise - **/ -gboolean -g_string_equals(GString *string1, GString *string2) -{ - g_assert(string1); - g_assert(string2); - return !strcmp(string1->str, string2->str); -} - - - -/** - * g_string_clone : clone a GString - * - * @string : the string to clone - * - * @Return Value : the clone ... - **/ -GString * -g_string_clone(GString *string) -{ - return g_string_new( g_strdup(string->str) ); -} - - - - -/** - * right_dichotomy : 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' - * - * @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 Value : result of the operation ('o', 'l' or 'n') - * - **/ -gchar -g_string_right_dichotomy( GString *string, gchar sep, GString **prefix, GString **suffix, DichotomyOption options) -{ - gchar *str, *tmp; - gint pos, len, first; - - CAMEL_LOG(FULL_DEBUG,\ - "Entering rightDichotomy: \n\tseparator=%c \n\tprefix=%p \n\tsuffix=%p \n\toptions=%ld\n",\ - sep, prefix, suffix, options); - g_assert( tmp=string->str ); - len = strlen(tmp); - if (!len) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - CAMEL_LOG(FULL_DEBUG,"rightDichotomy: string is empty\n"); - return 'n'; - } - first = 0; - - if ( (options & STRIP_LEADING ) && (tmp[first] == sep) ) - do {first++;} while ( (first<len) && (tmp[first] == sep) ); - - if (options & STRIP_TRAILING ) - while (tmp[len-1] == sep) - len--; - - if (first==len) { - if (prefix) *prefix=NULL; - if (suffix) *suffix=NULL; - CAMEL_LOG(FULL_DEBUG,"rightDichotomy: after stripping, string is empty\n"); - return 'n'; - } - - pos = len; - - do { - pos--; - } while ((pos>=first) && (tmp[pos]!=sep)); - - - if (pos<first) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG(FULL_DEBUG,"rightDichotomy: separator not found\n"); - return 'n'; - } - - /* if we have stripped trailongs separators, we should */ - /* never enter here */ - if (pos==len-1) - { - if (suffix) *suffix=NULL; - if (prefix) *prefix=NULL; - CAMEL_LOG(FULL_DEBUG,"rightDichotomy: separator is last character\n"); - 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 - * - * @dest_string : string which will be appended - * @other_string : string to append - * - **/ -void -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); -} - - - -/** - * g_string_equal_for_hash: test equality of two GStrings for hash tables - * @v: string 1 - * @v2: string 2 - * - * - * - * Return value: - **/ -g_string_equal_for_hash (gconstpointer v, gconstpointer v2) -{ - return strcmp ( ((const GString*)v)->str, ((const GString*)v2)->str) == 0; -} - - -/** - * g_string_hash: computes a hash value for a Gstring - * @v: Gstring object - * - * - * - * Return value: - **/ -guint -g_string_hash (gconstpointer v) -{ - return g_str_hash(((const GString*)v)->str); -} - - - - -/* utility func : frees a GString element in a GList */ -static void -__g_string_list_free_string (gpointer data, gpointer user_data) -{ - GString *string = (GString *)data; - g_string_free(string, TRUE); -} - - -void -g_string_list_free (GList *string_list) -{ - g_list_foreach(string_list, __g_string_list_free_string, NULL); - g_list_free(string_list); -} |