Make build on Mac with "gcc miditones.c -o miditones" without warning or errors.

pull/4/head
Dean Blackketter 9 years ago
parent 9f0396e967
commit 33e5fce907
  1. 30
      miditones.c

@ -354,13 +354,11 @@ void print_command_line (int argc,char *argv[]) {
} }
/**************** utility routines **********************/ /**************** utility routines **********************/
/* safe string copy */ /* safe string copy */
size_t miditones_strlcpy(char *dst, const char *src, size_t siz) {
size_t strlcpy(char *dst, const char *src, size_t siz) {
char *d = dst; char *d = dst;
const char *s = src; const char *s = src;
size_t n = siz; size_t n = siz;
@ -386,7 +384,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz) {
/* safe string concatenation */ /* safe string concatenation */
size_t strlcat(char *dst, const char *src, size_t siz) { size_t miditones_strlcat(char *dst, const char *src, size_t siz) {
char *d = dst; char *d = dst;
const char *s = src; const char *s = src;
size_t n = siz; size_t n = siz;
@ -472,7 +470,7 @@ void process_header (void) {
chk_bufdata(hdrptr, sizeof(struct midi_header)); chk_bufdata(hdrptr, sizeof(struct midi_header));
hdr = (struct midi_header *) hdrptr; hdr = (struct midi_header *) hdrptr;
if (!charcmp(hdr->MThd,"MThd")) midi_error("Missing 'MThd'", hdrptr); if (!charcmp((char*)hdr->MThd,"MThd")) midi_error("Missing 'MThd'", hdrptr);
num_tracks = rev_short(hdr->number_of_tracks); num_tracks = rev_short(hdr->number_of_tracks);
@ -501,7 +499,7 @@ void start_track (int tracknum) {
chk_bufdata(hdrptr, sizeof(struct track_header)); chk_bufdata(hdrptr, sizeof(struct track_header));
hdr = (struct track_header *) hdrptr; hdr = (struct track_header *) hdrptr;
if (!charcmp(hdr->MTrk,"MTrk")) midi_error("Missing 'MTrk'", hdrptr); if (!charcmp((char*)hdr->MTrk,"MTrk")) midi_error("Missing 'MTrk'", hdrptr);
tracklen = rev_long(hdr->track_size); tracklen = rev_long(hdr->track_size);
if (logparse) fprintf (logfile, "\nTrack %d length %ld\n", tracknum, tracklen); if (logparse) fprintf (logfile, "\nTrack %d length %ld\n", tracknum, tracklen);
@ -554,7 +552,11 @@ void find_note (int tracknum) {
delta_time = get_varlen(&t->trkptr); delta_time = get_varlen(&t->trkptr);
if (logparse) { if (logparse) {
fprintf (logfile, "trk %d ", tracknum); fprintf (logfile, "trk %d ", tracknum);
fprintf (logfile, delta_time ? "delta time %4ld, " : " ", delta_time); if (delta_time) {
fprintf (logfile, "delta time %4ld, ", delta_time);
} else {
fprintf (logfile, " ");
}
} }
t->time += delta_time; t->time += delta_time;
@ -708,8 +710,8 @@ int main(int argc,char *argv[]) {
/* Open the log file */ /* Open the log file */
if (logparse || loggen) { if (logparse || loggen) {
strlcpy(filename, filebasename, MAXPATH); miditones_strlcpy(filename, filebasename, MAXPATH);
strlcat(filename, ".log", MAXPATH); miditones_strlcat(filename, ".log", MAXPATH);
logfile = fopen(filename, "w"); logfile = fopen(filename, "w");
if (!logfile) { if (!logfile) {
fprintf(stderr, "Unable to open log file %s", filename); fprintf(stderr, "Unable to open log file %s", filename);
@ -719,8 +721,8 @@ int main(int argc,char *argv[]) {
/* Open the input file */ /* Open the input file */
strlcpy(filename, filebasename, MAXPATH); miditones_strlcpy(filename, filebasename, MAXPATH);
strlcat(filename, ".mid", MAXPATH); miditones_strlcat(filename, ".mid", MAXPATH);
infile = fopen(filename, "rb"); infile = fopen(filename, "rb");
if (!infile) { if (!infile) {
fprintf(stderr, "Unable to open input file %s", filename); fprintf(stderr, "Unable to open input file %s", filename);
@ -746,13 +748,13 @@ int main(int argc,char *argv[]) {
/* Create the output file */ /* Create the output file */
if (!parseonly) { if (!parseonly) {
strlcpy(filename, filebasename, MAXPATH); miditones_strlcpy(filename, filebasename, MAXPATH);
if (binaryoutput) { if (binaryoutput) {
strlcat(filename, ".bin", MAXPATH); miditones_strlcat(filename, ".bin", MAXPATH);
outfile = fopen(filename, "wb"); outfile = fopen(filename, "wb");
} }
else { else {
strlcat(filename, ".c", MAXPATH); miditones_strlcat(filename, ".c", MAXPATH);
outfile = fopen(filename, "w"); outfile = fopen(filename, "w");
} }
if (!outfile) { if (!outfile) {

Loading…
Cancel
Save