11841Sroot #include <ctype.h> 21841Sroot #include <stdio.h> 31841Sroot #include <sys/types.h> 41841Sroot #include <sys/stat.h> 51841Sroot 6*2199Sroot #define boolean int 7*2199Sroot #define TRUE 1 8*2199Sroot #define FALSE 0 9*2199Sroot #define NIL 0 10*2199Sroot 111841Sroot /* 121841Sroot * Vfontedpr. 131841Sroot * 14*2199Sroot * Dave Presotto 1/12/81 (adapted from an earlier version by Bill Joy) 151862Sroot * 161841Sroot */ 171862Sroot 181862Sroot #define STRLEN 10 /* length of strings introducing things */ 191862Sroot #define PNAMELEN 40 /* length of a function/procedure name */ 20*2199Sroot #define PSMAX 20 /* size of procedure name stacking */ 211862Sroot 22*2199Sroot /* regular expression routines */ 231862Sroot 24*2199Sroot char *expmatch(); /* match a string to an expression */ 25*2199Sroot char *STRNCMP(); /* a different kindof strncmp */ 26*2199Sroot char *convexp(); /* convert expression to internal form */ 271862Sroot 28*2199Sroot boolean isproc(); 291862Sroot 301862Sroot 31*2199Sroot char *ctime(); 321862Sroot 33*2199Sroot /* 34*2199Sroot * The state variables 35*2199Sroot */ 361862Sroot 37*2199Sroot boolean incomm; /* in a comment of the primary type */ 38*2199Sroot boolean instr; /* in a string constant */ 39*2199Sroot boolean inchr; /* in a string constant */ 40*2199Sroot boolean nokeyw = FALSE; /* no keywords being flagged */ 41*2199Sroot boolean index = FALSE; /* form an index */ 42*2199Sroot boolean filter = FALSE; /* act as a filter (like eqn) */ 43*2199Sroot boolean pass = FALSE; /* when acting as a filter, pass indicates 44*2199Sroot * whether we are currently processing 45*2199Sroot * input. 46*2199Sroot */ 47*2199Sroot boolean prccont; /* continue last procedure */ 48*2199Sroot int margin; 49*2199Sroot int psptr; /* the stack index of the current procedure */ 50*2199Sroot char pstack[PSMAX][PNAMELEN+1]; /* the procedure name stack */ 51*2199Sroot int plstack[PSMAX]; /* the procedure nesting level stack */ 52*2199Sroot int blklevel; /* current nesting level */ 53*2199Sroot char *defsfile = "/usr/lib/vgrindefs"; /* name of language definitions file */ 54*2199Sroot char pname[BUFSIZ+1]; 551862Sroot 56*2199Sroot /* 57*2199Sroot * The language specific globals 58*2199Sroot */ 591862Sroot 60*2199Sroot char *language = "c"; /* the language indicator */ 61*2199Sroot char *l_keywds[BUFSIZ/2]; /* keyword table address */ 62*2199Sroot char *l_prcbeg; /* regular expr for procedure begin */ 63*2199Sroot char *l_combeg; /* string introducing a comment */ 64*2199Sroot char *l_comend; /* string ending a comment */ 65*2199Sroot char *l_blkbeg; /* string begining of a block */ 66*2199Sroot char *l_blkend; /* string ending a block */ 67*2199Sroot char *l_strbeg; /* delimiter for string constant */ 68*2199Sroot char *l_strend; /* delimiter for string constant */ 69*2199Sroot char *l_chrbeg; /* delimiter for character constant */ 70*2199Sroot char *l_chrend; /* delimiter for character constant */ 71*2199Sroot char l_escape; /* character used to escape characters */ 72*2199Sroot boolean l_toplex; /* procedures only defined at top lex level */ 731878Sroot 741862Sroot /* 75*2199Sroot * global variables also used by expmatch 761862Sroot */ 77*2199Sroot boolean _escaped; /* if last character was an escape */ 78*2199Sroot char *_start; /* start of the current string */ 79*2199Sroot boolean l_onecase; /* upper and lower case are equivalent */ 801862Sroot 81*2199Sroot #define ps(x) printf("%s", x) 821862Sroot 83*2199Sroot main(argc, argv) 84*2199Sroot int argc; 85*2199Sroot char *argv[]; 86*2199Sroot { 87*2199Sroot int lineno; 88*2199Sroot char *fname = ""; 89*2199Sroot char *ptr; 90*2199Sroot struct stat stbuf; 91*2199Sroot char buf[BUFSIZ]; 92*2199Sroot char strings[2 * BUFSIZ]; 93*2199Sroot char defs[2 * BUFSIZ]; 94*2199Sroot int needbp = 0; 951862Sroot 96*2199Sroot argc--, argv++; 97*2199Sroot do { 98*2199Sroot char *cp; 99*2199Sroot int i; 1001878Sroot 101*2199Sroot if (argc > 0) { 102*2199Sroot if (!strcmp(argv[0], "-h")) { 103*2199Sroot if (argc == 1) { 104*2199Sroot printf("'ds =H\n"); 105*2199Sroot argc = 0; 106*2199Sroot goto rest; 107*2199Sroot } 108*2199Sroot printf("'ds =H %s\n", argv[1]); 109*2199Sroot argc -= 2; 110*2199Sroot argv += 2; 111*2199Sroot if (argc > 0) 112*2199Sroot continue; 113*2199Sroot goto rest; 114*2199Sroot } 1151862Sroot 116*2199Sroot /* act as a filter like eqn */ 117*2199Sroot if (!strcmp(argv[0], "-f")) { 118*2199Sroot filter++; 119*2199Sroot argv[0] = argv[argc-1]; 120*2199Sroot argv[argc-1] = "-"; 121*2199Sroot continue; 122*2199Sroot } 1231862Sroot 124*2199Sroot /* take input from the standard place */ 125*2199Sroot if (!strcmp(argv[0], "-")) { 126*2199Sroot argc = 0; 127*2199Sroot goto rest; 128*2199Sroot } 1291878Sroot 130*2199Sroot /* build an index */ 131*2199Sroot if (!strcmp(argv[0], "-x")) { 132*2199Sroot index++; 133*2199Sroot argv[0] = "-n"; 134*2199Sroot } 1351841Sroot 136*2199Sroot /* indicate no keywords */ 137*2199Sroot if (!strcmp(argv[0], "-n")) { 138*2199Sroot nokeyw++; 139*2199Sroot argc--, argv++; 140*2199Sroot continue; 141*2199Sroot } 1421862Sroot 143*2199Sroot /* specify the font size */ 144*2199Sroot if (!strncmp(argv[0], "-s", 2)) { 145*2199Sroot i = 0; 146*2199Sroot cp = argv[0] + 2; 147*2199Sroot while (*cp) 148*2199Sroot i = i * 10 + (*cp++ - '0'); 149*2199Sroot printf("'ps %d\n'vs %d\n", i, i+1); 150*2199Sroot argc--, argv++; 151*2199Sroot continue; 152*2199Sroot } 1531841Sroot 154*2199Sroot /* specify the language */ 155*2199Sroot if (!strncmp(argv[0], "-l", 2)) { 156*2199Sroot language = argv[0]+2; 157*2199Sroot argc--, argv++; 158*2199Sroot continue; 159*2199Sroot } 1601841Sroot 161*2199Sroot /* specify the language description file */ 162*2199Sroot if (!strncmp(argv[0], "-d", 2)) { 163*2199Sroot defsfile = argv[1]; 164*2199Sroot argc--, argv++; 165*2199Sroot argc--, argv++; 166*2199Sroot continue; 167*2199Sroot } 1681862Sroot 169*2199Sroot /* open the file for input */ 170*2199Sroot if (freopen(argv[0], "r", stdin) == NULL) { 171*2199Sroot perror(argv[0]); 172*2199Sroot exit(1); 173*2199Sroot } 174*2199Sroot if (index) 175*2199Sroot printf("'ta 4i 4.25i 5.5iR\n'in .5i\n"); 176*2199Sroot fname = argv[0]; 177*2199Sroot argc--, argv++; 178*2199Sroot } 179*2199Sroot rest: 1801862Sroot 181*2199Sroot /* 182*2199Sroot * get the language definition from the defs file 183*2199Sroot */ 184*2199Sroot i = tgetent (defs, language, defsfile); 185*2199Sroot if (i == 0) { 186*2199Sroot fprintf (stderr, "no entry for language %s\n", language); 187*2199Sroot exit (0); 188*2199Sroot } else if (i < 0) { 189*2199Sroot fprintf (stderr, "cannot find vgrindefs file %s\n", defsfile); 190*2199Sroot exit (0); 191*2199Sroot } 192*2199Sroot cp = strings; 193*2199Sroot if (tgetstr ("kw", &cp) == NIL) 194*2199Sroot nokeyw = TRUE; 195*2199Sroot else { 196*2199Sroot char **cpp; 1971878Sroot 198*2199Sroot cpp = l_keywds; 199*2199Sroot cp = strings; 200*2199Sroot while (*cp) { 201*2199Sroot while (*cp == ' ' || *cp =='\t') 202*2199Sroot *cp++ = NULL; 203*2199Sroot if (*cp) 204*2199Sroot *cpp++ = cp; 205*2199Sroot while (*cp != ' ' && *cp != '\t' && *cp) 206*2199Sroot cp++; 207*2199Sroot } 208*2199Sroot *cpp = NIL; 209*2199Sroot } 210*2199Sroot cp = buf; 211*2199Sroot l_prcbeg = convexp (tgetstr ("pb", &cp)); 212*2199Sroot cp = buf; 213*2199Sroot l_combeg = convexp (tgetstr ("cb", &cp)); 214*2199Sroot cp = buf; 215*2199Sroot l_comend = convexp (tgetstr ("ce", &cp)); 216*2199Sroot cp = buf; 217*2199Sroot l_strbeg = convexp (tgetstr ("sb", &cp)); 218*2199Sroot cp = buf; 219*2199Sroot l_strend = convexp (tgetstr ("se", &cp)); 220*2199Sroot cp = buf; 221*2199Sroot l_blkbeg = convexp (tgetstr ("bb", &cp)); 222*2199Sroot cp = buf; 223*2199Sroot l_blkend = convexp (tgetstr ("be", &cp)); 224*2199Sroot cp = buf; 225*2199Sroot l_chrbeg = convexp (tgetstr ("lb", &cp)); 226*2199Sroot cp = buf; 227*2199Sroot l_chrend = convexp (tgetstr ("le", &cp)); 228*2199Sroot l_escape = '\\'; 229*2199Sroot l_onecase = tgetflag ("oc"); 230*2199Sroot l_toplex = tgetflag ("tl"); 231*2199Sroot /* initialize the program */ 2321878Sroot 233*2199Sroot incomm = FALSE; 234*2199Sroot instr = FALSE; 235*2199Sroot inchr = FALSE; 236*2199Sroot _escaped = FALSE; 237*2199Sroot blklevel = 0; 238*2199Sroot for (psptr=0; psptr<PSMAX; psptr++) { 239*2199Sroot pstack[psptr][0] = NULL; 240*2199Sroot plstack[psptr] = 0; 241*2199Sroot } 242*2199Sroot psptr = -1; 243*2199Sroot ps("'-F\n"); 244*2199Sroot if (!filter) { 245*2199Sroot printf(".ds =F %s\n", fname); 246*2199Sroot fstat(fileno(stdin), &stbuf); 247*2199Sroot cp = ctime(&stbuf.st_mtime); 248*2199Sroot cp[16] = '\0'; 249*2199Sroot cp[24] = '\0'; 250*2199Sroot printf(".ds =M %s %s\n", cp+4, cp+20); 251*2199Sroot } 252*2199Sroot if (needbp) { 253*2199Sroot needbp = 0; 254*2199Sroot printf(".()\n"); 255*2199Sroot printf(".bp\n"); 256*2199Sroot } 2571878Sroot 258*2199Sroot /* 259*2199Sroot * MAIN LOOP!!! 260*2199Sroot */ 261*2199Sroot while (fgets(buf, sizeof buf, stdin) != NULL) { 262*2199Sroot if (buf[0] == '\f') { 263*2199Sroot printf(".bp\n"); 264*2199Sroot } 265*2199Sroot if (buf[0] == '.') { 266*2199Sroot printf("%s", buf); 267*2199Sroot if (!strncmp (buf+1, "vS", 2)) 268*2199Sroot pass = TRUE; 269*2199Sroot if (!strncmp (buf+1, "vE", 2)) 270*2199Sroot pass = FALSE; 271*2199Sroot continue; 272*2199Sroot } 273*2199Sroot prccont = FALSE; 274*2199Sroot if (!filter || pass) 275*2199Sroot putScp(buf); 276*2199Sroot else 277*2199Sroot printf("%s", buf); 278*2199Sroot if (prccont && (psptr >= 0)) { 279*2199Sroot ps("'FC "); 280*2199Sroot ps(pstack[psptr]); 281*2199Sroot ps("\n"); 282*2199Sroot } 283*2199Sroot #ifdef DEBUG 284*2199Sroot printf ("com %o str %o chr %o ptr %d\n", incomm, instr, inchr, psptr); 285*2199Sroot #endif 286*2199Sroot margin = 0; 287*2199Sroot } 288*2199Sroot needbp = 1; 289*2199Sroot } while (argc > 0); 290*2199Sroot exit(0); 2911841Sroot } 2921841Sroot 2931841Sroot #define isidchr(c) (isalnum(c) || (c) == '_') 2941841Sroot 2951841Sroot putScp(os) 296*2199Sroot char *os; 2971841Sroot { 298*2199Sroot register char *s = os; /* pointer to unmatched string */ 299*2199Sroot char dummy[BUFSIZ]; /* dummy to be used by expmatch */ 300*2199Sroot int xfld = 0; 301*2199Sroot char *comptr; /* end of a comment delimiter */ 302*2199Sroot char *strptr; /* end of a string delimiter */ 303*2199Sroot char *chrptr; /* end of a character const delimiter */ 304*2199Sroot char *blksptr; /* end of a lexical block start */ 305*2199Sroot char *blkeptr; /* end of a lexical block end */ 3061841Sroot 307*2199Sroot _start = os; /* remember the start for expmatch */ 308*2199Sroot _escaped = FALSE; 309*2199Sroot if (nokeyw || incomm || instr) 310*2199Sroot goto skip; 311*2199Sroot if (isproc(s)) { 312*2199Sroot ps("'FN "); 313*2199Sroot ps(pname); 314*2199Sroot if (psptr < PSMAX) { 315*2199Sroot ++psptr; 316*2199Sroot strncpy (pstack[psptr], pname, PNAMELEN); 317*2199Sroot pstack[psptr][PNAMELEN] = NULL; 318*2199Sroot ps("\n"); 319*2199Sroot plstack[psptr] = blklevel; 320*2199Sroot } 321*2199Sroot } 3221841Sroot skip: 323*2199Sroot do { 324*2199Sroot if (index) { 325*2199Sroot if (*s == ' ' || *s == '\t') { 326*2199Sroot if (xfld == 0) 327*2199Sroot printf(""); 328*2199Sroot printf("\t"); 329*2199Sroot xfld = 1; 330*2199Sroot while (*s == ' ' || *s == '\t') 331*2199Sroot s++; 332*2199Sroot continue; 333*2199Sroot } 334*2199Sroot } 335*2199Sroot 336*2199Sroot /* check for string, comment, blockstart, etc */ 337*2199Sroot if (!incomm && !instr && !inchr) { 338*2199Sroot 339*2199Sroot blkeptr = expmatch (s, l_blkend, dummy); 340*2199Sroot blksptr = expmatch (s, l_blkbeg, dummy); 341*2199Sroot comptr = expmatch (s, l_combeg, dummy); 342*2199Sroot strptr = expmatch (s, l_strbeg, dummy); 343*2199Sroot chrptr = expmatch (s, l_chrbeg, dummy); 344*2199Sroot 345*2199Sroot /* start of a comment? */ 346*2199Sroot if (comptr != NIL) 347*2199Sroot if ((comptr < strptr || strptr == NIL) 348*2199Sroot && (comptr < chrptr || chrptr == NIL) 349*2199Sroot && (comptr < blksptr || blksptr == NIL) 350*2199Sroot && (comptr < blkeptr || blkeptr == NIL)) { 351*2199Sroot putKcp (s, comptr-1, FALSE); 352*2199Sroot s = comptr; 353*2199Sroot incomm = TRUE; 354*2199Sroot if (s != os) 355*2199Sroot ps ("\\c"); 356*2199Sroot ps ("\\c\n'+C\n"); 357*2199Sroot continue; 3581841Sroot } 3591878Sroot 360*2199Sroot /* start of a string? */ 361*2199Sroot if (strptr != NIL) 362*2199Sroot if ((strptr < chrptr || chrptr == NIL) 363*2199Sroot && (comptr < blksptr || blksptr == NIL) 364*2199Sroot && (comptr < blkeptr || blkeptr == NIL)) { 365*2199Sroot putKcp (s, strptr-1, FALSE); 366*2199Sroot s = strptr; 367*2199Sroot instr = TRUE; 368*2199Sroot continue; 369*2199Sroot } 3701878Sroot 371*2199Sroot /* start of a character string? */ 372*2199Sroot if (chrptr != NIL) 373*2199Sroot if ((comptr < blksptr || blksptr == NIL) 374*2199Sroot && (comptr < blkeptr || blkeptr == NIL)) { 375*2199Sroot putKcp (s, chrptr-1, FALSE); 376*2199Sroot s = chrptr; 377*2199Sroot inchr = TRUE; 378*2199Sroot continue; 3791841Sroot } 3801878Sroot 381*2199Sroot /* end of a lexical block */ 382*2199Sroot if (blkeptr != NIL) { 383*2199Sroot if (blkeptr < blksptr || blksptr == NIL) { 384*2199Sroot putKcp (s, blkeptr - 1, FALSE); 385*2199Sroot s = blkeptr; 386*2199Sroot blklevel--; 387*2199Sroot if (psptr >= 0 && plstack[psptr] >= blklevel) { 3881878Sroot 389*2199Sroot /* end of current procedure */ 3901841Sroot if (s != os) 391*2199Sroot ps ("\\c"); 392*2199Sroot ps ("\\c\n'-F\n"); 393*2199Sroot blklevel = plstack[psptr]; 3941878Sroot 395*2199Sroot /* see if we should print the last proc name */ 396*2199Sroot if (--psptr >= 0) 397*2199Sroot prccont = TRUE; 398*2199Sroot else 399*2199Sroot psptr = -1; 400*2199Sroot } 401*2199Sroot continue; 4021841Sroot } 403*2199Sroot } 4041878Sroot 405*2199Sroot /* start of a lexical block */ 406*2199Sroot if (blksptr != NIL) { 407*2199Sroot putKcp (s, blksptr - 1, FALSE); 408*2199Sroot s = blksptr; 409*2199Sroot blklevel++; 410*2199Sroot continue; 411*2199Sroot } 412*2199Sroot 413*2199Sroot /* check for end of comment */ 414*2199Sroot } else if (incomm) { 415*2199Sroot if ((comptr = expmatch (s, l_comend, dummy)) != NIL) { 416*2199Sroot putKcp (s, comptr-1, TRUE); 417*2199Sroot s = comptr; 418*2199Sroot incomm = FALSE; 419*2199Sroot ps("\\c\n'-C\n"); 420*2199Sroot continue; 421*2199Sroot } else { 422*2199Sroot putKcp (s, s + strlen(s) -1); 423*2199Sroot s = s + strlen(s); 424*2199Sroot continue; 425*2199Sroot } 426*2199Sroot 427*2199Sroot /* check for end of string */ 428*2199Sroot } else if (instr) { 429*2199Sroot if ((strptr = expmatch (s, l_strend, dummy)) != NIL) { 430*2199Sroot putKcp (s, strptr-1, TRUE); 431*2199Sroot s = strptr; 432*2199Sroot instr = FALSE; 433*2199Sroot continue; 434*2199Sroot } else { 435*2199Sroot putKcp (s, s+strlen(s)-1, TRUE); 436*2199Sroot s = s + strlen(s); 437*2199Sroot continue; 438*2199Sroot } 439*2199Sroot 440*2199Sroot /* check for end of character string */ 441*2199Sroot } else if (inchr) { 442*2199Sroot if ((chrptr = expmatch (s, l_chrend, dummy)) != NIL) { 443*2199Sroot putKcp (s, chrptr-1, TRUE); 444*2199Sroot s = chrptr; 445*2199Sroot inchr = FALSE; 446*2199Sroot continue; 447*2199Sroot } else { 448*2199Sroot putKcp (s, s+strlen(s)-1, TRUE); 449*2199Sroot s = s + strlen(s); 450*2199Sroot continue; 451*2199Sroot } 4521841Sroot } 453*2199Sroot 454*2199Sroot /* print out the line */ 455*2199Sroot putKcp (s, s + strlen(s) -1, FALSE); 456*2199Sroot s = s + strlen(s); 457*2199Sroot } while (*s); 4581841Sroot } 4591841Sroot 460*2199Sroot putKcp (start, end, force) 461*2199Sroot char *start; /* start of string to write */ 462*2199Sroot char *end; /* end of string to write */ 463*2199Sroot boolean force; /* true if we should force nokeyw */ 464*2199Sroot { 465*2199Sroot int i; 466*2199Sroot 467*2199Sroot while (start <= end) { 468*2199Sroot 469*2199Sroot /* take care of nice tab stops */ 470*2199Sroot if (*start == '\t') { 471*2199Sroot while (*start == '\t') 472*2199Sroot start++; 473*2199Sroot i = tabs(_start, start) - margin / 8; 474*2199Sroot printf("\\h'|%dn'", i * 10 + 1 - margin % 8); 475*2199Sroot continue; 476*2199Sroot } 477*2199Sroot 478*2199Sroot if (!nokeyw && !force) 479*2199Sroot if ((*start == '#' || isidchr(*start)) 480*2199Sroot && (start == _start || !isidchr(start[-1]))) { 481*2199Sroot i = iskw(start); 482*2199Sroot if (i > 0) { 483*2199Sroot ps("\\*(+K"); 484*2199Sroot do 485*2199Sroot putcp(*start++); 486*2199Sroot while (--i > 0); 487*2199Sroot ps("\\*(-K"); 488*2199Sroot continue; 489*2199Sroot } 490*2199Sroot } 491*2199Sroot 492*2199Sroot putcp (*start++); 493*2199Sroot } 494*2199Sroot } 495*2199Sroot 496*2199Sroot 4971841Sroot tabs(s, os) 498*2199Sroot char *s, *os; 4991841Sroot { 5001841Sroot 501*2199Sroot return (width(s, os) / 8); 5021841Sroot } 5031841Sroot 5041841Sroot width(s, os) 5051841Sroot register char *s, *os; 5061841Sroot { 5071841Sroot register int i = 0; 5081841Sroot 5091841Sroot while (s < os) { 5101841Sroot if (*s == '\t') { 5111841Sroot i = (i + 8) &~ 7; 5121841Sroot s++; 5131841Sroot continue; 5141841Sroot } 5151841Sroot if (*s < ' ') 5161841Sroot i += 2; 5171841Sroot else 5181841Sroot i++; 5191841Sroot s++; 5201841Sroot } 5211841Sroot return (i); 5221841Sroot } 5231841Sroot 5241841Sroot putcp(c) 5251841Sroot register int c; 5261841Sroot { 5271841Sroot 5281841Sroot switch(c) { 5291841Sroot 530*2199Sroot case 0: 531*2199Sroot break; 532*2199Sroot 533*2199Sroot case '\f': 534*2199Sroot break; 535*2199Sroot 5361841Sroot case '{': 5371841Sroot ps("\\*(+K{\\*(-K"); 5381841Sroot break; 5391841Sroot 5401841Sroot case '}': 5411841Sroot ps("\\*(+K}\\*(-K"); 5421841Sroot break; 5431841Sroot 5441841Sroot case '\\': 5451841Sroot ps("\\e"); 5461841Sroot break; 5471841Sroot 5481841Sroot case '_': 5491841Sroot ps("\\*_"); 5501841Sroot break; 5511841Sroot 5521841Sroot case '-': 5531841Sroot ps("\\*-"); 5541841Sroot break; 5551841Sroot 5561841Sroot case '`': 5571841Sroot ps("\\`"); 5581841Sroot break; 5591841Sroot 5601841Sroot case '\'': 5611841Sroot ps("\\'"); 5621841Sroot break; 5631841Sroot 5641841Sroot case '.': 5651841Sroot ps("\\&."); 5661841Sroot break; 5671841Sroot 568*2199Sroot case '/': 569*2199Sroot ps("\\*/"); 570*2199Sroot break; 571*2199Sroot 5721841Sroot default: 5731841Sroot if (c < 040) 5741841Sroot putchar('^'), c |= '@'; 5751841Sroot case '\t': 5761841Sroot case '\n': 5771841Sroot putchar(c); 5781841Sroot } 5791841Sroot } 5801841Sroot 581*2199Sroot /* 582*2199Sroot * look for a process beginning on this line 5831878Sroot */ 584*2199Sroot boolean 585*2199Sroot isproc(s) 586*2199Sroot char *s; 5871878Sroot { 588*2199Sroot pname[0] = NULL; 589*2199Sroot if (!l_toplex || blklevel == 0) 590*2199Sroot if (expmatch (s, l_prcbeg, pname) != NIL) { 591*2199Sroot return (TRUE); 592*2199Sroot } 593*2199Sroot return (FALSE); 5941878Sroot } 5951878Sroot 596*2199Sroot 5971878Sroot /* iskw - check to see if the next word is a keyword 5981878Sroot */ 5991878Sroot 6001841Sroot iskw(s) 6011841Sroot register char *s; 6021841Sroot { 603*2199Sroot register char **ss = l_keywds; 6041841Sroot register int i = 1; 6051841Sroot register char *cp = s; 6061841Sroot 6071841Sroot while (++cp, isidchr(*cp)) 6081841Sroot i++; 6091841Sroot while (cp = *ss++) 610*2199Sroot if (!STRNCMP(s,cp,i) && !isidchr(cp[i])) 6111841Sroot return (i); 6121841Sroot return (0); 6131841Sroot } 614