]> andersk Git - splint.git/blobdiff - src/cpplib.c
*** empty log message ***
[splint.git] / src / cpplib.c
index 801de39eeae590ce2d607b0e5389b546237a007d..c523479663a51eb8c583e1c1f382eb1e11806a3a 100644 (file)
@@ -130,7 +130,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 # include "lclintMacros.nf"
 # include "llbasic.h"
 # include "lcllib.h"
-# include "cpp.h"
 # include "cpplib.h"
 # include "cpperror.h"
 # include "cpphash.h"
@@ -184,7 +183,7 @@ static void cpp_setLocation (cppReader *p_pfile)
 
 static enum cpp_token cpp_handleComment (cppReader *p_pfile,
                                         struct parse_marker *p_smark)
-     /*@modifies *p_pfile, *p_smark@*/;
+     /*@modifies p_pfile, p_smark@*/;
 
 static bool cpp_shouldCheckMacro (cppReader *p_pfile, char *p_p) /*@*/ ;
 
@@ -442,7 +441,7 @@ static int open_include_file (cppReader *p_pfile,
 
 static void push_macro_expansion (cppReader *,
                                  /*@owned@*/ char *, size_t,
-                                 /*@dependent@*/ HASHNODE *);
+                                 /*@dependent@*/ hashNode);
 
 /* Last arg to output_line_command.  */
 enum file_change_code {
@@ -821,6 +820,29 @@ cppReader_showIncludeChain (cppReader *pfile)
     }
 }
 
+cstring 
+cppReader_getIncludePath ()
+{
+  cppReader *pfile = &g_cppState;
+  struct file_name_list *dirs = CPPOPTIONS (pfile)->include;
+  cstring res = cstring_undefined;
+
+  if (dirs != NULL)
+    {
+      while (dirs != NULL)
+       {
+         res = message ("%q%c%s", res, PATH_SEPARATOR, dirs->fname);
+         dirs = dirs->next;
+       }
+    }
+  else
+    {
+      res = cstring_makeLiteral ("<no include path>");
+    }
+
+  return res;
+}
+
 void
 cppReader_addIncludeChain (cppReader *pfile, struct file_name_list *dir)
 {
@@ -946,7 +968,6 @@ cppOptions_init (cppOptions *opts)
   opts->for_lint = 0;
   opts->chill = 0;
   opts->pedantic_errors = 0;
-  opts->inhibit_warnings = 0;
   opts->warn_comments = 0;
   opts->warnings_are_errors = 0;
 
@@ -969,7 +990,7 @@ cppReader_nullCleanup (/*@unused@*/ cppBuffer *pbuf,
 void
 cppReader_macroCleanup (cppBuffer *pbuf, /*@unused@*/ cppReader *pfile)
 {
-  HASHNODE *macro = pbuf->hnode;
+  hashNode macro = pbuf->hnode;
 
   if (macro->type == T_DISABLED)
     {
@@ -1531,7 +1552,7 @@ collect_expansion (cppReader *pfile, char *buf, char *limit,
 
   if (limit - p >= 2 && p[0] == '#' && p[1] == '#') {
     cppReader_errorLit (pfile,
-                 cstring_makeLiteralTemp ("`##' at start of macro definition"));
+                       cstring_makeLiteralTemp ("`##' at start of macro definition"));
     p += 2;
   }
 
@@ -2149,7 +2170,7 @@ do_defineAux (cppReader *pfile, struct directive *keyword,
 {
   int hashcode;
   MACRODEF mdef;
-  HASHNODE *hp;
+  hashNode hp;
   
   DPRINTF (("Define aux: %d", noExpand));
 
@@ -2236,7 +2257,7 @@ do_defineAux (cppReader *pfile, struct directive *keyword,
       ** that for this new definition now.
       */
 
-      HASHNODE *hn;
+      hashNode hn;
 
       if (CPPOPTIONS (pfile)->debug_output && (keyword != NULL))
        {
@@ -2749,7 +2770,7 @@ static ob_mstring monthnames[] = {
  */
 
 static void
-special_symbol (HASHNODE *hp, cppReader *pfile)
+special_symbol (hashNode hp, cppReader *pfile)
 {
   cstring buf = cstring_undefined;
   size_t len;
@@ -3147,7 +3168,7 @@ unsafe_chars (char c1, char c2)
    an argument list follows; arguments come from the input stack.  */
 
 static void
-macroexpand (cppReader *pfile, /*@dependent@*/ HASHNODE *hp)
+macroexpand (cppReader *pfile, /*@dependent@*/ hashNode hp)
 {
   int nargs;
   DEFINITION *defn = hp->value.defn;
@@ -3314,6 +3335,8 @@ macroexpand (cppReader *pfile, /*@dependent@*/ HASHNODE *hp)
       size_t totlen;   /* total amount of exp buffer filled so far */
 
       register struct reflist *ap, *last_ap;
+      
+      assertSet (args); /* args is defined since the nargs > 0 path was taken */
 
       /* Macro really takes args.  Compute the expansion of this call.  */
 
@@ -3426,6 +3449,7 @@ macroexpand (cppReader *pfile, /*@dependent@*/ HASHNODE *hp)
            {
              /* Add 4 for two newline-space markers to prevent
                 token concatenation.  */
+             assertSet (args); /*@i534 shouldn't need this */
              xbuf_len += args[ap->argno].raw_length + 4;
            }
          else
@@ -3433,6 +3457,8 @@ macroexpand (cppReader *pfile, /*@dependent@*/ HASHNODE *hp)
              /* We have an ordinary (expanded) occurrence of the arg.
                 So compute its expansion, if we have not already.  */
 
+             assertSet (args); /*@i534 shouldn't need this */
+
              if (args[ap->argno].expand_length < 0)
                {
                  args[ap->argno].expanded = cppReader_getWritten (pfile);
@@ -3656,7 +3682,7 @@ macroexpand (cppReader *pfile, /*@dependent@*/ HASHNODE *hp)
 
 static void
 push_macro_expansion (cppReader *pfile, char *xbuf, size_t xbuf_len,
-                     /*@dependent@*/ HASHNODE *hp)
+                     /*@dependent@*/ hashNode hp)
 {
   cppBuffer *mbuf = cppReader_pushBuffer (pfile, xbuf, xbuf_len);
 
@@ -4302,8 +4328,9 @@ do_line (cppReader *pfile, /*@unused@*/ struct directive *keyword)
   if (token == CPP_STRING) {
     char *fname = pfile->token_buffer + old_written;
     char *end_name;
-    static HASHNODE *fname_table[FNAME_HASHSIZE];
-    HASHNODE *hp, **hash_bucket;
+    static hashNode fname_table[FNAME_HASHSIZE];
+    hashNode hp; 
+    hashNode *hash_bucket;
     char *p;
     size_t num_start;
     int fname_length;
@@ -4371,7 +4398,7 @@ do_line (cppReader *pfile, /*@unused@*/ struct directive *keyword)
 
     if (hp == 0) {
       /* Didn't find it; cons up a new one.  */
-      hp = (HASHNODE *) dmalloc (sizeof (*hp) + fname_length + 1);
+      hp = (hashNode) dmalloc (sizeof (*hp));
 
       hp->prev = NULL;
       hp->bucket_hdr = NULL;
@@ -4418,7 +4445,7 @@ do_undef (cppReader *pfile, struct directive *keyword, char *buf, char *limit)
 {
 
   int sym_length;
-  HASHNODE *hp;
+  hashNode hp;
   char *orig_buf = buf;
 
   SKIP_WHITE_SPACE (buf);
@@ -4643,7 +4670,7 @@ eval_if_expression (cppReader *pfile,
                    /*@unused@*/ char *buf,
                    /*@unused@*/ int length)
 {
-  HASHNODE *save_defined;
+  hashNode save_defined;
   HOST_WIDE_INT value;
   size_t old_written = cppReader_getWritten (pfile);
 
@@ -4708,7 +4735,7 @@ do_xifdef (cppReader *pfile, struct directive *keyword,
     }
   else if (token == CPP_NAME)
     {
-      HASHNODE *hp = cppReader_lookup (ident, ident_length, -1);
+      hashNode hp = cppReader_lookup (ident, ident_length, -1);
       skip = (keyword->type == T_IFDEF) 
        ? (hp == NULL) : (hp != NULL);
 
@@ -5614,7 +5641,7 @@ get_next:
        case 'Y': case 'Z':
         letter:
           {
-           HASHNODE *hp;
+           hashNode hp;
            char *ident;
            size_t before_name_written = cppReader_getWritten (pfile);
            int ident_len;
@@ -6461,7 +6488,7 @@ parseMoveMark (struct parse_marker *pmark, cppReader *pfile)
 void cppReader_initializeReader (cppReader *pfile) /* Must be done after library is loaded. */
 {
   struct cppOptions *opts = CPPOPTIONS (pfile);
-  char *xp;
+  cstring xp;
 
   /* The code looks at the defaults through this pointer, rather than through
      the constant structure above.  This pointer gets changed if an environment
@@ -6476,11 +6503,11 @@ void cppReader_initializeReader (cppReader *pfile) /* Must be done after library
      but that seems pointless: it comes before them, so it overrides them
      anyway.  */
 
-  xp = (char *) getenv ("CPATH");
+  xp = osd_getEnvironmentVariable (INCLUDEPATH_VAR);
 
-  if (xp != 0 && ! opts->no_standard_includes)
+  if (cstring_isDefined (xp) && !opts->no_standard_includes)
     {
-      path_include (pfile, xp);
+      path_include (pfile, cstring_toCharsSafe (xp));
     }
 
   /* Now that dollars_in_ident is known, initialize is_idchar.  */
@@ -6878,7 +6905,15 @@ static void cpp_setLocation (cppReader *pfile)
       
       line = cppReader_getBuffer (pfile)->lineno;
       fileloc_free (g_currentloc);
-      g_currentloc = fileloc_create (fid, line, 1);
+
+      if (fileId_isValid (fid))
+       {
+         g_currentloc = fileloc_create (fid, line, 1);
+       }
+      else
+       {
+         g_currentloc = fileloc_createBuiltin ();
+       }
     }
   else
     {
@@ -7439,13 +7474,9 @@ cpp_handleComment (cppReader *pfile, struct parse_marker *smark)
                if (start[i] == '/'
                    && i < len - 1
                    && start[i + 1] == '*') {
-                 /*@i32 make vgenopterror work in cpp... @*/
-                 if (context_getFlag (FLG_NESTCOMMENT)) 
-                   {
-                     cppReader_warning 
-                       (pfile,
-                        message ("Comment starts inside comment"));
-                   }
+                 (void) cppoptgenerror (FLG_NESTCOMMENT,
+                                        message ("Comment starts inside comment"),
+                                        pfile);
                }
                
                if (start[i] != '\n')
This page took 0.143999 seconds and 4 git commands to generate.