From: Martin Mares Date: Thu, 18 Oct 2007 09:37:00 +0000 (+0200) Subject: Fix. X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=08f31b3c742ff5b741bbcf7dc734052e39d5e26c;p=misc.git Fix. --- diff --git a/morse.c b/morse.c index 50f957b..a1d949e 100644 --- a/morse.c +++ b/morse.c @@ -5,7 +5,7 @@ #define MAXLEN 256 -static unsigned char decode[] = "**etianmsurwdkgohvf*l*p*bxcyzq*"; +static unsigned char decode[] = "**etianmsurwdkgohvf*l*pjbxcyzq*"; static unsigned char encode[256]; static void init(void) @@ -171,15 +171,28 @@ int main(int argc, char **argv) die("Usage: morse "); init(); load(argv[1]); - int N = strlen(argv[2]); + + char *in, mbuf[MAXLEN+1]; + if (argv[2][0] == '.' || argv[2][0] == '-') + in = argv[2]; + else + { + strencode(mbuf, argv[2], 0); + puts(mbuf); + if (strchr(mbuf, '?')) + die("Unable to encode"); + in = mbuf; + } + + int N = strlen(in); if (N > MAXLEN) die("Oops, too long for my memory!"); - map(argv[2], N); + map(in, N); char buf[MAXLEN+1]; for (int j=1; j<=N; j++) if (M[0][j]) - print(buf+1, buf, argv[2], 0, N, j); + print(buf+1, buf, in, 0, N, j); return 0; }