fix strptokspn, add strcspn, fix splash.c

fix off by 1 error in strptokspn, add strcspn, fix fallout in splash.c

Change-Id: I61475d9633fc35db5a8ae30cbe588f69f2f7fabc
This commit is contained in:
William Wilgus 2022-11-13 00:43:43 -05:00 committed by William Wilgus
parent ffe2df2e92
commit a634557a88
5 changed files with 65 additions and 36 deletions

View file

@ -73,11 +73,11 @@ static bool splash_internal(struct screen * screen, const char *fmt, va_list ap,
if (!next)
return false; /* nothing to display */
lines[line].len = next_len + 1;
lines[line].len = next_len;
lines[line].str = next;
while (true)
{
w = font_getstringnsize(next, next_len + 1, NULL, NULL, fontnum);
w = font_getstringnsize(next, next_len, NULL, NULL, fontnum);
if (lastbreak)
{
len = next - lastbreak;
@ -90,18 +90,19 @@ static bool splash_internal(struct screen * screen, const char *fmt, va_list ap,
break; /* screen full or out of lines */
x = 0;
y += chr_h;
lines[++line].len = next_len + len;
lines[++line].len = next_len;
lines[line].str = next;
}
else
{
/* restore & calculate spacing */
lines[line].len += next_len + len + 1;
lines[line].len += next_len + 1;
x += next_w;
}
}
x += w;
lastbreak = next + next_len + 1;
lastbreak = next + next_len;
lastbrkchr = *lastbreak;
next = strptokspn_r(NULL, matchstr, &next_len, &store);

View file

@ -1483,7 +1483,7 @@ static bool audio_init_codec(struct track_info *track_infop,
enum { AUTORESUMABLE_UNKNOWN = 0, AUTORESUMABLE_TRUE, AUTORESUMABLE_FALSE };
static bool autoresumable(struct mp3entry *id3)
{
char *endp, *path;
char *path;
size_t len;
bool is_resumable;
@ -1501,13 +1501,7 @@ static bool autoresumable(struct mp3entry *id3)
if (*path == ':') /* Skip empty search patterns */
continue;
/* FIXME: As soon as strcspn or strchrnul are made available in
the core, the following can be made more efficient. */
endp = strchr(path, ':');
if (endp)
len = endp - path;
else
len = strlen(path);
len = strcspn(path, ":");
/* Note: At this point, len is always > 0 */