]> andersk Git - splint.git/blobdiff - src/fileloc.c
Added splint.spec file contributed by Heiko Abraham
[splint.git] / src / fileloc.c
index de7b4aa6499c4d99932ef274fe28769309b4d2c3..729c633debbf41413e101988bca191d1ab16724b 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
@@ -33,7 +33,7 @@
  *   instead of fileloc_unparseFilename().
  */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 # include "fileIdList.h"
 # include "osd.h"
@@ -43,7 +43,7 @@ static /*@only@*/ fileloc fileloc_createPrim (flkind p_kind, fileId p_fid, int p
 
 static flkind fileId_kind (fileId s)
 {
-  cstring fname = rootFileName (s);
+  cstring fname = fileTable_rootFileName (s);
   
   if (fileLib_isLCLFile (fname))
     {
@@ -64,6 +64,8 @@ fileloc_decColumn (fileloc f, int x)
 {
   fileloc ret = fileloc_copy (f);
 
+  llassert (x >= 0);
+
   if (x > 0 && fileloc_isDefined (ret))
     {
       llassertprint (ret->column > x, ("decColumn: %d", x));
@@ -211,7 +213,7 @@ cstring fileloc_getBase (fileloc f)
 {
   llassert (fileloc_isDefined (f));
 
-  return (fileNameBase (f->fid));
+  return (fileTable_fileNameBase (f->fid));
 }
 
 bool
@@ -350,7 +352,7 @@ fileloc_sameModule (fileloc f1, fileloc f2)
          cstring s1 = fileloc_getBase (f1);
          cstring s2 = fileloc_getBase (f2);
          
-         return (cstring_equal (s1, s2));
+         return (cstring_equal (s1, s2)); 
        }
     }
 }
@@ -591,14 +593,14 @@ fileloc fileloc_create (fileId fid, int line, int col)
 /*@observer@*/ cstring
 fileloc_filename (fileloc f)
 {
-  return (fileloc_isDefined (f) ? rootFileName (f->fid) : cstring_makeLiteralTemp ("<unknown>"));
+  return (fileloc_isDefined (f) ? fileTable_rootFileName (f->fid) : cstring_makeLiteralTemp ("<unknown>"));
 }
 
 /*@only@*/ cstring fileloc_outputFilename (fileloc f)
 {
   if (fileloc_isDefined (f))
     {
-      return osd_outputPath (rootFileName (f->fid));
+      return osd_outputPath (fileTable_rootFileName (f->fid));
     }
   else
     {
@@ -644,6 +646,8 @@ fileloc_column (fileloc f)
 fileloc_unparse (fileloc f)
 {
   bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
+  bool htmlFormat = context_getFlag (FLG_HTMLFILEFORMAT);
+  cstring res = cstring_undefined;
 
   if (fileloc_isDefined (f))
     {
@@ -654,23 +658,29 @@ fileloc_unparse (fileloc f)
        case FL_IMPORT:
          if (parenFormat)
            {
-             return (message ("import file %q(%d)", fileloc_outputFilename (f), f->lineno));
+             res = message ("import file %q(%d)", fileloc_outputFilename (f), f->lineno);
            }
          else
            {
-             return (message ("import file %q:%d", fileloc_outputFilename (f), f->lineno));
+             res = message ("import file %q:%d", fileloc_outputFilename (f), f->lineno);
            }
+         break;
        case FL_PREPROC:
-         if (parenFormat)
-           {
-             return (message ("%q(%d)", fileloc_outputFilename (f), f->lineno));
-           }
-         else
-           {
-             return (message ("%q:%d", fileloc_outputFilename (f), f->lineno));
-           }
+         {
+           if (parenFormat)
+             {
+               res = message ("%q(%d)", fileloc_outputFilename (f), f->lineno);
+             }
+           else
+             {
+               res = message ("%q:%d", fileloc_outputFilename (f), f->lineno);
+             }
+           
+           break;
+         }
        case FL_EXTERNAL:
-         return (cstring_makeLiteral ("<external>"));
+         res = cstring_makeLiteral ("<external>");
+         break;
        default:
          {
            cstring fname;
@@ -692,84 +702,109 @@ fileloc_unparse (fileloc f)
                      {
                        if (parenFormat)
                          {
-                           return (message ("%q(%d,%d)", fname, f->lineno, f->column));
+                           res = message ("%q(%d,%d)", fname, f->lineno, f->column);
                          }
                        else
                          {
-                           return (message ("%q:%d:%d", fname, f->lineno, f->column));
+                           res = message ("%q:%d:%d", fname, f->lineno, f->column);
                          }
                      }
                    else
                      {
                        if (parenFormat)
                          {
-                           return (message ("%q(%d)", fname, f->lineno));
+                           res = message ("%q(%d)", fname, f->lineno);
                          }
                        else
                          {
-                           return (message ("%q:%d", fname, f->lineno));
+                           res = message ("%q:%d", fname, f->lineno);
                          }
                      }
                  }
-               
-               return fname;
+               else
+                 {
+                   res = fname;
+                 }
              }
            else if (fileloc_linenoDefined (f))
              {
                if (parenFormat)
                  {
-                   return (message ("%q(%d)", fname, f->lineno));
+                   res = message ("%q(%d)", fname, f->lineno);
                  }
                else
                  {
-                   return (message ("%q:%d", fname, f->lineno));
+                   res = message ("%q:%d", fname, f->lineno);
                  }
              }
            else
              {
-               return fname;
+               res = fname;
              }
          }
        }
-    }
 
-  return (cstring_makeLiteral ("< Location unknown >"));
+       if (htmlFormat && fileloc_linenoDefined (f))
+        {
+          res = message ("<a href=\"#line%d\">%s</a>", f->lineno, res);
+        }
+    }
+  else
+    {
+      res = cstring_makeLiteral ("< Location unknown >");
+    }
+  
+  return res;
 }
 
 /*@only@*/ cstring
 fileloc_unparseRaw (cstring fname, int lineno)
 {
-  bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
-
-  if (parenFormat)
+  if (!cstring_isEmpty (fname))
     {
-      return (message ("%q(%d)", osd_outputPath (fname), lineno));
+      bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
+      
+      if (parenFormat)
+       {
+         return (message ("%q(%d)", osd_outputPath (fname), lineno));
+       }
+      else
+       {
+         return (message ("%q:%d", osd_outputPath (fname), lineno));
+       }
     }
   else
     {
-      return (message ("%q:%d", osd_outputPath (fname), lineno));
+      return cstring_makeLiteral ("Command Line");
     }
 }
 
 /*@only@*/ cstring
 fileloc_unparseRawCol (cstring fname, int lineno, int col)
 {
-  if (context_getFlag (FLG_SHOWCOL)) 
+  if (!cstring_isEmpty (fname))
     {
-      bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
-      
-      if (parenFormat)
+      if (context_getFlag (FLG_SHOWCOL)) 
        {
-         return (message ("%q(%d,%d)", osd_outputPath (fname), lineno, col));
+         bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
+         
+         if (parenFormat)
+           {
+             return (message ("%q(%d,%d)", osd_outputPath (fname), lineno, col));
+           }
+         else
+           {
+             return (message ("%q:%d:%d", osd_outputPath (fname), lineno, col));
+           }
        }
       else
        {
-         return (message ("%q:%d:%d", osd_outputPath (fname), lineno, col));
+         return fileloc_unparseRaw (fname, lineno);
        }
     }
   else
     {
-      return fileloc_unparseRaw (fname, lineno);
+      return cstring_makeLiteral ("Command Line");
     }
 }
 
This page took 0.1356 seconds and 4 git commands to generate.