From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 29 11:40:58 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 67E2B16A4CF for ; Thu, 29 Jan 2004 11:40:58 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F389243D46 for ; Thu, 29 Jan 2004 11:40:17 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i0TJeHFR030269 for ; Thu, 29 Jan 2004 11:40:17 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i0TJeH61030268; Thu, 29 Jan 2004 11:40:17 -0800 (PST) (envelope-from gnats) Resent-Date: Thu, 29 Jan 2004 11:40:17 -0800 (PST) Resent-Message-Id: <200401291940.i0TJeH61030268@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ronald Klop Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AB03716A4CF for ; Thu, 29 Jan 2004 11:30:35 -0800 (PST) Received: from klop.ws (node1f673.a2000.nl [24.132.246.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7ED9643D46 for ; Thu, 29 Jan 2004 11:30:33 -0800 (PST) (envelope-from ronald@klop.ws) Received: from klop.ws (localhost [127.0.0.1]) by henk.thuis.klop.ws (8.12.10/8.12.10) with ESMTP id i0TJ4gVa001389; Thu, 29 Jan 2004 20:04:42 +0100 (CET) (envelope-from ronald@klop.ws) Received: (from ronald@localhost) by klop.ws (8.12.10/8.12.10/Submit) id i0TJ4gEO001388; Thu, 29 Jan 2004 20:04:42 +0100 (CET) (envelope-from ronald) Message-Id: <200401291904.i0TJ4gEO001388@klop.ws> Date: Thu, 29 Jan 2004 20:04:42 +0100 (CET) From: Ronald Klop To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: Ronald Klop Subject: bin/62077: Make it possible to abbreviate device names. (patch included) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Ronald Klop List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2004 19:40:58 -0000 >Number: 62077 >Category: bin >Synopsis: Make it possible to abbreviate device names. (patch included) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jan 29 11:40:16 PST 2004 >Closed-Date: >Last-Modified: >Originator: Ronald Klop >Release: FreeBSD 5.2-CURRENT i386 >Organization: >Environment: System: FreeBSD klop.ws 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Wed Jan 28 07:46:30 CET 2004 root@henk.thuis.klop.ws:/usr/obj/usr/src/sys/HENK i386 >Description: This patch makes it possible to abbreviate device names when changing mixer settings. So I can issue 'mixer sp 0' in stead of 'mixer speaker 0'. It only accepts non-ambigious abbreviations. I also updated the man page for this. >How-To-Repeat: >Fix: --- mixer.diff begins here --- diff -ruN0 /usr/src/usr.sbin/mixer/mixer.8 mixer/mixer.8 --- /usr/src/usr.sbin/mixer/mixer.8 Fri Sep 26 13:21:19 2003 +++ mixer/mixer.8 Thu Jan 29 12:33:15 2004 @@ -90,0 +91,3 @@ +The argument +.Ar dev +may be abbreviated to its shortest non-ambigious form. diff -ruN0 /usr/src/usr.sbin/mixer/mixer.c mixer/mixer.c --- /usr/src/usr.sbin/mixer/mixer.c Thu Jan 22 23:01:13 2004 +++ mixer/mixer.c Thu Jan 29 12:28:03 2004 @@ -62 +62 @@ - int foo; + int device, i, matches; @@ -64,3 +64,7 @@ - for (foo = 0; foo < SOUND_MIXER_NRDEVICES; foo++) - if ((1 << foo) & mask && !strcmp(names[foo], name)) - break; + matches = 0; + for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) + if ((1 << i) & mask + && !strncmp(names[i], name, strlen(name))) { + device = i; + matches++; + } @@ -68 +72 @@ - return foo == SOUND_MIXER_NRDEVICES ? -1 : foo; + return (matches == 1 ? device : -1); --- mixer.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: