From: Josh Coalson Date: Fri, 17 Nov 2006 06:05:02 +0000 (+0000) Subject: fixes from MSVC compile X-Git-Tag: 1.2.0~278 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0627a4e424f2388093b5fc5f312d421affa1ee4;p=platform%2Fupstream%2Fflac.git fixes from MSVC compile --- diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index 5449bee..d5c4490 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -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) { FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data; + FLAC__Metadata_Node *node; (void)decoder; - FLAC__Metadata_Node *node = node_new_(); + node = node_new_(); if(0 == node) { chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR; return; diff --git a/src/metaflac/options.c b/src/metaflac/options.c index 6e3acd5..9c9e591 100644 --- a/src/metaflac/options.c +++ b/src/metaflac/options.c @@ -835,7 +835,8 @@ FLAC__bool parse_uint32(const char *src, FLAC__uint32 *dest) 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) { FLAC__uint64 ret = 0; @@ -850,13 +851,18 @@ static FLAC__uint64 local__strtoull(const char *src) } return ret; } +#endif FLAC__bool parse_uint64(const char *src, FLAC__uint64 *dest) { FLAC__ASSERT(0 != src); if(strlen(src) == 0 || strspn(src, "0123456789") != strlen(src)) return false; +#ifdef _MSC_VER *dest = local__strtoull(src); +#else + *dest = strtoull(src, 0, 10); +#endif return true; } diff --git a/src/share/grabbag/seektable.c b/src/share/grabbag/seektable.c index 4594c6c..cb41b33 100644 --- a/src/share/grabbag/seektable.c +++ b/src/share/grabbag/seektable.c @@ -25,6 +25,32 @@ #include /* for atoi() */ #include +#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) { unsigned i; @@ -82,7 +108,7 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec if(!only_explicit_placeholders) { char *endptr; #ifdef _MSC_VER - const FLAC__int64 n = (FLAC__int64)strtol(pt, &endptr, 10); /* [2G limit] */ + const FLAC__int64 n = local__strtoll(pt, &endptr); #else const FLAC__int64 n = (FLAC__int64)strtoll(pt, &endptr, 10); #endif diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index 959dfe1..f31c4b3 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -309,6 +309,24 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, off_t fi 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[]) { const char *filename; @@ -328,7 +346,11 @@ int main(int argc, char *argv[]) if (argc > 2) count = strtoul(argv[2], 0, 10); if (argc > 3) +#ifdef _MSC_VER + samples = local__strtoull(argv[3]); +#else samples = strtoull(argv[3], 0, 10); +#endif if (count < 30) fprintf(stderr, "WARNING: random seeks don't kick in until after 30 preprogrammed ones\n");