aboutsummaryrefslogtreecommitdiff
path: root/libiberty/dyn-string.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2000-10-12 02:16:48 +0000
committerDJ Delorie <dj@redhat.com>2000-10-12 02:16:48 +0000
commit74bcd5294fa6894905a705d18c229cbe5ea42b59 (patch)
tree91ed0f591c548ee0da25c619bee2598d160e028f /libiberty/dyn-string.c
parent3ef20aaa54691fee72c081389787d2787dbf6164 (diff)
downloadgdb-74bcd5294fa6894905a705d18c229cbe5ea42b59.zip
gdb-74bcd5294fa6894905a705d18c229cbe5ea42b59.tar.gz
gdb-74bcd5294fa6894905a705d18c229cbe5ea42b59.tar.bz2
merge from gcc repository
Diffstat (limited to 'libiberty/dyn-string.c')
-rw-r--r--libiberty/dyn-string.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c
index 69897f8..34f88ad 100644
--- a/libiberty/dyn-string.c
+++ b/libiberty/dyn-string.c
@@ -305,6 +305,30 @@ dyn_string_insert_cstr (dest, pos, src)
return 1;
}
+/* Inserts character C into DEST starting at position POS. DEST is
+ expanded as necessary. Returns 1 on success. On failure,
+ RETURN_ON_ALLOCATION_FAILURE, deletes DEST and returns 0. */
+
+int
+dyn_string_insert_char (dest, pos, c)
+ dyn_string_t dest;
+ int pos;
+ int c;
+{
+ int i;
+
+ if (dyn_string_resize (dest, dest->length + 1) == NULL)
+ return 0;
+ /* Make room for the insertion. Be sure to copy the NUL. */
+ for (i = dest->length; i >= pos; --i)
+ dest->s[i + 1] = dest->s[i];
+ /* Add the new character. */
+ dest->s[pos] = c;
+ /* Compute the new length. */
+ ++dest->length;
+ return 1;
+}
+
/* Append S to DS, resizing DS if necessary. Returns 1 on success.
On failure, if RETURN_ON_ALLOCATION_FAILURE, deletes DEST and
returns 0. */