+ if (dflag) {
+ if (*argv) {
+ do {
+ s=strchr(*argv, ',');
+
+ if (s)
+ *s='\0';
+
+ decode(*argv);
+ } while (*++argv);
+ }else{
+ char buf[1024];
+
+ while (fgets(buf, 1024, stdin)) {
+ s=buf;
+
+ while (*s && isspace(*s))
+ s++;
+
+ if (*s) {
+ p=strtok(s, " \n\t");
+
+ while (p) {
+ s=strchr(p, ',');
+
+ if (s)
+ *s='\0';
+
+ decode(p);
+ p=strtok(NULL, " \n\t");
+ }
+ }
+ }
+ }
+ putchar('\n');
+ }else{
+ if (*argv)
+ do {
+ for (p = *argv; *p; ++p)
+ morse((int)*p);
+ } while (*++argv);
+ else while ((ch = getchar()) != EOF)
+ morse(ch);
+ }
+
+ return 0;
+}
+
+void
+decode(s)
+ const char *s;
+{
+ if (strcmp(s, MORSE_COLON) == 0){
+ putchar(',');
+ } else if (strcmp(s, MORSE_PERIOD) == 0){
+ putchar('.');
+ } else {
+ int found;
+ const char *const *a;
+ int size;
+ int i;
+
+ found=0;
+ a=digit;
+ size=sizeof(digit)/sizeof(digit[0]);
+ for (i=0; i<size; i++) {
+ if (strcmp(a[i], s) == 0) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) {
+ putchar('0'+i);
+ return;
+ }
+
+ found=0;
+ a=alph;
+ size=sizeof(alph)/sizeof(alph[0]);
+ for (i=0; i<size; i++) {
+ if (strcmp(a[i], s) == 0) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found)
+ putchar('a'+i);
+ else
+ putchar(' ');
+ }