]> andersk Git - splint.git/blobdiff - src/osd.c
Making fixes for Microsoft Visual C++ compiler.
[splint.git] / src / osd.c
index 938db1332f91f0849031e0341a85069ffe506c17..b429d3f30b37c0785df7c81c5dec6a9c0730ef46 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -62,7 +62,6 @@
 # include "splintMacros.nf"
 # include "basic.h"
 # include "osd.h"
-# include "portab.h"
 
 /* from stat.h */
 /*@ignore@*/
@@ -479,7 +478,7 @@ extern /*@external@*/ int unlink (const char *) /*@modifies fileSystem@*/ ;
 /*@=redecl@*/
 # endif
 
-static s_tempError = FALSE;
+static bool s_tempError = FALSE;
 
 void osd_setTempError (void)
 {
@@ -868,6 +867,7 @@ static void osd_setWorkingDirectory (void)
     {
       lldiagmsg (message ("Cannot get working directory: %s\n",
                          lldecodeerror (errno)));
+      osd_cwd = cstring_makeLiteral ("<missing directory>");
     }
   else
     {
@@ -903,7 +903,7 @@ cstring osd_absolutePath (cstring cwd, cstring filename)
   llassert (cstring_isDefined (cwd2));
   llassert (cstring_isDefined (filename));
 
-  abs_buffer = (char *) dmalloc (size_fromInt (cstring_length (cwd2) + cstring_length (filename) + 2));
+  abs_buffer = (char *) dmalloc (cstring_length (cwd2) + cstring_length (filename) + 2);
   endp = abs_buffer;
   
   /*
@@ -1036,7 +1036,6 @@ cstring osd_absolutePath (cstring cwd, cstring filename)
 
 cstring osd_outputPath (cstring filename)
 {
-  /*@i2534 fix this junky code once and for all! */
 # if defined (UNIX) || defined (OS2)
   char *rel_buffer;
   char *rel_buf_p;
@@ -1053,6 +1052,12 @@ cstring osd_outputPath (cstring filename)
   rel_buf_p = rel_buffer;
   *rel_buf_p = '\0';
 
+  if (cwd_p == NULL) 
+    {
+      /* Need to prevent recursive assertion failures */
+      return cstring_copy (filename);
+    }
+
   llassert (cwd_p != NULL);
   llassert (path_p != NULL);
 
@@ -1071,18 +1076,22 @@ cstring osd_outputPath (cstring filename)
        }
       else
        {
-         /*@i324 ! splint didn't report an errors for: return ++path_p; */
          cstring_free (rel_buffer);
          return cstring_fromCharsNew (path_p + 1);
        }
     }
   else
     {
+
+      /* drl   2002-10/14 I had to put this code back*/
+      /* the case that needs it is when splint is given an absolute path name of a file outside of the current directory and the subdirectories below the current directory. e.g. cd /home/; splint /tmp/prog.c
+       */
+      
       /* evans 2002-02-05 This is horrible code, which I've removed.  I couldn't find any
       ** test cases that need it, so I hope I'm not breaking anything.
       */
+      /*#if 0*/
 
-# if 0      
       if (*path_p != '\0')
         {
           --cwd_p;
@@ -1100,7 +1109,7 @@ cstring osd_outputPath (cstring filename)
 
       /* Find out how many directory levels in cwd were *not* matched.  */
       while (*cwd_p != '\0')
-       {s
+       {
          if (osd_isConnectChar (*cwd_p++))
            unmatched_slash_count++;
        }
@@ -1113,14 +1122,24 @@ cstring osd_outputPath (cstring filename)
          /* fprintf (stderr, "Returning filename: %s [%p]\n", filename); */
          return cstring_copy (filename);
        }
-# endif
-      
+
+      /*drl 10-14-2002 end previously removed code */
+      /*#endif*/
       /* For each of them, put a `../' at the beginning of the short name.  */
       while (unmatched_slash_count-- > 0)
         {
           /* Give up if the result gets to be longer
              than the absolute path name.  */
-          if (rel_buffer + filename_len <= rel_buf_p + 3)
+         char * temp_rel_buf_p;
+
+         /*drl This comment is necessary because for some reason Splint
+           does not realize that the pasts where rel_buf_p is released
+           do not reach here*/
+         /*@-usereleased@*/
+         temp_rel_buf_p = rel_buf_p;
+         /*@-usereleased@*/
+         
+          if (rel_buffer + filename_len <= temp_rel_buf_p + 3)
            {
              sfree (rel_buffer);
              return cstring_copy (filename);
@@ -1144,7 +1163,7 @@ cstring osd_outputPath (cstring filename)
       while ((*rel_buf_p++ = *path_p++) != '\0') ;
 
       
-      /*@=usereleased@*/ /*@i523! shouldn't need these */
+      /*@=usereleased@*/ /* Splint limitation: shouldn't need these */
       --rel_buf_p;
 
       if (osd_isConnectChar (*(rel_buf_p-1)))
This page took 0.117917 seconds and 4 git commands to generate.