MT#55283 change str_token_sep semantics a bit

If there are no more tokens, instead of returning a null string as
remainder, set the remainder to the end of the original string with a
zero length.

Update two places in the code where this makes a difference.

Change-Id: I137fbce3e7d88ccba65f6b23a36aa1dfbbd3867e
pull/1855/head
Richard Fuchs 1 year ago
parent b3a50d5e01
commit ad31048499

@ -255,7 +255,7 @@ void parse_rtpp_flags(const str * rtpp_flags, sdp_ng_flags *out)
generic:
/* generic one key flags */
if (!val.s)
if (!val.len)
call_ng_flags_flags(&key, 0, out);
/* generic flags with value, but no particular processing */
else

@ -436,8 +436,11 @@ INLINE unsigned long long str_to_ui(const str *s, unsigned long long def) {
INLINE bool str_token(str *new_token, str *ori_and_remainder, int sep) {
*new_token = *ori_and_remainder;
if (!str_chr_str(ori_and_remainder, ori_and_remainder, sep))
if (!str_chr_str(ori_and_remainder, ori_and_remainder, sep)) {
*ori_and_remainder = *new_token;
str_shift(ori_and_remainder, ori_and_remainder->len);
return false;
}
new_token->len = ori_and_remainder->s - new_token->s;
if (str_shift(ori_and_remainder, 1))
return false;
@ -445,6 +448,10 @@ INLINE bool str_token(str *new_token, str *ori_and_remainder, int sep) {
}
INLINE bool str_token_sep(str *new_token, str *ori_and_remainder, int sep) {
if (ori_and_remainder->len == 0) {
*new_token = STR_NULL;
return false;
}
str ori = *ori_and_remainder;
if (str_token(new_token, ori_and_remainder, sep))
return true;

Loading…
Cancel
Save