Skip to content

Commit

Permalink
global: Replace str_append_n() with str_append_data().
Browse files Browse the repository at this point in the history
The str_append_n() function is now deprecated. At no occasion, the occurence of
NUL in the data is possible or relevant, so each instance is replaced with
str_append_data() rather than str_append_max().
  • Loading branch information
stephanbosch authored and sirainen committed Aug 30, 2018
1 parent e07b395 commit 8647d31
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/lib-managesieve/managesieve-quote.c
Expand Up @@ -65,7 +65,7 @@ void managesieve_quote_append(string_t *str, const unsigned char *value,

tmp = t_str_new(value_len+escape+4);
if (!modify && (literal || escape == 0))
str_append_n(tmp, value, value_len);
str_append_data(tmp, value, value_len);
else {
last_lwsp = TRUE;
for (i = 0; i < value_len; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib-sieve/ext-encoded-character.c
Expand Up @@ -229,7 +229,7 @@ bool arg_encoded_string_validate
newstr = str_new(sieve_ast_pool((*arg)->ast), str_len(str)*2);
}

str_append_n(newstr, strstart, substart-strstart);
str_append_data(newstr, strstart, substart-strstart);
str_append_str(newstr, tmpstr);

strstart = p + 1;
Expand All @@ -246,7 +246,7 @@ bool arg_encoded_string_validate

if ( newstr != NULL ) {
if ( strstart != strend )
str_append_n(newstr, strstart, strend-strstart);
str_append_data(newstr, strstart, strend-strstart);

sieve_ast_argument_string_set(*arg, newstr);
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib-sieve/mcht-matches.c
Expand Up @@ -213,7 +213,7 @@ static int mcht_matches_match_key
qp = vp - key_offset;

if ( mvalues != NULL )
str_append_n(mvalue, pvp, qp-pvp);
str_append_data(mvalue, pvp, qp-pvp);

/* Compare needle to end of value string */
if ( !cmp->def->char_match(cmp, &vp, vend, &needle, nend) ) {
Expand Down Expand Up @@ -283,7 +283,7 @@ static int mcht_matches_match_key
const char *qp = qend - key_offset;

/* Append '*' match value */
str_append_n(mvalue, pvp, qp-pvp);
str_append_data(mvalue, pvp, qp-pvp);

/* Append any initial '?' match values (those that caused the key
* offset.
Expand Down Expand Up @@ -393,7 +393,7 @@ static int mcht_matches_match_key
/* Add the rest of the string as match value */
if ( mvalues != NULL ) {
str_truncate(mvalue, 0);
str_append_n(mvalue, vp, vend-vp);
str_append_data(mvalue, vp, vend-vp);
sieve_match_values_add(mvalues, mvalue);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c
Expand Up @@ -351,7 +351,7 @@ static string_t *ext_imap4flags_iter_get_flag_str
if ( fp > fstart ) {
/* Return flag */
string_t *flag = t_str_new(fp-fstart+1);
str_append_n(flag, fstart, fp-fstart);
str_append_data(flag, fstart, fp-fstart);

iter->last = fstart - fbegin;
iter->offset = fp - fbegin;
Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/plugins/mime/cmd-extracttext.c
Expand Up @@ -336,7 +336,7 @@ static int cmd_extracttext_operation_execute
value = t_str_new_const(mpart_data.content, mpart_data.size);
} else {
value = t_str_new((size_t)first);
str_append_n(value, mpart_data.content, (size_t)first);
str_append_data(value, mpart_data.content, (size_t)first);
}

/* Apply modifiers */
Expand Down
8 changes: 4 additions & 4 deletions src/lib-sieve/plugins/notify/ext-notify-common.c
Expand Up @@ -307,7 +307,7 @@ int ext_notify_construct_message
}

if ( *p++ != ']' || *p++ != '$' ) {
str_append_n(out_msg, begin, p-begin);
str_append_data(out_msg, begin, p-begin);
valid = FALSE;
}
} else {
Expand All @@ -324,9 +324,9 @@ int ext_notify_construct_message
}

if ( num > 0 && num < body_size)
str_append_n(out_msg, body_text, num);
str_append_data(out_msg, body_text, num);
else
str_append_n(out_msg, body_text, body_size);
str_append_data(out_msg, body_text, body_size);
}
} else {
size_t len;
Expand All @@ -335,7 +335,7 @@ int ext_notify_construct_message
len = strcspn(p + 1, "$") + 1;

/* Copy normal text */
str_append_n(out_msg, p, len);
str_append_data(out_msg, p, len);
p += len;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/plugins/regex/mcht-regex.c
Expand Up @@ -238,7 +238,7 @@ static int mcht_regex_match_key
skipped = 0;
}

str_append_n(subst, val + ctx->pmatch[i].rm_so,
str_append_data(subst, val + ctx->pmatch[i].rm_so,
ctx->pmatch[i].rm_eo - ctx->pmatch[i].rm_so);
sieve_match_values_add(mvalues, subst);
} else
Expand Down
4 changes: 2 additions & 2 deletions src/lib-sieve/plugins/variables/ext-variables-arguments.c
Expand Up @@ -243,7 +243,7 @@ static bool arg_variable_string_validate
*/
if ( substart > strstart ) {
string_t *newstr = str_new(pool, substart - strstart);
str_append_n(newstr, strstart, substart - strstart);
str_append_data(newstr, strstart, substart - strstart);

strarg = sieve_ast_argument_string_create_raw
((*arg)->ast, newstr, (*arg)->source_line);
Expand Down Expand Up @@ -311,7 +311,7 @@ static bool arg_variable_string_validate
if ( strend > strstart ) {
struct sieve_ast_argument *strarg;
string_t *newstr = str_new(pool, strend - strstart);
str_append_n(newstr, strstart, strend - strstart);
str_append_data(newstr, strstart, strend - strstart);

strarg = sieve_ast_argument_string_create_raw
((*arg)->ast, newstr, (*arg)->source_line);
Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/sieve-message.c
Expand Up @@ -482,7 +482,7 @@ static inline string_t *_header_right_trim(const char *raw)
if ( *p != ' ' && *p != '\t' ) break;
}
result = t_str_new(p - raw + 1);
str_append_n(result, raw, p - raw + 1);
str_append_data(result, raw, p - raw + 1);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/storage/ldap/sieve-ldap-db.c
Expand Up @@ -983,7 +983,7 @@ const char *ldap_escape(const char *str)
return str;

ret = t_str_new((size_t) (p - str) + 64);
str_append_n(ret, str, (size_t) (p - str));
str_append_data(ret, str, (size_t) (p - str));

for (; *p != '\0'; p++) {
if (IS_LDAP_ESCAPED_CHAR(*p))
Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/util/edit-mail.c
Expand Up @@ -438,7 +438,7 @@ static inline char *_header_value_unfold
}

out = t_str_new(i + strlen(value+i) + 10);
str_append_n(out, value, i);
str_append_data(out, value, i);
for ( ; value[i] != '\0'; i++ ) {
if (value[i] == '\n') {
i++;
Expand Down
8 changes: 4 additions & 4 deletions src/lib-sieve/util/rfc2822.c
Expand Up @@ -133,7 +133,7 @@ unsigned int rfc2822_header_append
unsigned int lines = 0;

/* Write header field name first */
str_append_n(header, name, line_len);
str_append(header, name);
str_append(header, ": ");

if ( body_offset_r != NULL )
Expand Down Expand Up @@ -163,7 +163,7 @@ unsigned int rfc2822_header_append
while ( *bp == '\r' || *bp == '\n' )
bp++;

str_append_n(header, sp, nlp-sp);
str_append_data(header, sp, nlp-sp);

if ( crlf )
str_append(header, "\r\n");
Expand All @@ -180,7 +180,7 @@ unsigned int rfc2822_header_append
sp = bp;
} else {
/* Insert newline at last whitespace within the max_line limit */
str_append_n(header, sp, wp-sp);
str_append_data(header, sp, wp-sp);

/* Force continued line; drop any existing whitespace */
while ( *wp == ' ' || *wp == '\t' )
Expand All @@ -205,7 +205,7 @@ unsigned int rfc2822_header_append
}

if ( bp != sp || lines == 0 ) {
str_append_n(header, sp, bp-sp);
str_append_data(header, sp, bp-sp);
if ( crlf )
str_append(header, "\r\n");
else
Expand Down
4 changes: 2 additions & 2 deletions src/lib-sieve/util/test-edit-mail.c
Expand Up @@ -37,12 +37,12 @@ static void str_append_no_cr(string_t *str, const char *cstr)
poff = p = cstr;
while (*p != '\0') {
if (*p == '\r') {
str_append_n(str, poff, (p - poff));
str_append_data(str, poff, (p - poff));
poff = p+1;
}
p++;
}
str_append_n(str, poff, (p - poff));
str_append_data(str, poff, (p - poff));
}

static int test_init_mail_user(void)
Expand Down
2 changes: 1 addition & 1 deletion src/managesieve-login/client-authenticate.c
Expand Up @@ -209,7 +209,7 @@ static int managesieve_client_auth_read_response
return -1;
}

str_append_n(client->auth_response, data, size);
str_append_data(client->auth_response, data, size);
i_stream_skip(msieve_client->auth_response_input, size);
}

Expand Down
4 changes: 2 additions & 2 deletions src/testsuite/testsuite-arguments.c
Expand Up @@ -120,7 +120,7 @@ static bool arg_testsuite_string_validate
*/
if ( substart > strstart ) {
string_t *newstr = str_new(pool, substart - strstart);
str_append_n(newstr, strstart, substart - strstart);
str_append_data(newstr, strstart, substart - strstart);

strarg = sieve_ast_argument_string_create_raw
((*arg)->ast, newstr, (*arg)->source_line);
Expand Down Expand Up @@ -174,7 +174,7 @@ static bool arg_testsuite_string_validate
if ( strend > strstart ) {
struct sieve_ast_argument *strarg;
string_t *newstr = str_new(pool, strend - strstart);
str_append_n(newstr, strstart, strend - strstart);
str_append_data(newstr, strstart, strend - strstart);

strarg = sieve_ast_argument_string_create_raw
((*arg)->ast, newstr, (*arg)->source_line);
Expand Down

0 comments on commit 8647d31

Please sign in to comment.