Browse Source

access:http: change the scanf/printf format modifiers when using uintmax_t

PRI(uxd)MAX for printf and SCN(uxd)MAX for scanf are supported in C99 and even
in MSVC 2013, unlike the j modifier.
pull/73/head
Steve Lhomme 8 years ago
parent
commit
06d86ae408
  1. 2
      modules/access/http/chunked.c
  2. 8
      modules/access/http/file.c
  3. 2
      modules/access/http/message.c

2
modules/access/http/chunked.c

@ -83,7 +83,7 @@ static block_t *vlc_chunked_read(struct vlc_http_stream *stream)
int end;
if (sscanf(line, "%jx%n", &s->chunk_length, &end) < 1
if (sscanf(line, "%" SCNxMAX "%n", &s->chunk_length, &end) < 1
|| (line[end] != '\0' && line[end] != ';' /* ignore extension(s) */))
s->chunk_length = UINTMAX_MAX;

8
modules/access/http/file.c

@ -69,7 +69,7 @@ static int vlc_http_file_req(const struct vlc_http_resource *res,
}
}
if (vlc_http_msg_add_header(req, "Range", "bytes=%ju-", *offset)
if (vlc_http_msg_add_header(req, "Range", "bytes=%" PRIuMAX "-", *offset)
&& *offset != 0)
return -1;
return 0;
@ -89,7 +89,7 @@ static int vlc_http_file_resp(const struct vlc_http_resource *res,
goto fail;
uintmax_t start, end;
if (sscanf(str, "bytes %ju-%ju", &start, &end) != 2
if (sscanf(str, "bytes %" SCNuMAX "-%" SCNuMAX, &start, &end) != 2
|| start != *offset || start > end)
/* A single range response is what we asked for, but not at that
* start offset. */
@ -140,7 +140,7 @@ static uintmax_t vlc_http_msg_get_file_size(const struct vlc_http_msg *resp)
uintmax_t end, total;
switch (sscanf(range, "bytes %*u-%ju/%ju", &end, &total))
switch (sscanf(range, "bytes %*u-%" SCNuMAX "/%" SCNuMAX, &end, &total))
{
case 1:
if (unlikely(end == UINTMAX_MAX))
@ -159,7 +159,7 @@ static uintmax_t vlc_http_msg_get_file_size(const struct vlc_http_msg *resp)
if (range == NULL)
return -1; /* valid but helpless response */
if (sscanf(range, "bytes */%ju", &total) == 1)
if (sscanf(range, "bytes */%" SCNuMAX, &total) == 1)
return total; /* this occurs when seeking beyond EOF */
}

2
modules/access/http/message.c

@ -876,7 +876,7 @@ uintmax_t vlc_http_msg_get_size(const struct vlc_http_msg *m)
uintmax_t length;
if (sscanf(str, "%ju", &length) == 1)
if (sscanf(str, "%" SCNuMAX, &length) == 1)
return length;
errno = EINVAL;

Loading…
Cancel
Save