bin/62077: Make it possible to abbreviate device names. (patch
included)
Ronald Klop
ronald at cs.vu.nl
Thu Jan 29 11:40:58 PST 2004
>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 at 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:
More information about the freebsd-bugs
mailing list