Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:44:45 UTC

view on githubraw file Latest commit bf5846c3 on 2004-02-25 18:19:54 UTC
bf5846c3a1 Ed H*0001 /* $XConsortium: pr.c,v 1.17 94/04/17 20:10:38 gildea Exp $ */
                0002 /*
                0003  * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
                0004  *
                0005  * Redistribution and use in source and binary forms, with or without
                0006  * modification, are permitted provided that the following conditions
                0007  * are met:
                0008  *
                0009  * 1. Redistributions of source code must retain the above copyright
                0010  *    notice, this list of conditions and the following disclaimer. 
                0011  *
                0012  * 2. Redistributions in binary form must reproduce the above copyright
                0013  *    notice, this list of conditions and the following disclaimer in
                0014  *    the documentation and/or other materials provided with the
                0015  *    distribution.
                0016  *
                0017  * 3. The name "Carnegie Mellon University" must not be used to
                0018  *    endorse or promote products derived from this software without
                0019  *    prior written permission. For permission or any other legal
                0020  *    details, please contact  
                0021  *      Office of Technology Transfer
                0022  *      Carnegie Mellon University
                0023  *      5000 Forbes Avenue
                0024  *      Pittsburgh, PA  15213-3890
                0025  *      (412) 268-4387, fax: (412) 268-7395
                0026  *      tech-transfer@andrew.cmu.edu
                0027  *
                0028  * 4. Redistributions of any form whatsoever must retain the following
                0029  *    acknowledgment:
                0030  *    "This product includes software developed by Computing Services
                0031  *     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
                0032  *
                0033  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
                0034  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
                0035  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
                0036  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                0037  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
                0038  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
                0039  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                0040  *
                0041  */
                0042 /*
                0043 
                0044 Copyright (c) 1993, 1994  X Consortium
                0045 
                0046 Permission is hereby granted, free of charge, to any person obtaining a copy
                0047 of this software and associated documentation files (the "Software"), to deal
                0048 in the Software without restriction, including without limitation the rights
                0049 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                0050 copies of the Software, and to permit persons to whom the Software is
                0051 furnished to do so, subject to the following conditions:
                0052 
                0053 The above copyright notice and this permission notice shall be included in
                0054 all copies or substantial portions of the Software.
                0055 
                0056 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                0057 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                0058 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
                0059 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
                0060 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
                0061 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
                0062 
                0063 Except as contained in this notice, the name of the X Consortium shall not be
                0064 used in advertising or otherwise to promote the sale, use or other dealings
                0065 in this Software without prior written authorization from the X Consortium.
                0066 
                0067 */
                0068 
                0069 #include "def.h"
                0070 
                0071 extern struct   inclist inclist[ MAXFILES ],
                0072             *inclistp;
                0073 extern char *objprefix;
                0074 extern char *objsuffix;
                0075 extern int  width;
                0076 extern boolean  printed;
                0077 extern boolean  verbose;
                0078 extern boolean  show_where_not;
                0079 
                0080 add_include(filep, file, file_red, include, dot, failOK)
                0081     struct filepointer  *filep;
                0082     struct inclist  *file, *file_red;
                0083     char    *include;
                0084     boolean dot;
                0085 {
                0086     register struct inclist *newfile;
                0087     register struct filepointer *content;
                0088 
                0089     /*
                0090      * First decide what the pathname of this include file really is.
                0091      */
                0092     newfile = inc_path(file->i_file, include, dot);
                0093     if (newfile == NULL) {
                0094         if (failOK)
                0095             return;
                0096         if (file != file_red)
                0097             warning("%s (reading %s, line %d): ",
                0098                 file_red->i_file, file->i_file, filep->f_line);
                0099         else
                0100             warning("%s, line %d: ", file->i_file, filep->f_line);
                0101         warning1("cannot find include file \"%s\"\n", include);
                0102         show_where_not = TRUE;
                0103         newfile = inc_path(file->i_file, include, dot);
                0104         show_where_not = FALSE;
                0105     }
                0106 
                0107     if (newfile) {
                0108         included_by(file, newfile);
                0109         if (!newfile->i_searched) {
                0110             newfile->i_searched = TRUE;
                0111             content = getfile(newfile->i_file);
                0112             find_includes(content, newfile, file_red, 0, failOK);
                0113             freefile(content);
                0114         }
                0115     }
                0116 }
                0117 
                0118 recursive_pr_include(head, file, base)
                0119     register struct inclist *head;
                0120     register char   *file, *base;
                0121 {
                0122     register int    i;
                0123 
                0124     if (head->i_marked)
                0125         return;
                0126     head->i_marked = TRUE;
                0127     if (head->i_file != file)
                0128         pr(head, file, base);
                0129     for (i=0; i<head->i_listlen; i++)
                0130         recursive_pr_include(head->i_list[ i ], file, base);
                0131 }
                0132 
                0133 pr(ip, file, base)
                0134     register struct inclist  *ip;
                0135     char    *file, *base;
                0136 {
                0137     static char *lastfile;
                0138     static int  current_len;
                0139     register int    len, i;
                0140     char    buf[ BUFSIZ ];
                0141 
                0142     printed = TRUE;
                0143     len = strlen(ip->i_file)+1;
                0144     if (current_len + len > width || file != lastfile) {
                0145         lastfile = file;
                0146         sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
                0147             ip->i_file);
                0148         len = current_len = strlen(buf);
                0149     }
                0150     else {
                0151         buf[0] = ' ';
                0152         strcpy(buf+1, ip->i_file);
                0153         current_len += len;
                0154     }
                0155     fwrite(buf, len, 1, stdout);
                0156 
                0157     /*
                0158      * If verbose is set, then print out what this file includes.
                0159      */
                0160     if (! verbose || ip->i_list == NULL || ip->i_notified)
                0161         return;
                0162     ip->i_notified = TRUE;
                0163     lastfile = NULL;
                0164     printf("\n# %s includes:", ip->i_file);
                0165     for (i=0; i<ip->i_listlen; i++)
                0166         printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
                0167 }