Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

filelocStack.c File Reference

#include "lclintMacros.nf"
#include "basic.h"
#include "filelocStack.h"

Go to the source code of this file.

Functions

filelocStack filelocStack_new ()
fileloc filelocStack_nextTop (filelocStack s)
void filelocStack_clear (filelocStack s)
bool filelocStack_popPushFile (filelocStack s, fileloc el)
cstring filelocStack_unparse (filelocStack s)
int filelocStack_includeDepth (filelocStack s)
void filelocStack_printIncludes (filelocStack s)
void filelocStack_free ( filelocStack s)


Function Documentation

void filelocStack_clear ( filelocStack s )
 

Definition at line 91 of file filelocStack.c.

Referenced by context_exitFile().

00092 {
00093   if (filelocStack_isDefined (s))
00094     {
00095       int i;
00096 
00097       for (i = 0; i < s->nelements; i++)
00098         {
00099           fileloc_free (s->elements[i]);
00100         }
00101 
00102       s->free += s->nelements;
00103       s->nelements = 0;
00104     }
00105 }

void filelocStack_free ( filelocStack s )
 

Definition at line 215 of file filelocStack.c.

Referenced by context_destroyMod().

00216 {
00217   if (filelocStack_isDefined (s))
00218     {
00219       int i;
00220       for (i = 0; i < s->nelements; i++)
00221         {
00222           fileloc_free (s->elements[i]); 
00223         }
00224       
00225       sfree (s->elements); 
00226       sfree (s);
00227     }
00228 }

int filelocStack_includeDepth ( filelocStack s )
 

Definition at line 163 of file filelocStack.c.

Referenced by context_setFilename().

00164 {
00165   int depth = 0;
00166   int i;
00167 
00168   if (filelocStack_isDefined (s))
00169     {
00170       /* the zeroth element doesn't count! */
00171       for (i = s->nelements - 1; i > 0; i--)
00172         {
00173           if (!fileloc_isSpecialFile (s->elements[i]))
00174             {
00175               depth++;
00176             }
00177         }
00178     }
00179 
00180   return depth;
00181 }

filelocStack filelocStack_new ( )
 

Definition at line 45 of file filelocStack.c.

Referenced by context_initMod().

00046 {
00047   return (filelocStack_newEmpty ());
00048 }

fileloc filelocStack_nextTop ( filelocStack s )
 

Definition at line 84 of file filelocStack.c.

Referenced by context_setFilename().

00085 {
00086   llassert (filelocStack_isDefined (s) && s->nelements > 1);
00087 
00088   return (s->elements[s->nelements - 2]);
00089 }

bool filelocStack_popPushFile ( filelocStack s,
fileloc el )
 

Definition at line 111 of file filelocStack.c.

Referenced by context_setFilename().

00112 {
00113   int i;
00114 
00115   llassert (filelocStack_isDefined (s));
00116 
00117   for (i = s->nelements - 1; i >= 0; i--)
00118     {
00119       if (fileloc_sameBaseFile (s->elements[i], el))
00120         {
00121           int j;
00122           
00123           for (j = i; j < s->nelements; j++)
00124             {
00125               fileloc_free (s->elements[j]);
00126             }
00127 
00128           s->elements[i] = el;
00129           s->nelements = i + 1;
00130           return FALSE;
00131         }
00132     }
00133 
00134   filelocStack_push (s, el);
00135   return TRUE;
00136 }

void filelocStack_printIncludes ( filelocStack s )
 

Definition at line 184 of file filelocStack.c.

Referenced by context_setFilename(), and context_showFilelocStack().

00185 {
00186   if (filelocStack_isDefined (s))
00187     {
00188       int i;
00189       bool prep = context_isPreprocessing ();
00190       
00191       if (prep)
00192         {
00193           /* need to do this for messages */
00194           context_clearPreprocessing ();
00195         }
00196 
00197       /* don't show last two files pushed */
00198       for (i = s->nelements - 3; i >= 0; i--)
00199         {
00200           if (i == 0 || !fileloc_isSpecialFile (s->elements[i]))
00201             {
00202               llgenindentmsg (cstring_makeLiteral ("Include site"),
00203                               s->elements[i]);
00204             }
00205         }
00206 
00207       if (prep)
00208         {
00209           context_setPreprocessing ();
00210         }
00211     }
00212 }

cstring filelocStack_unparse ( filelocStack s )
 

Definition at line 139 of file filelocStack.c.

00140 {
00141    int i;
00142    cstring st = cstring_makeLiteral ("[");
00143 
00144    if (filelocStack_isDefined (s))
00145      {
00146        for (i = s->nelements - 1; i >= 0; i--)
00147          {
00148            if (i == s->nelements - 1)
00149              {
00150                st = message ("%q %q", st, fileloc_unparse (s->elements[i]));
00151              }
00152            else
00153              {
00154                st = message ("%q, %q", st, fileloc_unparse (s->elements[i]));
00155              }
00156          }
00157      }
00158    
00159    st = message ("%q ]", st);
00160    return st;
00161 }


Generated at Fri Nov 3 18:57:58 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000