Module Name:    src
Committed By:   mrg
Date:           Sun Jun 21 06:06:01 UTC 2015

Modified Files:
        src/usr.bin/audio/common: Makefile audio.c
        src/usr.bin/midirecord: Makefile
Added Files:
        src/usr.bin/audio/common: decode.c

Log Message:
separate the 3 functions midirecord uses from libaudio.a into its own
file and link it directly, instead of having an (implicit) dependancy
on usr.bin/audio/common being built before usr.bin/midirecord is linked.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/audio/common/Makefile
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/audio/common/audio.c
cvs rdiff -u -r0 -r1.1 src/usr.bin/audio/common/decode.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/midirecord/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/audio/common/Makefile
diff -u src/usr.bin/audio/common/Makefile:1.8 src/usr.bin/audio/common/Makefile:1.9
--- src/usr.bin/audio/common/Makefile:1.8	Sat May  3 14:48:31 2008
+++ src/usr.bin/audio/common/Makefile	Sun Jun 21 06:06:01 2015
@@ -1,8 +1,8 @@
-#	$NetBSD: Makefile,v 1.8 2008/05/03 14:48:31 lukem Exp $
+#	$NetBSD: Makefile,v 1.9 2015/06/21 06:06:01 mrg Exp $
 
 LIBISPRIVATE=	yes
 
 LIB=	audio
-SRCS=	audio.c wav.c sun.c
+SRCS=	audio.c decode.c wav.c sun.c
 
 .include <bsd.lib.mk>

Index: src/usr.bin/audio/common/audio.c
diff -u src/usr.bin/audio/common/audio.c:1.23 src/usr.bin/audio/common/audio.c:1.24
--- src/usr.bin/audio/common/audio.c:1.23	Tue Dec 30 01:22:09 2014
+++ src/usr.bin/audio/common/audio.c	Sun Jun 21 06:06:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.23 2014/12/30 01:22:09 mrg Exp $	*/
+/*	$NetBSD: audio.c,v 1.24 2015/06/21 06:06:01 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -32,7 +32,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: audio.c,v 1.23 2014/12/30 01:22:09 mrg Exp $");
+__RCSID("$NetBSD: audio.c,v 1.24 2015/06/21 06:06:01 mrg Exp $");
 #endif
 
 
@@ -139,83 +139,6 @@ audio_enc_to_val(const char *enc)
 		return (AUDIO_ENOENT);
 }
 
-void
-decode_int(const char *arg, int *intp)
-{
-	char	*ep;
-	int	ret;
-
-	ret = (int)strtoul(arg, &ep, 10);
-
-	if (ep[0] == '\0') {
-		*intp = ret;
-		return;
-	}
-	errx(1, "argument `%s' not a valid integer", arg);
-}
-
-void
-decode_uint(const char *arg, unsigned *intp)
-{
-	char	*ep;
-	unsigned	ret;
-
-	ret = (unsigned)strtoul(arg, &ep, 10);
-
-	if (ep[0] == '\0') {
-		*intp = ret;
-		return;
-	}
-	errx(1, "argument `%s' not a valid integer", arg);
-}
-
-void
-decode_time(const char *arg, struct timeval *tvp)
-{
-	char	*s, *colon, *dot;
-	char	*copy = strdup(arg);
-	int	first;
-
-	if (copy == NULL)
-		err(1, "could not allocate a copy of %s", arg);
-
-	tvp->tv_sec = tvp->tv_usec = 0;
-	s = copy;
-	
-	/* handle [hh:]mm:ss.dd */
-	if ((colon = strchr(s, ':')) != NULL) {
-		*colon++ = '\0';
-		decode_int(s, &first);
-		tvp->tv_sec = first * 60;	/* minutes */
-		s = colon;
-
-		if ((colon = strchr(s, ':')) != NULL) {
-			*colon++ = '\0';
-			decode_int(s, &first);
-			tvp->tv_sec += first;	/* minutes and hours */
-			tvp->tv_sec *= 60;
-			s = colon;
-		}
-	}
-	if ((dot = strchr(s, '.')) != NULL) {
-		int 	i, base = 100000;
-
-		*dot++ = '\0';
-
-		for (i = 0; i < 6; i++, base /= 10) {
-			if (!dot[i])
-				break;
-			if (!isdigit((unsigned char)dot[i]))
-				errx(1, "argument `%s' is not a value time specification", arg);
-			tvp->tv_usec += base * (dot[i] - '0');
-		}
-	}
-	decode_int(s, &first);
-	tvp->tv_sec += first;
-
-	free(copy);
-}
-
 /*
  * decode a string into an encoding value.
  */

Index: src/usr.bin/midirecord/Makefile
diff -u src/usr.bin/midirecord/Makefile:1.1 src/usr.bin/midirecord/Makefile:1.2
--- src/usr.bin/midirecord/Makefile:1.1	Tue Dec 30 04:14:25 2014
+++ src/usr.bin/midirecord/Makefile	Sun Jun 21 06:06:01 2015
@@ -1,15 +1,18 @@
-#	$NetBSD: Makefile,v 1.1 2014/12/30 04:14:25 mrg Exp $
+#	$NetBSD: Makefile,v 1.2 2015/06/21 06:06:01 mrg Exp $
 
+SRCS=	midirecord decode.c
 PROG=	midirecord
 
 .include <bsd.own.mk>
 
-LIBAUDIO != cd ${.CURDIR}/../audio/common && ${PRINTOBJDIR}
+#LIBAUDIO != cd ${.CURDIR}/../audio/common && ${PRINTOBJDIR}
 CPPFLAGS+=-I${.CURDIR}/../audio/common
-DPADD+=	${LIBAUDIO}/libaudio.a
-LDADD+=	-L${LIBAUDIO} -laudio
+#DPADD+=	${LIBAUDIO}/libaudio.a
+#LDADD+=	-L${LIBAUDIO} -laudio
 
 DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
 
+.PATH: ${.CURDIR}/../audio/common
+
 .include <bsd.prog.mk>

Added files:

Index: src/usr.bin/audio/common/decode.c
diff -u /dev/null src/usr.bin/audio/common/decode.c:1.1
--- /dev/null	Sun Jun 21 06:06:02 2015
+++ src/usr.bin/audio/common/decode.c	Sun Jun 21 06:06:01 2015
@@ -0,0 +1,121 @@
+/*	$NetBSD: decode.c,v 1.1 2015/06/21 06:06:01 mrg Exp $	*/
+
+/*
+ * Copyright (c) 1999 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#ifndef lint
+__RCSID("$NetBSD: decode.c,v 1.1 2015/06/21 06:06:01 mrg Exp $");
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <err.h>
+
+#include "libaudio.h"
+
+void
+decode_int(const char *arg, int *intp)
+{
+	char	*ep;
+	int	ret;
+
+	ret = (int)strtoul(arg, &ep, 10);
+
+	if (ep[0] == '\0') {
+		*intp = ret;
+		return;
+	}
+	errx(1, "argument `%s' not a valid integer", arg);
+}
+
+void
+decode_uint(const char *arg, unsigned *intp)
+{
+	char	*ep;
+	unsigned	ret;
+
+	ret = (unsigned)strtoul(arg, &ep, 10);
+
+	if (ep[0] == '\0') {
+		*intp = ret;
+		return;
+	}
+	errx(1, "argument `%s' not a valid integer", arg);
+}
+
+void
+decode_time(const char *arg, struct timeval *tvp)
+{
+	char	*s, *colon, *dot;
+	char	*copy = strdup(arg);
+	int	first;
+
+	if (copy == NULL)
+		err(1, "could not allocate a copy of %s", arg);
+
+	tvp->tv_sec = tvp->tv_usec = 0;
+	s = copy;
+	
+	/* handle [hh:]mm:ss.dd */
+	if ((colon = strchr(s, ':')) != NULL) {
+		*colon++ = '\0';
+		decode_int(s, &first);
+		tvp->tv_sec = first * 60;	/* minutes */
+		s = colon;
+
+		if ((colon = strchr(s, ':')) != NULL) {
+			*colon++ = '\0';
+			decode_int(s, &first);
+			tvp->tv_sec += first;	/* minutes and hours */
+			tvp->tv_sec *= 60;
+			s = colon;
+		}
+	}
+	if ((dot = strchr(s, '.')) != NULL) {
+		int 	i, base = 100000;
+
+		*dot++ = '\0';
+
+		for (i = 0; i < 6; i++, base /= 10) {
+			if (!dot[i])
+				break;
+			if (!isdigit((unsigned char)dot[i]))
+				errx(1, "argument `%s' is not a value time specification", arg);
+			tvp->tv_usec += base * (dot[i] - '0');
+		}
+	}
+	decode_int(s, &first);
+	tvp->tv_sec += first;
+
+	free(copy);
+}

Reply via email to