Back to index

enigmail  1.4.3
pr.c
Go to the documentation of this file.
00001 /* $Xorg: pr.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
00002 /*
00003 
00004 Copyright (c) 1993, 1994, 1998 The Open Group
00005 
00006 Permission to use, copy, modify, distribute, and sell this software and its
00007 documentation for any purpose is hereby granted without fee, provided that
00008 the above copyright notice appear in all copies and that both that
00009 copyright notice and this permission notice appear in supporting
00010 documentation.
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00018 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 
00022 Except as contained in this notice, the name of The Open Group shall not be
00023 used in advertising or otherwise to promote the sale, use or other dealings
00024 in this Software without prior written authorization from The Open Group.
00025 
00026 */
00027 /* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
00028 
00029 #include "def.h"
00030 
00031 extern struct inclist       inclist[ MAXFILES ],
00032                      *inclistp;
00033 extern char   *objprefix;
00034 extern char   *objsuffix;
00035 extern int    width;
00036 extern boolean       printed;
00037 extern boolean       verbose;
00038 extern boolean       show_where_not;
00039 
00040 void
00041 add_include(struct filepointer *filep, struct inclist *file, 
00042            struct inclist *file_red, char *include, int type,
00043            boolean failOK)
00044 {
00045        register struct inclist     *newfile;
00046        register struct filepointer *content;
00047 
00048        /*
00049         * First decide what the pathname of this include file really is.
00050         */
00051        newfile = inc_path(file->i_file, include, type);
00052        if (newfile == NULL) {
00053               if (failOK)
00054                   return;
00055               if (file != file_red)
00056                      warning("%s (reading %s, line %d): ",
00057                             file_red->i_file, file->i_file, filep->f_line);
00058               else
00059                      warning("%s, line %d: ", file->i_file, filep->f_line);
00060               warning1("cannot find include file \"%s\"\n", include);
00061               show_where_not = TRUE;
00062               newfile = inc_path(file->i_file, include, type);
00063               show_where_not = FALSE;
00064        }
00065 
00066        if (newfile) {
00067               included_by(file, newfile);
00068               if (!(newfile->i_flags & SEARCHED)) {
00069                      newfile->i_flags |= SEARCHED;
00070                      content = getfile(newfile->i_file);
00071                      find_includes(content, newfile, file_red, 0, failOK);
00072                      freefile(content);
00073               }
00074        }
00075 }
00076 
00077 static void
00078 pr(struct inclist *ip, char *file, char *base)
00079 {
00080        static char   *lastfile;
00081        static int    current_len;
00082        register int  len, i;
00083        char   buf[ BUFSIZ ];
00084 
00085        printed = TRUE;
00086        len = strlen(ip->i_file)+1;
00087        if (current_len + len > width || file != lastfile) {
00088               lastfile = file;
00089               sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
00090                      ip->i_file);
00091               len = current_len = strlen(buf);
00092        }
00093        else {
00094               buf[0] = ' ';
00095               strcpy(buf+1, ip->i_file);
00096               current_len += len;
00097        }
00098        fwrite(buf, len, 1, stdout);
00099 
00100        /*
00101         * If verbose is set, then print out what this file includes.
00102         */
00103        if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
00104               return;
00105        ip->i_flags |= NOTIFIED;
00106        lastfile = NULL;
00107        printf("\n# %s includes:", ip->i_file);
00108        for (i=0; i<ip->i_listlen; i++)
00109               printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
00110 }
00111 
00112 void
00113 recursive_pr_include(struct inclist *head, char *file, char *base)
00114 {
00115        int    i;
00116 
00117        if (head->i_flags & MARKED)
00118               return;
00119        head->i_flags |= MARKED;
00120        if (head->i_file != file)
00121               pr(head, file, base);
00122        for (i=0; i<head->i_listlen; i++)
00123               recursive_pr_include(head->i_list[ i ], file, base);
00124 }