1: # include "refer.h"
   2: # include "stdio.h"
   3: # include "ctype.h"
   4: 
   5: int grepin, grepout;
   6: 
   7: grepcall (in, arg)
   8: char *in, *arg;
   9: {
  10:     char line[TAGLEN], *s, argig[100], *cv[NQUERY+1];
  11:     char *inp, inb[QLEN];
  12:     extern char gfile[];
  13:     FILE *qf, *gf;
  14:     int c, oldc 0, alph 0, nv 0;
  15:     strcpy (argig, arg);
  16:     strcat(argig, ".ig");
  17:     strcpy (inp=inb, in);
  18:     if (gfile[0]==0)
  19:         sprintf(gfile, "/tmp/rj%dg", getpid());
  20:     for(cv[nv++] = "fgrep"; (c = *inp) && (nv<=NQUERY); inp++)
  21:     {
  22:         if (c== ' ')
  23:             c = *inp = 0;
  24:         else if (isupper(c))
  25:             *inp = tolower(c);
  26:         alph = (c==0) ? 0 : alph+1;
  27:         if (alph == 1)
  28:             cv[nv++] = inp;
  29:         if (alph > 6)
  30:             *inp = 0;
  31:         oldc=c;
  32:     }
  33:     if ((grepin=open (argig, 0)) < 0)
  34:         err("Can't read fgrep index %s", argig);
  35:     if ((grepout=creat(gfile, 0666)) < 0)
  36:         err("Can't write fgrep output %s", gfile);
  37:     fgrep(nv, cv);
  38:     close(grepin);
  39:     close (grepout);
  40: 
  41:     gf = fopen(gfile, "r");
  42:     if (gf==NULL)
  43:         err("can't read fgrep output %s", gfile);
  44:     while (fgets(line, TAGLEN, gf) == line)
  45:     {
  46:         for(s=line; *s && (*s != '\t'); s++);
  47:         if (*s == '\t')
  48:         {
  49:             *s++ = '\n';
  50:             *s++ = 0;
  51:         }
  52:         if (line[0]) {
  53:             if (++nfound == 1) {
  54:                 strcpy(tagout, line);
  55:                 findline(tagout,text,TXTLEN,0L);
  56:             } else {
  57:                 if (nfound == 2) {
  58:                 fprintf(stderr,
  59:                     "%s: Multiple matches for '%s'",
  60:                     Ifile,sinput);
  61:                 fprintf(stderr,"in %s\n",Index);
  62:                 title(text);
  63:                 }
  64:                 findline(line,inb,QLEN,0L);
  65:                 title(inb);
  66:             }
  67:         }
  68:         while (*s) s++;
  69:         if (s[-1]!= '\n')
  70:             while (!feof(gf) && getc(gf)!= '\n') ;
  71:     }
  72:     fclose(gf);
  73:     unlink (gfile);
  74:     return(0);
  75: }
  76: 
  77: clfgrep()
  78: {
  79:     if (gfile[0])
  80:         unlink(gfile);
  81: }

Defined functions

clfgrep defined in line 77; used 1 times
grepcall defined in line 7; used 2 times

Defined variables

grepin defined in line 5; used 2 times
grepout defined in line 5; used 2 times
Last modified: 1982-05-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 718
Valid CSS Valid XHTML 1.0 Strict