Skip to content

Commit

Permalink
music_ogg.c: Replace str_to_int64 with SDL_strtoull(x, NULL, 10)
Browse files Browse the repository at this point in the history
This workaround is no more needed as SDL_strtoull with 10 base works as needed.
https://bugzilla.libsdl.org/show_bug.cgi?id=4855#c8
  • Loading branch information
Wohlstand committed Nov 17, 2019
1 parent efcb999 commit b8a6710
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions music_ogg.c
Expand Up @@ -223,25 +223,6 @@ static int OGG_UpdateSection(OGG_music *music)
return 0;
}

/* Convert string into integer with clean-up from junk and leading zeroes */
static ogg_int64_t str_to_int64(char *param)
{
char *front = param;
char *back;

/* Find digit between of 1 and 9 at begin */
while (*front != '\0' && (*front < '1' || *front > '9')) {
front++;
}
/* Find any non-digit character or NULL */
back = front;
while (*back != '\0' && (*back >= '0' && *back <= '9')) {
back++;
}
*back = '\0';
return (ogg_int64_t)SDL_strtoull(front, NULL, 0);
}

/* Parse time string of the form HH:MM:SS.mmm and return equivalent sample
* position */
static ogg_int64_t parse_time(char *time, long samplerate_hz)
Expand All @@ -252,7 +233,7 @@ static ogg_int64_t parse_time(char *time, long samplerate_hz)

/* Time is directly expressed as a sample position */
if (SDL_strchr(time, ':') == NULL) {
return str_to_int64(time);
return (ogg_int64_t)SDL_strtoull(time, NULL, 10);
}

result = 0;
Expand Down Expand Up @@ -336,7 +317,7 @@ static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc)
if (SDL_strcasecmp(argument, "LOOPSTART") == 0)
music->loop_start = parse_time(value, rate);
else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) {
music->loop_len = str_to_int64(value);
music->loop_len = (ogg_int64_t)SDL_strtoull(value, NULL, 10);
isLoopLength = 1;
} else if (SDL_strcasecmp(argument, "LOOPEND") == 0) {
isLoopLength = 0;
Expand Down

0 comments on commit b8a6710

Please sign in to comment.