Source-Changes-HG archive

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

[src/trunk]: src/usr.bin separate the 3 functions midirecord uses from libaud...



details:   https://anonhg.NetBSD.org/src/rev/d003276c3066
branches:  trunk
changeset: 338979:d003276c3066
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Jun 21 06:06:01 2015 +0000

description:
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.

diffstat:

 usr.bin/audio/common/Makefile |    4 +-
 usr.bin/audio/common/audio.c  |   81 +---------------------------
 usr.bin/audio/common/decode.c |  121 ++++++++++++++++++++++++++++++++++++++++++
 usr.bin/midirecord/Makefile   |   11 ++-
 4 files changed, 132 insertions(+), 85 deletions(-)

diffs (267 lines):

diff -r 7e255b569a25 -r d003276c3066 usr.bin/audio/common/Makefile
--- a/usr.bin/audio/common/Makefile     Sun Jun 21 06:04:45 2015 +0000
+++ b/usr.bin/audio/common/Makefile     Sun Jun 21 06:06:01 2015 +0000
@@ -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>
diff -r 7e255b569a25 -r d003276c3066 usr.bin/audio/common/audio.c
--- a/usr.bin/audio/common/audio.c      Sun Jun 21 06:04:45 2015 +0000
+++ b/usr.bin/audio/common/audio.c      Sun Jun 21 06:06:01 2015 +0000
@@ -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 @@
                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.
  */
diff -r 7e255b569a25 -r d003276c3066 usr.bin/audio/common/decode.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/audio/common/decode.c     Sun Jun 21 06:06:01 2015 +0000
@@ -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);
+}
diff -r 7e255b569a25 -r d003276c3066 usr.bin/midirecord/Makefile
--- a/usr.bin/midirecord/Makefile       Sun Jun 21 06:04:45 2015 +0000
+++ b/usr.bin/midirecord/Makefile       Sun Jun 21 06:06:01 2015 +0000
@@ -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>



Home | Main Index | Thread Index | Old Index