int main(int argc, char **argv) { char *buf, *eq, *p; if ( argc < 2 ) { fprintf(stderr,"Need string argument\n"); exit(1); } buf = strdup(argv[1]); printf("%s\n",buf); for ( p = buf; (eq=feq(p)); ) { while ( p != eq ) { printf("."); p++; } printf("^"); p++; } printf("\n"); for (p=buf; p=fnam(p); p++ ) { printf("Found %s\n",p); if ( ! (p = feq(p)) ) break; } cmdlinePairExtract(buf,ptenv,1); printf("Line now '%s'\n", buf); }
void cmdlinePairExtract(char *buf, int (*putpair)(char *str), int removeFound) { char *beg,*end; if ( !buf || !putpair ) return; /* find 'name=' tags */ /* this algorithm is copied from the svgm BSP (startup/bspstart.c) */ for (beg=buf; beg && (beg=fnam(beg)); beg=end) { /* simple algorithm to find the end of quoted 'name=quoted' * substring. As a side effect, quotes are removed from * the value. */ if ( (end = strchr(beg,'=')) ) { char *dst; /* now unquote the value */ if ('\'' == *++end) { /* end points to the 1st char after '=' which is a '\'' */ dst = end++; /* end points to 1st char after '\'' */ while ('\'' != *end || '\'' == *++end) { if ( 0 == (*dst++=*end++) ) { /* NO TERMINATING QUOTE FOUND * (for a properly quoted string we * should never get here) */ end = 0; dst--; break; } } *dst = 0; } else { /* first space terminates non-quoted strings */ if ( (dst = end = strchr(end,' ')) ) *(end++)=0; } if ( 0 == putpair(beg) && removeFound ) { if ( end ) { memmove(beg, end, strlen(end)+1); end = beg; } else { *beg = 0; } } else { if ( dst ) *dst = ' '; } } } return; }
int main() { int mask; printf("/* WARNING: DO NOT EDIT THIS AUTOMATICALLY-GENERATED FILE */\n"); printf("#define JUMPTAB_ARGLIST(args) "); for (mask=0; mask < MAXBITS; mask++) printf(",args[%i]",mask); printf("\n"); printf("#define MAXBITS %i\n",MAXBITS); for (mask=0; mask< (1<<MAXBITS); mask++) { printf("typedef %s (*",typ[RES]); tnam(mask); printf(")("); targs(mask); printf(");\n"); printf("static %s ",typ[RES]); fnam(mask); protoargs(); printf("\n"); printf("{return (("); tnam(mask); printf(")f->tv.p)("); callargs(mask); printf(");}\n\n"); } printf("static UFUNC jumptab[%i]={\n",1<<MAXBITS); for (mask=0; mask < (1<<MAXBITS); mask++) { printf("\t"); fnam(mask); printf(",\n"); } printf("};\n"); return 0; }