Date: Tue, 8 Sep 1998 21:05:14 -0600 (MDT) From: lyndon@orthanc.ab.ca To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/7868: Morse Code Fixups Message-ID: <199809090305.VAA02319@thingfish.v-wave.com>
index | next in thread | raw e-mail
>Number: 7868
>Category: bin
>Synopsis: Morse Code Fixups
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Sep 8 20:10:01 PDT 1998
>Last-Modified:
>Originator:
>Organization:
The Frobozz Magic Homing Pigeon Company
>Release: FreeBSD 2.2.7-STABLE i386
>Environment:
>Description:
* Make audio support conditional on __FreeBSD__ instead of via explicit
CFLAGS setting in the Makefile.
* Fixed the output grammar to properly speak non-terminal dits.
>How-To-Repeat:
>Fix:
In /usr/src/games/morse:
===================================================================
RCS file: Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- Makefile 1998/09/09 02:39:40 1.1
+++ Makefile 1998/09/09 02:40:16
@@ -2,6 +2,5 @@
PROG= morse
NOMAN= noman
-CFLAGS += -DSPEAKER=\"/dev/speaker\"
.include <bsd.prog.mk>
===================================================================
RCS file: morse.c,v
retrieving revision 1.1
diff -u -r1.1 morse.c
--- morse.c 1998/09/09 02:39:47 1.1
+++ morse.c 1998/09/09 02:50:00
@@ -32,8 +32,8 @@
*/
/*
- * Taught to send *real* morse by Lyndon Nerenberg (VE7TCP/VE6BBM)
- * <lyndon@orthanc.com>
+ * Taught to send *real* morse by Lyndon Nerenberg (VE6BBM)
+ * <lyndon@orthanc.ab.ca>
*/
#ifndef lint
@@ -50,10 +50,10 @@
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
-
-#ifdef SPEAKER
-#include <machine/speaker.h>
-#include <fcntl.h>
+#include <sys/param.h>
+#ifdef __FreeBSD__
+# include <machine/speaker.h>
+# include <fcntl.h>
#endif
struct morsetab {
@@ -194,7 +194,7 @@
#define FREQUENCY 600
static int freq = FREQUENCY;
-#ifdef SPEAKER
+#ifdef __FreeBSD__
#define DASH_LEN 3
#define CHAR_SPACE 3
#define WORD_SPACE (7 - CHAR_SPACE - 1)
@@ -243,10 +243,10 @@
if (pflag && (freq == 0))
freq = FREQUENCY;
-#ifdef SPEAKER
+#ifdef __FreeBSD__
if (pflag) {
- if ((spkr = open(SPEAKER, O_WRONLY, 0)) == -1) {
- perror(SPEAKER);
+ if ((spkr = open("/dev/speaker", O_WRONLY, 0)) == -1) {
+ perror("/dev/speaker");
exit(1);
}
dot_clock = wpm / 2.4; /* dots/sec */
@@ -255,7 +255,9 @@
/* the dot rate */
dot_clock = dot_clock * 100; /* scale for ioctl */
}
-#endif
+#else /* ! __FreeBSD__ */
+ errx(1, "audio not supported on this platform");
+#endif /* ! __FreeBSD__ */
argc -= optind;
argv += optind;
@@ -319,14 +321,14 @@
printf(" %s", s);
else
for (; *s; ++s)
- printf(" %s", *s == '.' ? "dit" : "dah");
+ printf(" %s", *s == '.' ? *(s+1) == '\0' ? "dit" : "di" : "dah");
printf("\n");
}
void
play(const char *s)
{
-#ifdef SPEAKER
+#ifdef __FreeBSD__
const char *c;
for (c = s; *c != '\0'; c++) {
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809090305.VAA02319>
