mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
fixes from MSVC compile
This commit is contained in:
@@ -1218,10 +1218,11 @@ static FLAC__StreamDecoderWriteStatus chain_read_ogg_write_cb_(const FLAC__Strea
|
|||||||
static void chain_read_ogg_metadata_cb_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
|
static void chain_read_ogg_metadata_cb_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
|
||||||
{
|
{
|
||||||
FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data;
|
FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data;
|
||||||
|
FLAC__Metadata_Node *node;
|
||||||
|
|
||||||
(void)decoder;
|
(void)decoder;
|
||||||
|
|
||||||
FLAC__Metadata_Node *node = node_new_();
|
node = node_new_();
|
||||||
if(0 == node) {
|
if(0 == node) {
|
||||||
chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
|
chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -835,7 +835,8 @@ FLAC__bool parse_uint32(const char *src, FLAC__uint32 *dest)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There's no stroull() in MSVC6 so we just write a specialized one */
|
#ifdef _MSC_VER
|
||||||
|
/* There's no strtoull() in MSVC6 so we just write a specialized one */
|
||||||
static FLAC__uint64 local__strtoull(const char *src)
|
static FLAC__uint64 local__strtoull(const char *src)
|
||||||
{
|
{
|
||||||
FLAC__uint64 ret = 0;
|
FLAC__uint64 ret = 0;
|
||||||
@@ -850,13 +851,18 @@ static FLAC__uint64 local__strtoull(const char *src)
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FLAC__bool parse_uint64(const char *src, FLAC__uint64 *dest)
|
FLAC__bool parse_uint64(const char *src, FLAC__uint64 *dest)
|
||||||
{
|
{
|
||||||
FLAC__ASSERT(0 != src);
|
FLAC__ASSERT(0 != src);
|
||||||
if(strlen(src) == 0 || strspn(src, "0123456789") != strlen(src))
|
if(strlen(src) == 0 || strspn(src, "0123456789") != strlen(src))
|
||||||
return false;
|
return false;
|
||||||
|
#ifdef _MSC_VER
|
||||||
*dest = local__strtoull(src);
|
*dest = local__strtoull(src);
|
||||||
|
#else
|
||||||
|
*dest = strtoull(src, 0, 10);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,32 @@
|
|||||||
#include <stdlib.h> /* for atoi() */
|
#include <stdlib.h> /* for atoi() */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
/* There's no strtoll() in MSVC6 so we just write a specialized one */
|
||||||
|
static FLAC__int64 local__strtoll(const char *src, char **endptr)
|
||||||
|
{
|
||||||
|
FLAC__bool neg = false;
|
||||||
|
FLAC__int64 ret = 0;
|
||||||
|
int c;
|
||||||
|
FLAC__ASSERT(0 != src);
|
||||||
|
if(*src == '-') {
|
||||||
|
neg = true;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
while(0 != (c = *src)) {
|
||||||
|
c -= '0';
|
||||||
|
if(c >= 0 && c <= 9)
|
||||||
|
ret = (ret * 10) + c;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
if(endptr)
|
||||||
|
*endptr = (char*)src;
|
||||||
|
return neg? -ret : ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, unsigned sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points)
|
FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, unsigned sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@@ -82,7 +108,7 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec
|
|||||||
if(!only_explicit_placeholders) {
|
if(!only_explicit_placeholders) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
const FLAC__int64 n = (FLAC__int64)strtol(pt, &endptr, 10); /* [2G limit] */
|
const FLAC__int64 n = local__strtoll(pt, &endptr);
|
||||||
#else
|
#else
|
||||||
const FLAC__int64 n = (FLAC__int64)strtoll(pt, &endptr, 10);
|
const FLAC__int64 n = (FLAC__int64)strtoll(pt, &endptr, 10);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -309,6 +309,24 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, off_t fi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
/* There's no strtoull() in MSVC6 so we just write a specialized one */
|
||||||
|
static FLAC__uint64 local__strtoull(const char *src)
|
||||||
|
{
|
||||||
|
FLAC__uint64 ret = 0;
|
||||||
|
int c;
|
||||||
|
FLAC__ASSERT(0 != src);
|
||||||
|
while(0 != (c = *src++)) {
|
||||||
|
c -= '0';
|
||||||
|
if(c >= 0 && c <= 9)
|
||||||
|
ret = (ret * 10) + c;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *filename;
|
const char *filename;
|
||||||
@@ -328,7 +346,11 @@ int main(int argc, char *argv[])
|
|||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
count = strtoul(argv[2], 0, 10);
|
count = strtoul(argv[2], 0, 10);
|
||||||
if (argc > 3)
|
if (argc > 3)
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
samples = local__strtoull(argv[3]);
|
||||||
|
#else
|
||||||
samples = strtoull(argv[3], 0, 10);
|
samples = strtoull(argv[3], 0, 10);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (count < 30)
|
if (count < 30)
|
||||||
fprintf(stderr, "WARNING: random seeks don't kick in until after 30 preprogrammed ones\n");
|
fprintf(stderr, "WARNING: random seeks don't kick in until after 30 preprogrammed ones\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user