/[cvs]/ccvs/src/subr.c
ViewVC logotype

Diff of /ccvs/src/subr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.148.4.1 by dprice, Thu Oct 20 21:33:12 2005 UTC revision 1.148.4.2 by dprice, Sat Oct 29 04:35:01 2005 UTC
# Line 616  out: Line 616  out:
616    
617    
618    
619    bool
620    file_contains_keyword (const struct file_info *finfo)
621    {
622        FILE *fp;
623        bool result;
624        struct stat st;
625        char *content;
626    
627        fp = CVS_FOPEN (finfo->file, "r");
628        if (fp == NULL)
629            error (1, errno, "cannot open %s", finfo->fullname);
630        if (fstat (fileno (fp), &st))
631            error (1, errno, "cannot fstat `%s'", finfo->fullname);
632        content = xmalloc (st.st_size);
633        if (fread (content, sizeof *content, st.st_size, fp) < st.st_size)
634            error (1, errno, "Failed to read from `%s'", finfo->fullname);
635        result = contains_keyword (content, st.st_size);
636        if (fclose (fp) < 0)
637            error (0, errno, "cannot close %s", finfo->fullname);
638        free (content);
639        return result;
640    }
641    
642    
643    
644  /* Read the entire contents of the file NAME into *BUF.  /* Read the entire contents of the file NAME into *BUF.
645     If NAME is NULL, read from stdin.  *BUF     If NAME is NULL, read from stdin.  *BUF
646     is a pointer returned from malloc (or NULL), pointing to *BUFSIZE     is a pointer returned from malloc (or NULL), pointing to *BUFSIZE

Legend:
Removed from v.1.148.4.1  
changed lines
  Added in v.1.148.4.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26