LCOV - code coverage report
Current view: top level - soltools/mkdepend - pr.c (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 62 0.0 %
Date: 2014-04-11 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* $XConsortium: pr.c,v 1.17 94/04/17 20:10:38 gildea Exp $ */
       3             : /*
       4             : 
       5             : Copyright (c) 1993, 1994  X Consortium
       6             : 
       7             : Permission is hereby granted, free of charge, to any person obtaining a copy
       8             : of this software and associated documentation files (the "Software"), to deal
       9             : in the Software without restriction, including without limitation the rights
      10             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      11             : copies of the Software, and to permit persons to whom the Software is
      12             : furnished to do so, subject to the following conditions:
      13             : 
      14             : The above copyright notice and this permission notice shall be included in
      15             : all copies or substantial portions of the Software.
      16             : 
      17             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      18             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      19             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
      20             : X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
      21             : AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
      22             : CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      23             : 
      24             : Except as contained in this notice, the name of the X Consortium shall not be
      25             : used in advertising or otherwise to promote the sale, use or other dealings
      26             : in this Software without prior written authorization from the X Consortium.
      27             : 
      28             : */
      29             : 
      30             : #include "def.h"
      31             : #include <string.h>
      32             : size_t pr( struct inclist *ip, char *file,char *base);
      33             : 
      34             : extern struct   inclist inclist[ MAXFILES ],
      35             :             *inclistp;
      36             : extern char *objprefix;
      37             : extern char *objsuffix;
      38             : extern int  width;
      39             : extern boolean  printed;
      40             : extern boolean  verbose;
      41             : extern boolean  show_where_not;
      42             : 
      43           0 : void add_include(struct filepointer *filep, struct inclist *file, struct inclist *file_red, char *include, boolean dot, boolean failOK, struct IncludesCollection* incCollection, struct symhash *symbols)
      44             : {
      45             :     register struct inclist *newfile;
      46             :     register struct filepointer *content;
      47             : 
      48             :     /*
      49             :      * First decide what the pathname of this include file really is.
      50             :      */
      51           0 :     newfile = inc_path(file->i_file, include, dot, incCollection);
      52           0 :     if (newfile == NULL) {
      53           0 :         if (failOK)
      54           0 :             return;
      55           0 :         if (file != file_red)
      56           0 :             warning("%s (reading %s, line %d): ",
      57             :                 file_red->i_file, file->i_file, filep->f_line);
      58             :         else
      59           0 :             warning("%s, line %d: ", file->i_file, filep->f_line);
      60           0 :         warning1("cannot find include file \"%s\"\n", include);
      61           0 :         show_where_not = TRUE;
      62           0 :         newfile = inc_path(file->i_file, include, dot, incCollection);
      63           0 :         show_where_not = FALSE;
      64             :     }
      65             : 
      66           0 :     if (newfile) {
      67             : 
      68             :         /* Only add new dependency files if they don't have "/usr/include" in them. */
      69           0 :         if (!(newfile && newfile->i_file && strstr(newfile->i_file, "/usr/"))) {
      70           0 :             included_by(file, newfile);
      71             :         }
      72             : 
      73           0 :         if (!newfile->i_searched) {
      74           0 :             newfile->i_searched = TRUE;
      75           0 :             content = getfile(newfile->i_file);
      76           0 :             find_includes(content, newfile, file_red, 0, failOK, incCollection, symbols);
      77           0 :             freefile(content);
      78             :         }
      79             :     }
      80             : }
      81             : 
      82           0 : void pr_dummy(ip)
      83             :     register struct inclist  *ip;
      84             : {
      85           0 :     fwrite(ip->i_file, strlen(ip->i_file), 1, stdout);
      86           0 :     fwrite(" :\n\n", 4, 1, stdout);
      87           0 : }
      88             : 
      89           0 : void recursive_pr_dummy(head, file)
      90             :     register struct inclist *head;
      91             :     register char   *file;
      92             : {
      93             :     register int    i;
      94             : 
      95           0 :     if (head->i_marked == 2)
      96           0 :         return;
      97           0 :     head->i_marked = 2; // it's a large boolean...
      98           0 :     if (head->i_file != file)
      99           0 :         pr_dummy(head);
     100           0 :     for (i=0; i<head->i_listlen; i++)
     101           0 :         recursive_pr_dummy(head->i_list[ i ], file);
     102             : }
     103             : 
     104             : 
     105           0 : void recursive_pr_include(head, file, base)
     106             :     register struct inclist *head;
     107             :     register char   *file, *base;
     108             : {
     109             :     register int    i;
     110             : 
     111           0 :     if (head->i_marked)
     112           0 :         return;
     113           0 :     head->i_marked = TRUE;
     114           0 :     if (head->i_file != file)
     115           0 :         pr(head, file, base);
     116           0 :     for (i=0; i<head->i_listlen; i++)
     117           0 :         recursive_pr_include(head->i_list[ i ], file, base);
     118             : }
     119             : 
     120           0 : size_t pr(ip, file, base)
     121             :     register struct inclist  *ip;
     122             :     char    *file, *base;
     123             : {
     124             :     size_t ret;
     125             :     static char *lastfile;
     126             :     static int  current_len;
     127             :     register int    len, i;
     128             :     char    buf[ BUFSIZ ];
     129             : 
     130           0 :     printed = TRUE;
     131           0 :     len = (int)strlen(ip->i_file)+4;
     132           0 :     if (file != lastfile) {
     133           0 :         lastfile = file;
     134           0 :         sprintf(buf, "\n%s%s%s: \\\n %s", objprefix, base, objsuffix,
     135             :             ip->i_file);
     136           0 :         len = current_len = (int)strlen(buf);
     137             :     }
     138             :     else {
     139           0 :         buf[0] = ' ';
     140           0 :         buf[1] = '\\';
     141           0 :         buf[2] = '\n';
     142           0 :         buf[3] = ' ';
     143           0 :         strcpy(buf+4, ip->i_file);
     144           0 :         current_len += len;
     145             :     }
     146           0 :     ret = fwrite(buf, len, 1, stdout);
     147             : 
     148             :     /*
     149             :      * If verbose is set, then print out what this file includes.
     150             :      */
     151           0 :     if (! verbose || ip->i_list == NULL || ip->i_notified)
     152           0 :         return ret;
     153           0 :     ip->i_notified = TRUE;
     154           0 :     lastfile = NULL;
     155           0 :     printf("\n# %s includes:", ip->i_file);
     156           0 :     for (i=0; i<ip->i_listlen; i++)
     157           0 :         printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
     158           0 :     return ret;
     159             : }
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10