2 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
3 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
4 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
7 /*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/taste.c,v 1.1 1992/10/28 00:28:39 jutta Exp $*/
22 extern char * malloc P((char *)), * realloc P((char *,int));
24 extern int exit P((int));
30 * common code to sweet.c and bitter.c: read the name:#bits description.
35 static struct spex * s_spex;
36 static int n_spex, m_spex;
38 extern void write_code P((struct spex *, int));
40 char * strsave P1((str), char * str) /* strdup() + errors */
42 int n = strlen(str) + 1;
45 fprintf(stderr, "Failed to malloc %d bytes, abort\n",
49 return memcpy(s, str, n);
52 struct spex * new_spex P0()
54 if (n_spex >= m_spex) {
56 if (!(s_spex = (struct spex *)(n_spex
57 ? realloc((char *)s_spex, m_spex * sizeof(*s_spex))
58 : malloc( m_spex * sizeof(*s_spex))))) {
59 fprintf(stderr, "Failed to malloc %d bytes, abort\n",
60 m_spex * sizeof(*s_spex));
64 return s_spex + n_spex;
67 char * strtek P2((str, sep), char * str, char * sep) {
69 static char * S = (char *)0;
74 if (!S || !*S) return (char *)0;
79 for (c = sep; *c && *c != *S; c++) ;
86 /* Skip non-delimiters.
88 for (base = S; *S; S++) {
90 for (c = sep; *c; c++)
97 return base == S ? (char *)0 : base;
104 struct spex * sp = s_spex;
106 while (fgets(buf, sizeof buf, stdin)) {
110 if (nl = strchr(buf, '\n'))
113 if (!*buf || *buf == ';') continue;
114 s = strtek(buf, " \t");
116 fprintf(stderr, "? %s\n", buf);
120 sp->var = strsave(s);
121 s = strtek((char*)0, " \t");
123 fprintf(stderr, "varsize?\n");
126 sp->varsize = strtol(s, (char **)0, 0);
136 write_code(s_spex, n_spex);