1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Teach morse(6) the <AC> prosign as '@', as added on May 24, 2004 (the

160th anniversary of the first public Morse telegraph transmission).

Support decoding (only; not encoding) of other prosigns, including <SK>
as we were previously using for '@'.  From pjanzen.
This commit is contained in:
sthen 2016-01-19 23:21:26 +00:00
parent 847d0c5724
commit fa195fe752
2 changed files with 35 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: morse.6,v 1.2 2016/01/18 11:24:44 sthen Exp $
.\" $OpenBSD: morse.6,v 1.3 2016/01/19 23:21:26 sthen Exp $
.\"
.\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" @(#)bcd.6 8.1 (Berkeley) 5/31/93
.\"
.Dd $Mdocdate: January 18 2016 $
.Dd $Mdocdate: January 19 2016 $
.Dt MORSE 6
.Os
.Sh NAME
@ -58,6 +58,7 @@ back into text.
A lowercase
.Sq x
is printed for undecipherable input; otherwise, text is returned uppercase.
Many procedural signs can be decoded (though not encoded).
If the morse to be translated is given on the command line, it should be
preceded by
.Sq --

View File

@ -1,4 +1,4 @@
/* $OpenBSD: morse.c,v 1.20 2016/01/18 11:27:19 sthen Exp $ */
/* $OpenBSD: morse.c,v 1.21 2016/01/19 23:21:26 sthen Exp $ */
/*
* Copyright (c) 1988, 1993
@ -82,6 +82,7 @@ struct punc {
char c;
char *morse;
} other[] = {
{ 'e', "..-.." }, /* accented e - only decodes */
{ ',', "--..--" },
{ '.', ".-.-.-" },
{ '?', "..--.." },
@ -89,17 +90,34 @@ struct punc {
{ '-', "-....-" },
{ ':', "---..." },
{ ';', "-.-.-." },
{ '(', "-.--." },
{ '(', "-.--." }, /* KN */
{ ')', "-.--.-" },
{ '"', ".-..-." },
{ '`', ".-..-." },
{ '\'', ".----." },
{ '+', ".-.-." }, /* AR */
{ '=', "-...-" }, /* BT */
{ '@', "...-.-" }, /* SK */
{ '+', ".-.-." }, /* AR \n\n\n */
{ '=', "-...-" }, /* BT \n\n */
{ '@', ".--.-." },
{ '\n', ".-.-" }, /* AA (will only decode) */
{ '\0', NULL }
};
struct prosign {
char *c;
char *morse;
} ps[] = {
{ "<AS>", ".-..." }, /* wait */
{ "<CL>", "-.-..-.." },
{ "<CT>", "-.-.-" }, /* start */
{ "<EE5>", "......" }, /* error */
{ "<EE5>", "......." },
{ "<EE5>", "........" },
{ "<SK>", "...-.-" },
{ "<SN>", "...-." }, /* understood */
{ "<SOS>", "...---..." },
{ NULL, NULL }
};
void morse(int);
void decode(char *);
void show(char *);
@ -233,6 +251,15 @@ decode(char *s)
}
i++;
}
i = 0;
while (ps[i].c) {
/* put whitespace around prosigns */
if (strcmp(ps[i].morse, s) == 0) {
printf(" %s ", ps[i].c);
return;
}
i++;
}
putchar('x'); /* line noise */
}