/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* cscope - interactive C symbol cross-reference
*
* build cross-reference file
*/
#include "global.h"
/* convert long to a string */
*s = '\0'; \
digits = 1; \
while (n >= BASE) { \
++digits; \
i = n; \
n /= BASE; \
*--s = i - n * BASE + '!'; \
} \
*--s = n + '!';
} *symbol;
static void putcrossref(void);
void
{
int i;
/* open the source file */
errorsfound = YES;
return;
}
dbputc('\n');
dbputc('\n');
/* read the source file */
fcnoffset = macrooffset = 0;
symbols = 0;
}
for (;;) {
/* get the next token */
default:
/* if requested, truncate C symbols */
length = 8;
}
/* see if the token has a symbol */
if (length == 0) {
break;
}
/* see if the symbol is already in the list */
for (i = 0; i < symbols; ++i) {
break;
}
}
if (i == symbols) { /* if not already in list */
}
break;
case NEWLINE: /* end of line containing symbols */
--yyleng; /* remove the newline */
putcrossref(); /* output the symbols and source line */
break;
case LEXEOF: /* end of file; last line may not have \n */
/*
* if there were symbols, output them and the
* source line
*/
if (symbols > 0) {
putcrossref();
}
/* output the leading tab expected by the next call */
dbputc('\t');
return;
}
}
}
/* save the symbol in the list */
void
{
/* make sure there is room for the symbol */
}
/* save the symbol */
++symbols;
}
/* output the file name */
void
{
/* check for file system out of space */
/* note: dbputc is not used to avoid lint complaint */
/* NOTREACHED */
}
++dboffset;
if (invertedindex) {
}
fcnoffset = macrooffset = 0;
}
/* output the symbols and source line */
static void
putcrossref(void)
{
int i, j;
unsigned c;
int type;
/* output the source line */
for (i = 0; i < yyleng; ++i) {
/* change a tab to a blank and compress blanks */
}
/* look for the start of a symbol */
/* check for compressed blanks */
if (blank) {
if (newline) {
dbputc('\n');
}
dbputc(' ');
}
/* output any symbol type */
dbputc('\t');
} else {
type = ' ';
}
/* output the symbol */
c = yytext[j];
yytext[j] = '\0';
if (invertedindex) {
}
yytext[j] = (char)c;
i = j - 1;
++symput;
} else {
if (newline) {
dbputc('\n');
}
/* check for compressed blanks */
if (blank) {
if (dicode2[c]) {
dicode2[c];
} else {
dbputc(' ');
}
} else if (dicode1[c] &&
/* compress digraphs */
++i;
}
/*
* if the last line of the file is a '}' without a
* newline, the lex EOF code overwrites it with a 0
*/
if (c) {
dbputc((int)c);
} else {
dbputc(' ');
}
/* skip compressed characters */
if (c < ' ') {
++i;
/* skip blanks before a preprocesor keyword */
/*
* note: don't use isspace() because \f and \v
* are used for keywords
*/
++i;
}
/* skip the rest of the keyword */
++i;
}
/* skip space after certain keywords */
while ((j = yytext[i]) == ' ' ||
j == '\t') {
++i;
}
}
/* skip a '(' after certain keywords */
yytext[i] == '(') {
++i;
}
--i; /* compensate for ++i in for() */
}
}
}
/* ignore trailing blanks */
dbputc('\n');
dbputc('\n');
/* output any #define end marker */
/*
* note: must not be part of #define so putsource() doesn't discard it
* so findcalledbysub() can find it and return
*/
dbputc('\t');
dbputc('\n');
macrooffset = 0;
}
symbols = 0;
}
/* output the inverted index posting */
void
{
long i, n;
char *s;
/* get the function or macro name offset */
if (macrooffset != 0) {
}
/* then update them to avoid negative relative name offset */
switch (type) {
case DEFINE:
break;
case DEFINEEND:
macrooffset = 0;
return; /* null term */
case FCNDEF:
break;
case FCNEND:
fcnoffset = 0;
return; /* null term */
}
if (*term == '\0') {
return;
}
/* skip any #include secondary type char (< or ") */
++term;
}
/*
* output the posting, which should be as small as possible to reduce
* the temp file size and sort time
*/
/*
* the line offset is padded so postings for the same term will sort
* in ascending line offset order to order the references as they
* appear withing a source file
*/
}
do {
} while (*++s != '\0');
/* postings are also sorted by type */
/* function or macro name offset */
if (offset > 0) {
do {
} while (*++s != '\0');
}
/* NOTREACHED */
}
++npostings;
}
/* put the string into the new database */
void
putstring(char *s)
{
unsigned c;
int i;
/* compress digraphs */
for (i = 0; (c = s[i]) != '\0'; ++i) {
dicode2[(unsigned)s[i + 1]];
++i;
}
dbputc((int)c);
}
}
/* print a warning message with the file name and line number */
void
char *text;
{
extern int yylineno;
errorsfound = YES;
}