Use new function flac_snprintf() where ever appropriate.
[platform/upstream/flac.git] / src / metaflac / operations_shorthand_cuesheet.c
index 4393a16..f59bc89 100644 (file)
@@ -11,9 +11,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #if HAVE_CONFIG_H
 #endif
 
 #include <errno.h>
-#if HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#include <stdio.h> /* for snprintf() */
 #include <string.h>
 #include "options.h"
 #include "utils.h"
 #include "FLAC/assert.h"
 #include "share/grabbag.h"
+#include "share/compat.h"
 #include "operations_shorthand.h"
 
 static FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet, const char *cs_filename, FLAC__bool *needs_write, FLAC__uint64 lead_out_offset, unsigned sample_rate, FLAC__bool is_cdda, Argument_AddSeekpoint *add_seekpoint_link);
@@ -165,7 +162,7 @@ FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet,
                for(track = 0; track < cs->num_tracks; track++) {
                        const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+track;
                        for(index = 0; index < tr->num_indices; index++) {
-                               sprintf(spec, "%" PRIu64 ";", (tr->offset + tr->indices[index].offset));
+                               flac_snprintf(spec, sizeof (spec), "%" PRIu64 ";", (tr->offset + tr->indices[index].offset));
                                local_strcat(seekpoint_specification, spec);
                        }
                }
@@ -198,14 +195,12 @@ FLAC__bool export_cs_to(const char *filename, const FLAC__StreamMetadata *cueshe
        reflen = strlen(filename) + 7 + 1;
        if(0 == (ref = malloc(reflen))) {
                fprintf(stderr, "%s: ERROR: allocating memory\n", filename);
+               if(f != stdout)
+                       fclose(f);
                return false;
        }
 
-#if defined _MSC_VER || defined __MINGW32__
-       _snprintf(ref, reflen, "\"%s\" FLAC", filename);
-#else
-       snprintf(ref, reflen, "\"%s\" FLAC", filename);
-#endif
+       flac_snprintf(ref, reflen, "\"%s\" FLAC", filename);
 
        grabbag__cuesheet_emit(f, cuesheet, ref);