mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
add dstring_insertsubstr
This commit is contained in:
parent
619a77b2f7
commit
d00d6a539a
2 changed files with 17 additions and 3 deletions
|
@ -54,6 +54,8 @@ dstring_t *dstring_newstr (void);
|
|||
void dstring_appendstr (dstring_t *dstr, const char *str);
|
||||
void dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len);
|
||||
void dstring_insertstr (dstring_t *dstr, const char *str, unsigned int pos);
|
||||
void dstring_insertsubstr (dstring_t *dstr, const char *str, unsigned int pos,
|
||||
unsigned int len);
|
||||
void dstring_clearstr (dstring_t *dstr);
|
||||
|
||||
int dvsprintf (dstring_t *dstr, const char *fmt, va_list args);
|
||||
|
|
|
@ -125,8 +125,9 @@ dstring_appendstr (dstring_t *dstr, const char *str) {
|
|||
|
||||
void
|
||||
dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len) {
|
||||
if (len > strlen (str))
|
||||
len = strlen (str);
|
||||
unsigned int l = strlen (str);
|
||||
if (len > l)
|
||||
len = l;
|
||||
dstr->size += len;
|
||||
dstring_adjust(dstr);
|
||||
strncat(dstr->str, str, len);
|
||||
|
@ -135,10 +136,21 @@ dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len) {
|
|||
void
|
||||
dstring_insertstr (dstring_t *dstr, const char *str, unsigned int pos)
|
||||
{
|
||||
// Don't instert strlen + 1 to achieve concatenation
|
||||
// Don't insert strlen + 1 to achieve concatenation
|
||||
dstring_insert (dstr, str, strlen(str), pos);
|
||||
}
|
||||
|
||||
void
|
||||
dstring_insertsubstr (dstring_t *dstr, const char *str, unsigned int pos,
|
||||
unsigned int len)
|
||||
{
|
||||
// Don't insert strlen + 1 to achieve concatenation
|
||||
unsigned int l = strlen (str);
|
||||
if (len > l)
|
||||
len = l;
|
||||
dstring_insert (dstr, str, len, pos);
|
||||
}
|
||||
|
||||
void
|
||||
dstring_clearstr (dstring_t *dstr)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue