Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
f15cbed5
Commit
f15cbed5
authored
19 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
add new GString derived function to replace one string with another in a GString.
parent
766964e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/ZMap/zmapGLibUtils.h
+4
-2
4 additions, 2 deletions
src/include/ZMap/zmapGLibUtils.h
src/zmapUtils/zmapGLibUtils.c
+57
-6
57 additions, 6 deletions
src/zmapUtils/zmapGLibUtils.c
with
61 additions
and
8 deletions
src/include/ZMap/zmapGLibUtils.h
+
4
−
2
View file @
f15cbed5
...
...
@@ -26,9 +26,9 @@
* glib but not included with their distribution.
*
* HISTORY:
* Last edited: Mar
1 14:55
2006 (edgrif)
* Last edited: Mar
27 12:20
2006 (edgrif)
* Created: Thu Oct 13 15:56:54 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.h,v 1.
4
2006-03-
03 08:07:21
edgrif Exp $
* CVS info: $Id: zmapGLibUtils.h,v 1.
5
2006-03-
27 12:10:54
edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_GLIBUTILS_H
...
...
@@ -66,6 +66,8 @@ void zMap_g_list_foreach_directional(GList *list,
gpointer
user_data
,
ZMapGListDirection
forward
);
gboolean
zMap_g_string_replace
(
GString
*
string
,
char
*
target
,
char
*
source
)
;
/* Returns a pointer to an element of the array instead of the element itself. */
#define zMap_g_array_index_ptr(a, t, i) (&(((t*) (a)->data) [(i)]))
...
...
This diff is collapsed.
Click to expand it.
src/zmapUtils/zmapGLibUtils.c
+
57
−
6
View file @
f15cbed5
...
...
@@ -26,12 +26,13 @@
*
* Exported functions: See ZMap/zmapGLibUtils.h
* HISTORY:
* Last edited: Mar
1 14:56
2006 (edgrif)
* Last edited: Mar
27 12:42
2006 (edgrif)
* Created: Thu Oct 13 15:22:35 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.c,v 1.
4
2006-03-
03 08:07:20
edgrif Exp $
* CVS info: $Id: zmapGLibUtils.c,v 1.
5
2006-03-
27 12:10:54
edgrif Exp $
*-------------------------------------------------------------------
*/
#include
<string.h>
#include
<ZMap/zmapUtils.h>
#include
<ZMap/zmapGLibUtils.h>
...
...
@@ -156,10 +157,7 @@ void zMap_g_list_foreach_directional(GList *list,
/* My new routine for returning a pointer to an element in the array, the array will be
* expanded to include the requested element if necessary. If "clear" was not set when
* the array was created then the element may contain random junk instead of zeros. */
GArray
*
zMap_g_array_element
(
GArray
*
farray
,
guint
index
,
gpointer
*
element_out
)
GArray
*
zMap_g_array_element
(
GArray
*
farray
,
guint
index
,
gpointer
*
element_out
)
{
GRealArray
*
array
=
(
GRealArray
*
)
farray
;
gint
length
;
...
...
@@ -179,6 +177,59 @@ zMap_g_array_element (GArray *farray,
/*!
* Additions to GString
*
* GString is a very good package but there are some more operations it could usefully do.
*
*/
/*!
* Substitute one string for another in a GString.
*
* You should note that this routine simply uses the existing GString erase/insert
* functions and so may not be incredibly efficient. If the target string was not
* found the GString remains unaltered and FALSE is returned.
*
* @param string A valid GString.
* @param target The string to be replaced.
* @param source The string to be inserted.
* @return TRUE if a string was replaced, FALSE otherwise.
* */
gboolean
zMap_g_string_replace
(
GString
*
string
,
char
*
target
,
char
*
source
)
{
gboolean
result
=
FALSE
;
int
source_len
;
int
target_len
;
int
target_pos
;
char
*
template_ptr
;
target_len
=
strlen
(
target
)
;
source_len
=
strlen
(
source
)
;
template_ptr
=
string
->
str
;
while
((
template_ptr
=
strstr
(
template_ptr
,
target
)))
{
result
=
TRUE
;
target_pos
=
template_ptr
-
string
->
str
;
string
=
g_string_erase
(
string
,
target_pos
,
target_len
)
;
string
=
g_string_insert
(
string
,
target_pos
,
source
)
;
template_ptr
=
string
->
str
+
target_pos
+
source_len
;
/* Shouldn't go off the end. */
}
return
result
;
}
/*!
* Additions to GQuark
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment