Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
def.h File Reference
#include <X11/Xos.h>
#include <X11/Xfuncproto.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  symtab
struct  inclist
struct  filepointer

Defines

#define MAXDEFINES   512
#define MAXFILES   1024
#define MAXINCFILES   128 /* "-include" files */
#define MAXDIRS   64
#define SYMTABINC   10 /* must be > 1 for define() to work right */
#define TRUE   1
#define FALSE   0
#define IF   0
#define IFDEF   1
#define IFNDEF   2
#define ELSE   3
#define ENDIF   4
#define DEFINE   5
#define UNDEF   6
#define INCLUDE   7
#define LINE   8
#define PRAGMA   9
#define ERROR   10
#define IDENT   11
#define SCCS   12
#define ELIF   13
#define EJECT   14
#define WARNING   15
#define INCLUDENEXT   16
#define IFFALSE   17 /* pseudo value --- never matched */
#define ELIFFALSE   18 /* pseudo value --- never matched */
#define INCLUDEDOT   19 /* pseudo value --- never matched */
#define IFGUESSFALSE   20 /* pseudo value --- never matched */
#define ELIFGUESSFALSE   21 /* pseudo value --- never matched */
#define INCLUDENEXTDOT   22 /* pseudo value --- never matched */
#define debug(level, arg)
#define DEFCHECKED   (1<<0) /* whether defines have been checked */
#define NOTIFIED   (1<<1) /* whether we have revealed includes */
#define MARKED   (1<<2) /* whether it's in the makefile */
#define SEARCHED   (1<<3) /* whether we have read this */
#define FINISHED   (1<<4) /* whether we are done reading this */
#define INCLUDED_SYM

Typedefs

typedef unsigned char boolean

Functions

char * copy (char *str)
int match (char *str, char **list)
char * base_name (char *file)
char * getnextline (struct filepointer *fp)
struct symtab ** slookup (char *symbol, struct inclist *file)
struct symtab ** isdefined (char *symbol, struct inclist *file, struct inclist **srcfile)
struct symtab ** fdefined (char *symbol, struct inclist *file, struct inclist **srcfile)
struct filepointergetfile (char *file)
void included_by (struct inclist *ip, struct inclist *newfile)
struct inclistnewinclude (char *newfile, char *incstring)
void inc_clean (void)
struct inclistinc_path (char *file, char *include, int type)
void freefile (struct filepointer *fp)
void define2 (char *name, char *val, struct inclist *file)
void define (char *def, struct inclist *file)
void undefine (char *symbol, struct inclist *file)
int find_includes (struct filepointer *filep, struct inclist *file, struct inclist *file_red, int recursion, boolean failOK)
void recursive_pr_include (struct inclist *head, char *file, char *base)
void add_include (struct filepointer *filep, struct inclist *file, struct inclist *file_red, char *include, int type, boolean failOK)
int cppsetup (char *filename, char *line, struct filepointer *filep, struct inclist *inc)
void fatalerr (char *,...)
void warning (char *,...)
void warning1 (char *,...)

Class Documentation

struct symtab

Definition at line 99 of file def.h.

Class Members
char * s_name
char * s_value
struct inclist

Definition at line 111 of file def.h.

Collaboration diagram for inclist:
Class Members
struct symtab ** i_defs
char * i_file
unsigned char i_flags
char * i_incstring
struct inclist ** i_list
int i_listlen
boolean * i_merged
int i_ndefs
struct filepointer

Definition at line 124 of file def.h.

Class Members
long cmdinc_count
long cmdinc_line
char ** cmdinc_list
char * f_base
char * f_end
long f_len
long f_line
char * f_name
char * f_p

Define Documentation

#define debug (   level,
  arg 
)

Definition at line 94 of file def.h.

#define DEFCHECKED   (1<<0) /* whether defines have been checked */

Definition at line 105 of file def.h.

#define DEFINE   5

Definition at line 62 of file def.h.

#define EJECT   14

Definition at line 71 of file def.h.

#define ELIF   13

Definition at line 70 of file def.h.

#define ELIFFALSE   18 /* pseudo value --- never matched */

Definition at line 75 of file def.h.

#define ELIFGUESSFALSE   21 /* pseudo value --- never matched */

Definition at line 78 of file def.h.

#define ELSE   3

Definition at line 60 of file def.h.

#define ENDIF   4

Definition at line 61 of file def.h.

#define ERROR   10

Definition at line 67 of file def.h.

#define FALSE   0

Definition at line 54 of file def.h.

#define FINISHED   (1<<4) /* whether we are done reading this */

Definition at line 109 of file def.h.

#define IDENT   11

Definition at line 68 of file def.h.

#define IF   0

Definition at line 57 of file def.h.

#define IFDEF   1

Definition at line 58 of file def.h.

#define IFFALSE   17 /* pseudo value --- never matched */

Definition at line 74 of file def.h.

#define IFGUESSFALSE   20 /* pseudo value --- never matched */

Definition at line 77 of file def.h.

#define IFNDEF   2

Definition at line 59 of file def.h.

#define INCLUDE   7

Definition at line 64 of file def.h.

Value:
(1<<5) /* whether #include SYMBOL was found
                               Can't use i_list if TRUE */

Definition at line 110 of file def.h.

#define INCLUDEDOT   19 /* pseudo value --- never matched */

Definition at line 76 of file def.h.

#define INCLUDENEXT   16

Definition at line 73 of file def.h.

#define INCLUDENEXTDOT   22 /* pseudo value --- never matched */

Definition at line 79 of file def.h.

#define LINE   8

Definition at line 65 of file def.h.

#define MARKED   (1<<2) /* whether it's in the makefile */

Definition at line 107 of file def.h.

#define MAXDEFINES   512

Definition at line 48 of file def.h.

#define MAXDIRS   64

Definition at line 51 of file def.h.

#define MAXFILES   1024

Definition at line 49 of file def.h.

#define MAXINCFILES   128 /* "-include" files */

Definition at line 50 of file def.h.

#define NOTIFIED   (1<<1) /* whether we have revealed includes */

Definition at line 106 of file def.h.

#define PRAGMA   9

Definition at line 66 of file def.h.

#define SCCS   12

Definition at line 69 of file def.h.

#define SEARCHED   (1<<3) /* whether we have read this */

Definition at line 108 of file def.h.

#define SYMTABINC   10 /* must be > 1 for define() to work right */

Definition at line 52 of file def.h.

#define TRUE   1

Definition at line 53 of file def.h.

#define UNDEF   6

Definition at line 63 of file def.h.

#define WARNING   15

Definition at line 72 of file def.h.


Typedef Documentation

typedef unsigned char boolean

Definition at line 97 of file def.h.


Function Documentation

void add_include ( struct filepointer filep,
struct inclist file,
struct inclist file_red,
char *  include,
int  type,
boolean  failOK 
)

Definition at line 41 of file pr.c.

{
       register struct inclist     *newfile;
       register struct filepointer *content;

       /*
        * First decide what the pathname of this include file really is.
        */
       newfile = inc_path(file->i_file, include, type);
       if (newfile == NULL) {
              if (failOK)
                  return;
              if (file != file_red)
                     warning("%s (reading %s, line %d): ",
                            file_red->i_file, file->i_file, filep->f_line);
              else
                     warning("%s, line %d: ", file->i_file, filep->f_line);
              warning1("cannot find include file \"%s\"\n", include);
              show_where_not = TRUE;
              newfile = inc_path(file->i_file, include, type);
              show_where_not = FALSE;
       }

       if (newfile) {
              included_by(file, newfile);
              if (!(newfile->i_flags & SEARCHED)) {
                     newfile->i_flags |= SEARCHED;
                     content = getfile(newfile->i_file);
                     find_includes(content, newfile, file_red, 0, failOK);
                     freefile(content);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* base_name ( char *  file)

Definition at line 737 of file main.c.

{
       char   *p;

       file = copy(file);
       for(p=file+strlen(file); p>file && *p != '.'; p--) ;

       if (*p == '.')
              *p = '\0';
       return(file);
}

Here is the call graph for this function:

char* copy ( char *  str)

Definition at line 583 of file main.c.

{
       char   *p = (char *)malloc(strlen(str) + 1);

       strcpy(p, str);
       return(p);
}
int cppsetup ( char *  filename,
char *  line,
struct filepointer filep,
struct inclist inc 
)

Definition at line 208 of file cppsetup.c.

{
    IfParser ip;
    struct _parse_data pd;
    long val = 0;

    pd.filep = filep;
    pd.inc = inc;
    pd.line = line;
    pd.filename = filename;
    ip.funcs.handle_error = my_if_errors;
    ip.funcs.eval_defined = my_eval_defined;
    ip.funcs.eval_variable = my_eval_variable;
    ip.data = (char *) &pd;

    (void) ParseIfExpression (&ip, line, &val);
    if (val)
       return IF;
    else
       return IFFALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void define ( char *  def,
struct inclist file 
)

Definition at line 410 of file parse.c.

{
    char *val;

    /* Separate symbol name and its value */
    val = def;
    while (isalnum(*val) || *val == '_')
       val++;
    if (*val)
       *val++ = '\0';
    while (*val == ' ' || *val == '\t')
       val++;

    if (!*val)
       val = "1";
    define2(def, val, file);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void define2 ( char *  name,
char *  val,
struct inclist file 
)

Definition at line 325 of file parse.c.

{
    int first, last, below;
    register struct symtab **sp = NULL, **dest;
    struct symtab *stab;

    /* Make space if it's needed */
    if (file->i_defs == NULL)
    {
       file->i_defs = (struct symtab **)
                     malloc(sizeof (struct symtab*) * SYMTABINC);
       file->i_ndefs = 0;
    }
    else if (!(file->i_ndefs % SYMTABINC))
       file->i_defs = (struct symtab **)
                     realloc(file->i_defs,
                        sizeof(struct symtab*)*(file->i_ndefs+SYMTABINC));

    if (file->i_defs == NULL)
       fatalerr("malloc()/realloc() failure in insert_defn()\n");

    below = first = 0;
    last = file->i_ndefs - 1;
    while (last >= first)
    {
       /* Fast inline binary search */
       register char *s1;
       register char *s2;
       register int middle = (first + last) / 2;

       /* Fast inline strchr() */
       s1 = name;
       s2 = file->i_defs[middle]->s_name;
       while (*s1++ == *s2++)
           if (s2[-1] == '\0') break;

       /* If exact match, set sp and break */
       if (*--s1 == *--s2) 
       {
           sp = file->i_defs + middle;
           break;
       }

       /* If name > i_defs[middle] ... */
       if (*s1 > *s2) 
       {
           below = first;
           first = middle + 1;
       }
       /* else ... */
       else
       {
           below = last = middle - 1;
       }
    }

    /* Search is done.  If we found an exact match to the symbol name,
       just replace its s_value */
    if (sp != NULL)
    {
       debug(1,("redefining %s from %s to %s in file %s\n",
              name, (*sp)->s_value, val, file->i_file));
       free((*sp)->s_value);
       (*sp)->s_value = copy(val);
       return;
    }

    sp = file->i_defs + file->i_ndefs++;
    dest = file->i_defs + below + 1;
    while (sp > dest)
    {
       *sp = sp[-1];
       sp--;
    }
    stab = (struct symtab *) malloc(sizeof (struct symtab));
    if (stab == NULL)
       fatalerr("malloc()/realloc() failure in insert_defn()\n");

    debug(1,("defining %s to %s in file %s\n", name, val, file->i_file));
    stab->s_name = copy(name);
    stab->s_value = copy(val);
    *sp = stab;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fatalerr ( char *  ,
  ... 
)

Definition at line 833 of file main.c.

{
       va_list args;
       fprintf(stderr, "%s: error:  ", ProgramName);
       va_start(args, msg);
       vfprintf(stderr, msg, args);
       va_end(args);
       exit (1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct symtab** fdefined ( char *  symbol,
struct inclist file,
struct inclist **  srcfile 
) [read]

Definition at line 263 of file parse.c.

{
       struct inclist       **ip;
       struct symtab **val;
       int    i;
       static int    recurse_lvl = 0;

       if (file->i_flags & DEFCHECKED)
              return(NULL);
       debug(2,("Looking for %s in %s\n", symbol, file->i_file));
       file->i_flags |= DEFCHECKED;
       if ((val = slookup(symbol, file)))
              debug(1,("%s defined in %s as %s\n",
                      symbol, file->i_file, (*val)->s_value));
       if (val == NULL && file->i_list)
       {
              for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
                     if (file->i_merged[i]==FALSE) {
                            val = fdefined(symbol, *ip, srcfile);
                            file->i_merged[i]=merge2defines(file,*ip);
                            if (val!=NULL) break;
                     }
       }
       else if (val != NULL && srcfile != NULL) *srcfile = file;
       recurse_lvl--;
       file->i_flags &= ~DEFCHECKED;

       return(val);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int find_includes ( struct filepointer filep,
struct inclist file,
struct inclist file_red,
int  recursion,
boolean  failOK 
)

Definition at line 549 of file parse.c.

{
       struct inclist       *inclistp;
       char          **includedirsp;
       register char *line;
       register int  type;
       boolean recfailOK;

       while ((line = getnextline(filep))) {
              switch(type = deftype(line, filep, file_red, file, TRUE)) {
              case IF:
              doif:
                     type = find_includes(filep, file,
                            file_red, recursion+1, failOK);
                     while ((type == ELIF) || (type == ELIFFALSE) ||
                            (type == ELIFGUESSFALSE))
                            type = gobble(filep, file, file_red);
                     if (type == ELSE)
                            gobble(filep, file, file_red);
                     break;
              case IFFALSE:
              case IFGUESSFALSE:
                  doiffalse:
                     if (type == IFGUESSFALSE || type == ELIFGUESSFALSE)
                         recfailOK = TRUE;
                     else
                         recfailOK = failOK;
                     type = gobble(filep, file, file_red);
                     if (type == ELSE)
                         find_includes(filep, file,
                                     file_red, recursion+1, recfailOK);
                     else
                     if (type == ELIF)
                         goto doif;
                     else
                     if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE))
                         goto doiffalse;
                     break;
              case IFDEF:
              case IFNDEF:
                     if ((type == IFDEF && isdefined(line, file_red, NULL))
                      || (type == IFNDEF && !isdefined(line, file_red, NULL))) {
                            debug(1,(type == IFNDEF ?
                                "line %d: %s !def'd in %s via %s%s\n" : "",
                                filep->f_line, line,
                                file->i_file, file_red->i_file, ": doit"));
                            type = find_includes(filep, file,
                                   file_red, recursion+1, failOK);
                            while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE)
                                   type = gobble(filep, file, file_red);
                            if (type == ELSE)
                                   gobble(filep, file, file_red);
                     }
                     else {
                            debug(1,(type == IFDEF ?
                                "line %d: %s !def'd in %s via %s%s\n" : "",
                                filep->f_line, line,
                                file->i_file, file_red->i_file, ": gobble"));
                            type = gobble(filep, file, file_red);
                            if (type == ELSE)
                                   find_includes(filep, file,
                                          file_red, recursion+1, failOK);
                            else if (type == ELIF)
                                   goto doif;
                            else if (type == ELIFFALSE || type == ELIFGUESSFALSE)
                                   goto doiffalse;
                     }
                     break;
              case ELSE:
              case ELIFFALSE:
              case ELIFGUESSFALSE:
              case ELIF:
                     if (!recursion)
                            gobble(filep, file, file_red);
              case ENDIF:
                     if (recursion)
                            return(type);
              case DEFINE:
                     define(line, file);
                     break;
              case UNDEF:
                     if (!*line) {
                         warning("%s", file_red->i_file);
                         if (file_red != file)
                            warning1(" (reading %s)", file->i_file);
                         warning1(", line %d: incomplete undef == \"%s\"\n",
                            filep->f_line, line);
                         break;
                     }
                     undefine(line, file_red);
                     break;
              case INCLUDE:
              case INCLUDEDOT:
              case INCLUDENEXT:
              case INCLUDENEXTDOT:
                     inclistp = inclistnext;
                     includedirsp = includedirsnext;
                     debug(2,("%s, reading %s, includes %s\n",
                            file_red->i_file, file->i_file, line));
                     add_include(filep, file, file_red, line, type, failOK);
                     inclistnext = inclistp;
                     includedirsnext = includedirsp;
                     break;
              case ERROR:
              case WARNING:
                     warning("%s", file_red->i_file);
                     if (file_red != file)
                            warning1(" (reading %s)", file->i_file);
                     warning1(", line %d: %s\n",
                             filep->f_line, line);
                     break;
                  
              case PRAGMA:
              case IDENT:
              case SCCS:
              case EJECT:
                     break;
              case -1:
                     warning("%s", file_red->i_file);
                     if (file_red != file)
                         warning1(" (reading %s)", file->i_file);
                     warning1(", line %d: unknown directive == \"%s\"\n",
                             filep->f_line, line);
                     break;
              case -2:
                     warning("%s", file_red->i_file);
                     if (file_red != file)
                         warning1(" (reading %s)", file->i_file);
                     warning1(", line %d: incomplete include == \"%s\"\n",
                             filep->f_line, line);
                     break;
              }
       }
       file->i_flags |= FINISHED;
       debug(2,("finished with %s\n", file->i_file));
       return(-1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void freefile ( struct filepointer fp)

Definition at line 577 of file main.c.

{
       free(fp->f_base);
       free(fp);
}

Here is the caller graph for this function:

struct filepointer* getfile ( char *  file) [read]

Definition at line 533 of file main.c.

{
       int    fd;
       struct filepointer   *content;
       struct stat   st;

       content = (struct filepointer *)malloc(sizeof(struct filepointer));
       content->f_name = file;
       if ((fd = open(file, O_RDONLY)) < 0) {
              warning("cannot open \"%s\"\n", file);
              content->f_p = content->f_base = content->f_end = (char *)malloc(1);
              *content->f_p = '\0';
              return(content);
       }
       fstat(fd, &st);
       content->f_base = (char *)malloc(st.st_size+1);
       if (content->f_base == NULL)
              fatalerr("cannot allocate mem\n");
       if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)
              fatalerr("failed to read %s\n", file);
#ifdef __UNIXOS2__
       st.st_size = elim_cr(content->f_base,st.st_size);
#endif
       close(fd);
       content->f_len = st.st_size+1;
       content->f_p = content->f_base;
       content->f_end = content->f_base + st.st_size;
       *content->f_end = '\0';
       content->f_line = 0;
       content->cmdinc_count = 0;
       content->cmdinc_list = NULL;
       content->cmdinc_line = 0;
       return(content);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* getnextline ( struct filepointer fp)

Definition at line 606 of file main.c.

{
       char   *p,    /* walking pointer */
              *eof,  /* end of file pointer */
              *bol;  /* beginning of line pointer */
       int    lineno;       /* line number */
       boolean whitespace = FALSE;

       /*
        * Fake the "-include" line files in form of #include to the
        * start of each file.
        */
       if (filep->cmdinc_line < filep->cmdinc_count) {
              char *inc = filep->cmdinc_list[2 * filep->cmdinc_line + 0];
              char *buf = filep->cmdinc_list[2 * filep->cmdinc_line + 1];
              filep->cmdinc_line++;
              sprintf(buf,"%s%s%s",DASH_INC_PRE,inc,DASH_INC_POST);
              DBG_PRINT(stderr,"%s\n",buf);
              return(buf);
       }

       p = filep->f_p;
       eof = filep->f_end;
       if (p >= eof)
              return((char *)NULL);
       lineno = filep->f_line;

       for (bol = p--; ++p < eof; ) {
              if ((bol == p) && ((*p == ' ') || (*p == '\t')))
              {
                     /* Consume leading white-spaces for this line */
                     while (((p+1) < eof) && ((*p == ' ') || (*p == '\t')))
                     {
                            p++;
                            bol++;
                     }
                     whitespace = TRUE;
              }
        
              if (*p == '/' && (p+1) < eof && *(p+1) == '*') {
                     /* Consume C comments */
                     *(p++) = ' ';
                     *(p++) = ' ';
                     while (p < eof && *p) {
                            if (*p == '*' && (p+1) < eof && *(p+1) == '/') {
                                   *(p++) = ' ';
                                   *(p++) = ' ';
                                   break;
                            }
                            if (*p == '\n')
                                   lineno++;
                            *(p++) = ' ';
                     }
                     --p;
              }
              else if (*p == '/' && (p+1) < eof && *(p+1) == '/') {
                     /* Consume C++ comments */
                     *(p++) = ' ';
                     *(p++) = ' ';
                     while (p < eof && *p) {
                            if (*p == '\\' && (p+1) < eof &&
                                *(p+1) == '\n') {
                                   *(p++) = ' ';
                                   lineno++;
                            }
                            else if (*p == '?' && (p+3) < eof &&
                                    *(p+1) == '?' && 
                                    *(p+2) == '/' &&
                                    *(p+3) == '\n') {
                                   *(p++) = ' ';
                                   *(p++) = ' ';
                                   *(p++) = ' ';
                                   lineno++;
                            }
                            else if (*p == '\n')
                                   break; /* to process end of line */
                            *(p++) = ' ';
                     }
                     --p;
              }
              else if (*p == '\\' && (p+1) < eof && *(p+1) == '\n') {
                     /* Consume backslash line terminations */
                     *(p++) = ' ';
                     *p = ' ';
                     lineno++;
              }
              else if (*p == '?' && (p+3) < eof &&
                      *(p+1) == '?' && *(p+2) == '/' && *(p+3) == '\n') {
                     /* Consume trigraph'ed backslash line terminations */
                     *(p++) = ' ';
                     *(p++) = ' ';
                     *(p++) = ' ';
                     *p = ' ';
                     lineno++;
              }
              else if (*p == '\n') {
                     lineno++;
                     if (*bol == '#') {
                            char *cp;

                            *(p++) = '\0';
                            /* punt lines with just # (yacc generated) */
                            for (cp = bol+1; 
                                 *cp && (*cp == ' ' || *cp == '\t'); cp++);
                            if (*cp) goto done;
                            --p;
                     }
                     bol = p+1;
                     whitespace = FALSE;
              }
       }
       if (*bol != '#')
              bol = NULL;
done:
       if (bol && whitespace) {
              warning("%s:  non-portable whitespace encountered at line %d\n",
                     filep->f_name, lineno);
       }
       filep->f_p = p;
       filep->f_line = lineno;
#ifdef DEBUG_DUMP
       if (bol)
              DBG_PRINT(stderr,"%s\n",bol);
#endif
       return(bol);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 248 of file include.c.

{
       register struct inclist *ip;

       for (ip = inclist; ip < inclistp; ip++) {
              ip->i_flags &= ~MARKED;
       }
}

Here is the caller graph for this function:

struct inclist* inc_path ( char *  file,
char *  include,
int  type 
) [read]

Definition at line 258 of file include.c.

{
       static char          path[ BUFSIZ ];
       register char        **pp, *p;
       register struct inclist     *ip;

       /*
        * Check all previously found include files for a path that
        * has already been expanded.
        */
       if ((type == INCLUDE) || (type == INCLUDEDOT))
              inclistnext = inclist;
       ip = inclistnext;

       for (; ip->i_file; ip++) {
              if ((strcmp(ip->i_incstring, include) == 0) &&
                  !(ip->i_flags & INCLUDED_SYM)) {
                     inclistnext = ip + 1;
                     return ip;
              }
       }

       if (inclistnext == inclist) {
              /*
               * If the path was surrounded by "" or is an absolute path,
               * then check the exact path provided.
               */
              if ((type == INCLUDEDOT) ||
                  (type == INCLUDENEXTDOT) ||
                  (*include == '/')) {
                     if (does_file_exist(include))
                            return newinclude(include, include);
                     if (show_where_not)
                            warning1("\tnot in %s\n", include);
              }

              /*
               * If the path was surrounded by "" see if this include file is
               * in the directory of the file being parsed.
               */
              if ((type == INCLUDEDOT) || (type == INCLUDENEXTDOT)) {
                     for (p=file+strlen(file); p>file; p--)
                            if (*p == '/')
                                   break;
                     if (p == file) {
                            strcpy(path, include);
                     } else {
                            strncpy(path, file, (p-file) + 1);
                            path[ (p-file) + 1 ] = '\0';
                            strcpy(path + (p-file) + 1, include);
                     }
                     remove_dotdot(path);
                     if (does_file_exist(path))
                            return newinclude(path, include);
                     if (show_where_not)
                            warning1("\tnot in %s\n", path);
              }
       }

       /*
        * Check the include directories specified.  Standard include dirs
        * should be at the end.
        */
       if ((type == INCLUDE) || (type == INCLUDEDOT))
              includedirsnext = includedirs;
       pp = includedirsnext;

       for (; *pp; pp++) {
              sprintf(path, "%s/%s", *pp, include);
              remove_dotdot(path);
              if (does_file_exist(path)) {
                     includedirsnext = pp + 1;
                     return newinclude(path, include);
              }
              if (show_where_not)
                     warning1("\tnot in %s\n", path);
       }

       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void included_by ( struct inclist ip,
struct inclist newfile 
)

Definition at line 198 of file include.c.

{
       register int i;

       if (ip == NULL)
              return;
       /*
        * Put this include file (newfile) on the list of files included
        * by 'file'.  If 'file' is NULL, then it is not an include
        * file itself (i.e. was probably mentioned on the command line).
        * If it is already on the list, don't stick it on again.
        */
       if (ip->i_list == NULL) {
              ip->i_list = (struct inclist **)
                     malloc(sizeof(struct inclist *) * ++ip->i_listlen);
              ip->i_merged = (boolean *)
                  malloc(sizeof(boolean) * ip->i_listlen);
       } else {
              for (i=0; i<ip->i_listlen; i++)
                     if (ip->i_list[ i ] == newfile) {
                         i = strlen(newfile->i_file);
                         if (!(ip->i_flags & INCLUDED_SYM) &&
                            !(i > 2 &&
                              newfile->i_file[i-1] == 'c' &&
                              newfile->i_file[i-2] == '.'))
                         {
                            /* only bitch if ip has */
                            /* no #include SYMBOL lines  */
                            /* and is not a .c file */
                            if (warn_multiple)
                            {
                                   warning("%s includes %s more than once!\n",
                                          ip->i_file, newfile->i_file);
                                   warning1("Already have\n");
                                   for (i=0; i<ip->i_listlen; i++)
                                          warning1("\t%s\n", ip->i_list[i]->i_file);
                            }
                         }
                         return;
                     }
              ip->i_list = (struct inclist **) realloc(ip->i_list,
                     sizeof(struct inclist *) * ++ip->i_listlen);
              ip->i_merged = (boolean *)
                  realloc(ip->i_merged, sizeof(boolean) * ip->i_listlen);
       }
       ip->i_list[ ip->i_listlen-1 ] = newfile;
       ip->i_merged[ ip->i_listlen-1 ] = FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct symtab** isdefined ( char *  symbol,
struct inclist file,
struct inclist **  srcfile 
) [read]

Definition at line 294 of file parse.c.

{
       struct symtab **val;

       if ((val = slookup(symbol, &maininclist))) {
              debug(1,("%s defined on command line\n", symbol));
              if (srcfile != NULL) *srcfile = &maininclist;
              return(val);
       }
       if ((val = fdefined(symbol, file, srcfile)))
              return(val);
       debug(1,("%s not defined in %s\n", symbol, file->i_file));
       return(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int match ( char *  str,
char **  list 
)

Definition at line 592 of file main.c.

{
       int    i;

       for (i=0; *list; i++, list++)
              if (strcmp(str, *list) == 0)
                     return(i);
       return(-1);
}

Here is the call graph for this function:

struct inclist* newinclude ( char *  newfile,
char *  incstring 
) [read]

Definition at line 176 of file include.c.

{
       register struct inclist     *ip;

       /*
        * First, put this file on the global list of include files.
        */
       ip = inclistp++;
       if (inclistp == inclist + MAXFILES - 1)
              fatalerr("out of space: increase MAXFILES\n");
       ip->i_file = copy(newfile);

       if (incstring == NULL)
              ip->i_incstring = ip->i_file;
       else
              ip->i_incstring = copy(incstring);

       inclistnext = inclistp;
       return(ip);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void recursive_pr_include ( struct inclist head,
char *  file,
char *  base 
)

Definition at line 113 of file pr.c.

{
       int    i;

       if (head->i_flags & MARKED)
              return;
       head->i_flags |= MARKED;
       if (head->i_file != file)
              pr(head, file, base);
       for (i=0; i<head->i_listlen; i++)
              recursive_pr_include(head->i_list[ i ], file, base);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct symtab** slookup ( char *  symbol,
struct inclist file 
) [read]

Definition at line 429 of file parse.c.

{
       register int first = 0;
       register int last = file->i_ndefs - 1;

       if (file) while (last >= first)
       {
           /* Fast inline binary search */
           register char *s1;
           register char *s2;
           register int middle = (first + last) / 2;

           /* Fast inline strchr() */
           s1 = symbol;
           s2 = file->i_defs[middle]->s_name;
           while (*s1++ == *s2++)
               if (s2[-1] == '\0') break;

           /* If exact match, we're done */
           if (*--s1 == *--s2) 
           {
               return file->i_defs + middle;
           }

           /* If symbol > i_defs[middle] ... */
           if (*s1 > *s2) 
           {
               first = middle + 1;
           }
           /* else ... */
           else
           {
               last = middle - 1;
           }
       }
       return(NULL);
}

Here is the caller graph for this function:

void undefine ( char *  symbol,
struct inclist file 
)

Definition at line 536 of file parse.c.

{
       register struct symtab **ptr;
       struct inclist *srcfile;
       while ((ptr = isdefined(symbol, file, &srcfile)) != NULL)
       {
           srcfile->i_ndefs--;
           for (; ptr < srcfile->i_defs + srcfile->i_ndefs; ptr++)
              *ptr = ptr[1];
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void warning ( char *  ,
  ... 
)

Definition at line 844 of file main.c.

{
       va_list args;
       fprintf(stderr, "%s: warning:  ", ProgramName);
       va_start(args, msg);
       vfprintf(stderr, msg, args);
       va_end(args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void warning1 ( char *  ,
  ... 
)

Definition at line 854 of file main.c.

{
       va_list args;
       va_start(args, msg);
       vfprintf(stderr, msg, args);
       va_end(args);
}

Here is the call graph for this function:

Here is the caller graph for this function: