diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2016-01-19 23:21:27 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2016-01-19 23:21:27 +0000 |
commit | 9fadaa0cb690dd672a6da2aff8e3252c11609ce2 (patch) | |
tree | afd7b54ae4d1c1d943b8230e9f8cb9ddf95ffae1 /games/morse | |
parent | 82901f04bb589ac671f7055dd0f1452173268b35 (diff) |
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.
Diffstat (limited to 'games/morse')
-rw-r--r-- | games/morse/morse.6 | 5 | ||||
-rw-r--r-- | games/morse/morse.c | 37 |
2 files changed, 35 insertions, 7 deletions
diff --git a/games/morse/morse.6 b/games/morse/morse.6 index 63cd4a9f3ce..0a6f42c42b3 100644 --- a/games/morse/morse.6 +++ b/games/morse/morse.6 @@ -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 -- diff --git a/games/morse/morse.c b/games/morse/morse.c index be4d06d6646..ae246ad67e0 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -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 */ } |