add dstring_appendsubstr

This commit is contained in:
Bill Currie 2002-03-21 21:16:26 +00:00
parent 6f1b68aeb4
commit b7fc784718
2 changed files with 10 additions and 0 deletions

View file

@ -52,6 +52,7 @@ void dstring_clear (dstring_t *dstr);
// String-specific functions
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_clearstr (dstring_t *dstr);

View file

@ -123,6 +123,15 @@ dstring_appendstr (dstring_t *dstr, const char *str) {
strcat(dstr->str, str);
}
void
dstring_appendsubstr (dstring_t *dstr, const char *str, unsigned int len) {
if (len > strlen (str))
len = strlen (str);
dstr->size += len;
dstring_adjust(dstr);
strncat(dstr->str, str, len);
}
void
dstring_insertstr (dstring_t *dstr, const char *str, unsigned int pos)
{