Skip to content
Snippets Groups Projects
Commit 9e5ce48c authored by edgrif's avatar edgrif
Browse files

add minor utility to remove a char from a string.

parent 08057040
No related branches found
No related tags found
No related merge requests found
......@@ -26,9 +26,9 @@
* glib but not included with their distribution.
*
* HISTORY:
* Last edited: Mar 27 12:20 2006 (edgrif)
* Last edited: May 19 16:51 2006 (edgrif)
* Created: Thu Oct 13 15:56:54 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.h,v 1.5 2006-03-27 12:10:54 edgrif Exp $
* CVS info: $Id: zmapGLibUtils.h,v 1.6 2006-05-19 15:55:58 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_GLIBUTILS_H
......@@ -60,6 +60,8 @@ typedef enum
char *zMap_g_remove_char(char *string, char ch) ;
void zMap_g_list_foreach_reverse(GList *list, GFunc func, gpointer user_data);
void zMap_g_list_foreach_directional(GList *list,
GFunc func,
......
......@@ -26,9 +26,9 @@
*
* Exported functions: See ZMap/zmapGLibUtils.h
* HISTORY:
* Last edited: Mar 27 12:42 2006 (edgrif)
* Last edited: May 19 16:50 2006 (edgrif)
* Created: Thu Oct 13 15:22:35 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.c,v 1.5 2006-03-27 12:10:54 edgrif Exp $
* CVS info: $Id: zmapGLibUtils.c,v 1.6 2006-05-19 15:55:58 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -90,6 +90,44 @@ static inline GQuark g_quark_new(ZMapQuarkSet quark_set, gchar *string) ;
* */
/*
* Additions to String utilities
*/
/* This routine removes all occurences of the given char from the target string,
* this is done inplace so the returned string will be shorter. */
char *zMap_g_remove_char(char *string, char ch)
{
char *cp ;
zMapAssert(string) ;
cp = string ;
while (*cp)
{
if (*cp == ch)
{
char *cq ;
cq = cp ;
while (*cq)
{
*cq = *(cq + 1) ;
cq++ ;
}
*cq = '\0' ;
}
cp++ ;
}
return string ;
}
/*
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment