_snprintf hackery for MSVC6
authorJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 10 Oct 2006 00:36:59 +0000 (00:36 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 10 Oct 2006 00:36:59 +0000 (00:36 +0000)
src/flac/utils.c
src/metaflac/operations_shorthand_cuesheet.c
src/test_grabbag/picture/main.c

index 401f511..15d715a 100644 (file)
@@ -25,6 +25,7 @@
 #include "FLAC/metadata.h"
 #include <math.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -282,7 +283,11 @@ FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__
        FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
        FLAC__ASSERT(strlen(CHANNEL_MASK_TAG+1+2+16+1) <= sizeof(tag)); /* +1 for =, +2 for 0x, +16 for digits, +1 for NUL */
        entry.entry = (FLAC__byte*)tag;
+#if defined _MSC_VER || defined __MINGW32__
+       if((entry.length = _snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (unsigned)channel_mask)) >= sizeof(tag))
+#else
        if((entry.length = snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (unsigned)channel_mask)) >= sizeof(tag))
+#endif
                return false;
        if(!FLAC__metadata_object_vorbiscomment_replace_comment(object, entry, /*all=*/true, /*copy=*/true))
                return false;
index bd37fd4..c4be6fe 100644 (file)
@@ -199,7 +199,7 @@ FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cueshe
                return false;
        }
 
-#ifdef _MSC_VER
+#if defined _MSC_VER || defined __MINGW32__
        _snprintf(ref, reflen, "\"%s\" FLAC", filename);
 #else
        snprintf(ref, reflen, "\"%s\" FLAC", filename);
index c17f4bc..68800e9 100644 (file)
@@ -69,7 +69,11 @@ static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, co
        FLAC__StreamMetadata *obj;
        const char *error;
        char s[4096];
+#if defined _MSC_VER || defined __MINGW32__
+       _snprintf(s, sizeof(s)-1, "%u|%s|%s|%s|%s/%s", (unsigned)pf->type, pf->mime_type, pf->description, res, prefix, pf->path);
+#else
        snprintf(s, sizeof(s)-1, "%u|%s|%s|%s|%s/%s", (unsigned)pf->type, pf->mime_type, pf->description, res, prefix, pf->path);
+#endif
 
        printf("testing grabbag__picture_parse_specification(\"%s\")... ", s);
        if(0 == (obj = grabbag__picture_parse_specification(s, &error)))