Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/midirecord be explicit about stdout mode.



details:   https://anonhg.NetBSD.org/src/rev/024b37e94cc0
branches:  trunk
changeset: 336435:024b37e94cc0
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Mar 01 09:56:54 2015 +0000

description:
be explicit about stdout mode.

diffstat:

 usr.bin/midirecord/midirecord.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (56 lines):

diff -r dc2d845f59d2 -r 024b37e94cc0 usr.bin/midirecord/midirecord.c
--- a/usr.bin/midirecord/midirecord.c   Sun Mar 01 09:53:36 2015 +0000
+++ b/usr.bin/midirecord/midirecord.c   Sun Mar 01 09:56:54 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: midirecord.c,v 1.6 2015/01/03 22:57:54 joerg Exp $     */
+/*     $NetBSD: midirecord.c,v 1.7 2015/03/01 09:56:54 mrg Exp $       */
 
 /*
  * Copyright (c) 2014 Matthew R. Green
@@ -33,7 +33,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: midirecord.c,v 1.6 2015/01/03 22:57:54 joerg Exp $");
+__RCSID("$NetBSD: midirecord.c,v 1.7 2015/03/01 09:56:54 mrg Exp $");
 #endif
 
 #include <sys/param.h>
@@ -74,6 +74,7 @@
 static int     tempo = 120;
 static unsigned        notes_per_beat = 24;
 static bool ignore_timer_fail = false;
+static bool stdout_mode = false;
 
 static void debug_log(const char *, size_t, const char *, ...)
     __printflike(3, 4);
@@ -191,8 +192,10 @@
                outfd = open(*argv, mode, 0666);
                if (outfd < 0)
                        err(1, "could not open %s", *argv);
-       } else
+       } else {
+               stdout_mode = true;
                outfd = STDOUT_FILENO;
+       }
 
        /* open the raw output file */
        if (raw_output) {
@@ -711,7 +714,7 @@
 {
 
        /* can't do this here! */
-       if (outfd == STDOUT_FILENO)
+       if (stdout_mode)
                return;
 
        if (lseek(outfd, (off_t)0, SEEK_SET) == (off_t)-1)
@@ -734,7 +737,7 @@
                0, 0, /* ntracks */
                0, 0, /* notes per beat */
        };
-       /* XXX only spport one track so far */
+       /* XXX only support one track so far */
        unsigned ntracks = 1;
        unsigned char track[] = {
                'M', 'T', 'r', 'k',



Home | Main Index | Thread Index | Old Index