1: /*************************************************************************
   2:  * This program is copyright (C) 1985, 1986 by Jonathan Payne.  It is    *
   3:  * provided to you without charge for use only on a licensed Unix        *
   4:  * system.  You may copy JOVE provided that this notice is included with *
   5:  * the copy.  You may not sell copies of this program or versions        *
   6:  * modified for use on microcomputer systems, unless the copies are      *
   7:  * included with a Unix system distribution and the source is provided.  *
   8:  *************************************************************************/
   9: 
  10: #define TXT_TO_C
  11: 
  12: #include "funcdefs.c"
  13: #undef putchar  /* From jove.h via funcdefs.c, conflicts with STDIO */
  14: #undef putc
  15: #undef getc
  16: #undef EOF
  17: #undef FILE
  18: #undef BUFSIZ
  19: #include <stdio.h>
  20: 
  21: match(choices, what)
  22: register struct cmd choices[];
  23: register char   *what;
  24: {
  25:     register int    len;
  26:     int i,
  27:         found = 0,
  28:         save,
  29:         exactmatch = -1;
  30: 
  31:     len = strlen(what);
  32:     for (i = 0; choices[i].Name != 0; i++) {
  33:         if (*what != *choices[i].Name)
  34:             continue;
  35:         if (strncmp(what, choices[i].Name, len) == 0)
  36:             return i;
  37:     }
  38:     return -1;
  39: }
  40: 
  41: char *
  42: PPchar(c)
  43: int c;
  44: {
  45:     static char str[10];
  46:     char    *cp = str;
  47: 
  48:     if (c == '\033')
  49:         strcpy(cp, "ESC");
  50:     else if (c < ' ')
  51:         (void) sprintf(cp, "C-%c", c + '@');
  52:     else if (c == '\177')
  53:         strcpy(cp, "^?");
  54:     else
  55:         (void) sprintf(cp, "%c", c);
  56:     return cp;
  57: }
  58: 
  59: extract(into, from)
  60: char    *into,
  61:     *from;
  62: {
  63:     from += 2;  /* Past tab and first double quote. */
  64:     while ((*into = *from++) != '"')
  65:         into++;
  66:     *into = 0;
  67: }
  68: 
  69: main()
  70: {
  71:     FILE    *ifile,
  72:         *of;
  73:     char    line[100],
  74:         comname[70];
  75:     int comnum,
  76:         ch;
  77: 
  78:     ifile = stdin;
  79:     of = stdout;
  80:     if (ifile == NULL || of == NULL) {
  81:         printf("Cannot read input or write output.\n");
  82:         exit(1);
  83:     }
  84:     while (fgets(line, sizeof line, ifile) != NULL) {
  85:         if (strncmp(line, "\t\"", 2) != 0) {
  86:             fprintf(of, line);
  87:             ch = 0;
  88:             continue;
  89:         }
  90:         extract(comname, line);
  91:         if (strcmp(comname, "unbound") == 0)
  92:             comnum = 12345;
  93:         else {
  94:             comnum = match(commands, comname);
  95:             if (comnum < 0) {
  96:                 fprintf(stderr, "Cannot find command \"%s\".\n", comname);
  97:                 exit(1);
  98:             }
  99:         }
 100:         if (comnum == 12345)
 101:             fprintf(of, "	(data_obj *) 0,                 /* %s */\n", PPchar(ch++));
 102:         else
 103:             fprintf(of, "	(data_obj *) &commands[%d],	/* %s */\n", comnum, PPchar(ch++));
 104:     }
 105:     fclose(of);
 106:     fclose(ifile);
 107:     exit(0);
 108: }

Defined functions

PPchar defined in line 41; used 2 times
extract defined in line 59; used 1 times
  • in line 90
main defined in line 69; never used
match defined in line 21; used 1 times
  • in line 94

Defined macros

TXT_TO_C defined in line 10; never used
Last modified: 1986-03-28
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1084
Valid CSS Valid XHTML 1.0 Strict