diff options
author | obrien <obrien@FreeBSD.org> | 2001-05-28 05:21:37 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-05-28 05:21:37 +0000 |
commit | 328e45595b12375b6d16a846069507d25086abdb (patch) | |
tree | ae2a6f4f4987889b7bd2af7bdf0b86fa580df011 /contrib/binutils/libiberty/dyn-string.c | |
parent | 7fbb72605a1c3bcb81f8b6bb6297ffef30f84335 (diff) | |
download | FreeBSD-src-328e45595b12375b6d16a846069507d25086abdb.zip FreeBSD-src-328e45595b12375b6d16a846069507d25086abdb.tar.gz |
Import of GNU Binutils version 2.11.0.
Believe it or not, this is heavily stripped down.
Diffstat (limited to 'contrib/binutils/libiberty/dyn-string.c')
-rw-r--r-- | contrib/binutils/libiberty/dyn-string.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/binutils/libiberty/dyn-string.c b/contrib/binutils/libiberty/dyn-string.c index 69897f8..34f88ad 100644 --- a/contrib/binutils/libiberty/dyn-string.c +++ b/contrib/binutils/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. */ |