|
Packit |
40b132 |
/* $Xorg: pr.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
|
|
Packit |
40b132 |
/*
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
Copyright (c) 1993, 1994, 1998 The Open Group
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
40b132 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
40b132 |
the above copyright notice appear in all copies and that both that
|
|
Packit |
40b132 |
copyright notice and this permission notice appear in supporting
|
|
Packit |
40b132 |
documentation.
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
The above copyright notice and this permission notice shall be included in
|
|
Packit |
40b132 |
all copies or substantial portions of the Software.
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
40b132 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
40b132 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
40b132 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit |
40b132 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit |
40b132 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit |
40b132 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit |
40b132 |
in this Software without prior written authorization from The Open Group.
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
*/
|
|
Packit |
40b132 |
/* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
#include "def.h"
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
extern struct inclist inclist[ MAXFILES ],
|
|
Packit |
40b132 |
*inclistp;
|
|
Packit |
40b132 |
extern char *objprefix;
|
|
Packit |
40b132 |
extern char *objsuffix;
|
|
Packit |
40b132 |
extern int width;
|
|
Packit |
40b132 |
extern boolean printed;
|
|
Packit |
40b132 |
extern boolean verbose;
|
|
Packit |
40b132 |
extern boolean show_where_not;
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
void
|
|
Packit |
40b132 |
add_include(struct filepointer *filep, struct inclist *file,
|
|
Packit |
40b132 |
struct inclist *file_red, char *include, int type,
|
|
Packit |
40b132 |
boolean failOK)
|
|
Packit |
40b132 |
{
|
|
Packit |
40b132 |
register struct inclist *newfile;
|
|
Packit |
40b132 |
register struct filepointer *content;
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
/*
|
|
Packit |
40b132 |
* First decide what the pathname of this include file really is.
|
|
Packit |
40b132 |
*/
|
|
Packit |
40b132 |
newfile = inc_path(file->i_file, include, type);
|
|
Packit |
40b132 |
if (newfile == NULL) {
|
|
Packit |
40b132 |
if (failOK)
|
|
Packit |
40b132 |
return;
|
|
Packit |
40b132 |
if (file != file_red)
|
|
Packit |
40b132 |
warning("%s (reading %s, line %d): ",
|
|
Packit |
40b132 |
file_red->i_file, file->i_file, filep->f_line);
|
|
Packit |
40b132 |
else
|
|
Packit |
40b132 |
warning("%s, line %d: ", file->i_file, filep->f_line);
|
|
Packit |
40b132 |
warning1("cannot find include file \"%s\"\n", include);
|
|
Packit |
40b132 |
show_where_not = TRUE;
|
|
Packit |
40b132 |
newfile = inc_path(file->i_file, include, type);
|
|
Packit |
40b132 |
show_where_not = FALSE;
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
if (newfile) {
|
|
Packit |
40b132 |
included_by(file, newfile);
|
|
Packit |
40b132 |
if (!(newfile->i_flags & SEARCHED)) {
|
|
Packit |
40b132 |
newfile->i_flags |= SEARCHED;
|
|
Packit |
40b132 |
content = getfile(newfile->i_file);
|
|
Packit |
40b132 |
find_includes(content, newfile, file_red, 0, failOK);
|
|
Packit |
40b132 |
freefile(content);
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
static void
|
|
Packit |
40b132 |
pr(struct inclist *ip, char *file, char *base)
|
|
Packit |
40b132 |
{
|
|
Packit |
40b132 |
static char *lastfile;
|
|
Packit |
40b132 |
static int current_len;
|
|
Packit |
40b132 |
register int len, i;
|
|
Packit |
40b132 |
char buf[ BUFSIZ ];
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
printed = TRUE;
|
|
Packit |
40b132 |
len = strlen(ip->i_file)+1;
|
|
Packit |
40b132 |
if (current_len + len > width || file != lastfile) {
|
|
Packit |
40b132 |
lastfile = file;
|
|
Packit |
40b132 |
sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
|
|
Packit |
40b132 |
ip->i_file);
|
|
Packit |
40b132 |
len = current_len = strlen(buf);
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
else {
|
|
Packit |
40b132 |
buf[0] = ' ';
|
|
Packit |
40b132 |
strcpy(buf+1, ip->i_file);
|
|
Packit |
40b132 |
current_len += len;
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
fwrite(buf, len, 1, stdout);
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
/*
|
|
Packit |
40b132 |
* If verbose is set, then print out what this file includes.
|
|
Packit |
40b132 |
*/
|
|
Packit |
40b132 |
if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
|
|
Packit |
40b132 |
return;
|
|
Packit |
40b132 |
ip->i_flags |= NOTIFIED;
|
|
Packit |
40b132 |
lastfile = NULL;
|
|
Packit |
40b132 |
printf("\n# %s includes:", ip->i_file);
|
|
Packit |
40b132 |
for (i=0; i<ip->i_listlen; i++)
|
|
Packit |
40b132 |
printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
|
|
Packit |
40b132 |
}
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
void
|
|
Packit |
40b132 |
recursive_pr_include(struct inclist *head, char *file, char *base)
|
|
Packit |
40b132 |
{
|
|
Packit |
40b132 |
int i;
|
|
Packit |
40b132 |
|
|
Packit |
40b132 |
if (head->i_flags & MARKED)
|
|
Packit |
40b132 |
return;
|
|
Packit |
40b132 |
head->i_flags |= MARKED;
|
|
Packit |
40b132 |
if (head->i_file != file)
|
|
Packit |
40b132 |
pr(head, file, base);
|
|
Packit |
40b132 |
for (i=0; i<head->i_listlen; i++)
|
|
Packit |
40b132 |
recursive_pr_include(head->i_list[ i ], file, base);
|
|
Packit |
40b132 |
}
|