2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
27 ** Provide a system-independent interface to system-dependent
32 * Modified by Herbert 04/19/97:
33 * - added conditional 'OS2' to conditional 'MSDOS'
34 * - added include of new header portab.h.
35 * - changed '/' to macro.
36 * - added DOS / OS/2 specific stuff in osd_getPath.
38 * - added OS/2 specific includes before osd_getPid()
39 * - handle files like in WIN32 for OS/2 in osd_fileExists()
41 * - added OS/2 support to absolute file names
46 # include <sys/types.h>
47 # include <sys/stat.h>
48 /* Fix suggested by Lars Rasmussen */
51 /* POSIX platforms should defined getpid in unistd.h */
52 # if defined (WIN32) || (defined(OS2) && defined(__IBMC__))
55 # define getcwd _getcwd
62 # include "splintMacros.nf"
68 extern int stat (const char *, /*@out@*/ struct stat *);
71 static bool osd_executableFileExists (char *);
73 static bool nextdir (char **p_current_dir, /*@out@*/ char **p_dir,
74 /*@out@*/ size_t *p_len);
76 extern cstring LSLRootName (cstring filespec)
79 char *result, *startName, *tail;
82 llassert (cstring_isDefined (filespec));
83 tail = strrchr (filespec, CONNECTCHAR);
84 startName = (tail == NULL ? filespec : &tail[1]);
85 tail = strrchr (startName, '.');
86 nameLength = (tail == NULL ? strlen (startName)
87 : size_fromInt (tail - startName));
88 result = dmalloc (nameLength + 1);
89 strncpy (result, startName, nameLength);
90 result[(int) nameLength] = '\0';
92 /*@noaccess cstring@*/
95 extern /*@observer@*/ cstring
96 osd_getEnvironment (cstring env, /*@returned@*/ cstring def)
99 char *ret = osd_getEnvironmentVariable (env);
109 /*@noaccess cstring@*/
115 ** FUNCTIONAL DESCRIPTION:
117 ** This function attempts to locate a file in a search list. On VMS, it
118 ** just concatinates the path and file names, and then lets RMS do the
119 ** searching. On Ultrix, it searches for the file on the path.
121 ** FORMAL PARAMETERS:
123 ** path: search path where to look for the file.
124 ** file: name of file to search for.
125 ** returnPath: if a file is found, this is where the concatenated
126 ** directory and file name are returned.
130 ** OSD_FILEFOUND: the file was found on the search list.
131 ** OSD_FILENOTFOUND the file was not found.
132 ** OSD_PATHTOOLONG the concatenated directory and file name are too
141 ** Requires that parameters, path and file, are valid C strings.
147 extern /*@observer@*/ cstring osd_getHomeDir ()
149 /* Would something different be better for windows? */
150 return (osd_getEnvironmentVariable (cstring_makeLiteralTemp ("HOME")));
153 filestatus osd_findOnLarchPath (cstring file, cstring *returnPath)
155 return (osd_getPath (context_getLarchPath (), file, returnPath));
159 osd_getPath (cstring path, cstring file, cstring *returnPath)
164 char aPath[MAXPATHLEN];
165 filestatus rVal = OSD_FILENOTFOUND; /* assume file not found. */
170 llassert (cstring_isDefined (file));
172 /* 2002-01-01: make sure returnPath gets defined even when there are errors.
173 ** (fixed splint checking detected this)
176 *returnPath = cstring_undefined;
180 # if defined(OS2) || defined(MSDOS) || defined(WIN32)
181 /* under OS/2 and MSDOS the includePath may be empty, if so, search
182 * the current directory. */
184 (*file == CONNECTCHAR || (file[0] != '\0' && file[1] == ':'))
186 (*file == CONNECTCHAR)
190 /* No path specified. Look for it in the current directory. */
192 strcpy (&aPath[0], file);
194 if (osd_fileExists (&aPath[0]))
196 rVal = OSD_FILEFOUND;
197 *returnPath = dmalloc (strlen (&aPath[0]) + 1);
198 strcpy (*returnPath, &aPath[0]);
203 /* Path specified. Loop through directories in path looking for the */
204 /* first occurrence of the file. */
206 while (nextdir (&fullPath, &dirPtr, &dirLen)
207 && rVal == OSD_FILENOTFOUND)
209 if ((dirLen + strlen (file) + 2) <= MAXPATHLEN)
211 /* Cat directory and filename, and see if file exists. */
212 strncpy (&aPath[0], dirPtr, dirLen);
213 strcpy (&aPath[0] + dirLen, ""); /* Null terminate aPath. */
214 strcat (&aPath[0], CONNECTSTR);
215 strcat (&aPath[0], file);
217 if (osd_fileExists (&aPath[0]))
219 rVal = OSD_FILEFOUND;
220 *returnPath = (char *) dmalloc (strlen (&aPath[0]) + 1);
221 strcpy (*returnPath, &aPath[0]);
226 rVal = OSD_PATHTOOLONG;
232 /*@noaccess cstring@*/
236 osd_getExePath (cstring path, cstring file, cstring *returnPath)
241 char aPath[MAXPATHLEN];
242 filestatus rVal = OSD_FILENOTFOUND; /* assume file not found. */
245 *returnPath = cstring_undefined;
246 fullPath = osd_getEnvironmentVariable (path);
248 if (fullPath == NULL)
250 /* No path specified. Look for it in the current directory. */
251 llassert (cstring_isDefined (file));
252 strcpy (&aPath[0], file);
254 if (osd_fileExists (&aPath[0]))
256 rVal = OSD_FILEFOUND;
257 *returnPath = dmalloc (strlen (&aPath[0]) + 1);
258 strcpy (*returnPath, &aPath[0]);
264 ** Path specified. Loop through directories in path looking
265 ** for the first occurrence of the file.
268 while (nextdir (&fullPath, &dirPtr, &dirLen) &&
269 rVal == OSD_FILENOTFOUND)
271 llassert (cstring_isDefined (file));
273 if ((dirLen + cstring_length (file) + 2) <= MAXPATHLEN)
275 /* Cat directory and filename, and see if file exists. */
276 strncpy (&aPath[0], dirPtr, dirLen);
277 strcpy (&aPath[0] + dirLen, ""); /* Null terminate aPath. */
278 strcat (&aPath[0], CONNECTSTR);
279 strcat (&aPath[0], file);
281 if (osd_executableFileExists (&aPath[0]))
283 rVal = OSD_FILEFOUND;
284 *returnPath = dmalloc (strlen (&aPath[0]) + 1);
285 strcpy (*returnPath, &aPath[0]);
290 rVal = OSD_PATHTOOLONG;
296 /*@noaccess cstring@*/
300 osd_fileExists (cstring filespec)
304 /*@i3@*/ return (stat (cstring_toCharsSafe (filespec), &buf) == 0); /* spurious */
306 # if defined (WIN32) || defined (OS2)
307 FILE *test = fileTable_openReadFile (context_fileTable (), filespec);
311 (void) fileTable_closeFile (context_fileTable (),test);
324 # if defined(__IBMC__) && defined(OS2)
325 # define S_IFMT (unsigned short)0xFFFF
329 ** Works form Win32 at least...
334 # define S_IXUSR _S_IEXEC
339 osd_executableFileExists (/*@unused@*/ char *filespec)
341 /*@-compdestroy@*/ /* possible memory leaks here? */
344 if (stat (filespec, &buf) == 0)
346 /* mask by file type */
347 /*@-type@*/ /* confusion about __mode_t and mode_t types */
348 if ((buf.st_mode & S_IFMT) != S_IFDIR) /* not a directory */
351 /* as long as it is an executable file */
352 # if defined(__IBMC__) && defined(OS2)
353 int com_or_exe_pos = strlen( filespec) - 4;
354 return stricmp( &filespec[com_or_exe_pos], ".exe") == 0
355 || stricmp( &filespec[com_or_exe_pos], ".com") == 0
356 || stricmp( &filespec[com_or_exe_pos], ".bat") == 0
357 || stricmp( &filespec[com_or_exe_pos], ".cmd") == 0;
359 return (((buf.st_mode & S_IXUSR)
360 # if defined (S_IXGRP) && defined (S_IXOTH)
361 | (buf.st_mode & S_IXGRP) |
362 (buf.st_mode & S_IXOTH)
364 ) != 0); /* spurious */
375 ** FUNCTIONAL DESCRIPTION:
377 ** Find the next directory from a directory path.
379 ** FORMAL PARAMETERS:
381 ** char ** current_dir :
382 ** Points to the current position in the path string. The first time
383 ** you call this routine, this should point to the first character of
384 ** the path. On return, this will be updated to point to the
385 ** terminating \0 or : of the first directory found. You can then pass
386 ** it unchanged for subsequent calls; this routine will correctly skip
390 ** On exit, this will point to the first character of the directory
391 ** that was found. This will be a pointer directly into the client's
394 ** unsigned int * len :
395 ** On exit, this will contain the length of the directory that was
396 ** found, not counting any terminating \0 or :. If no directory was
397 ** found, this will be 0.
400 ** TRUE if we found another directory.
405 ** We return a pointer and length, rather than a string, because of a)
406 ** historical reasons; and b) this avoids having to allocate storage.
414 nextdir (d_char *current_dir, d_char *dir, size_t *len)
418 if (**current_dir == '\0')
425 *dir = (**current_dir == PATH_SEPARATOR ? *current_dir + 1 : *current_dir);
427 /* Find next ':' or end of string */
428 for (tchar = *dir; *tchar != '\0' && *tchar != PATH_SEPARATOR; tchar++)
433 *current_dir = tchar;
434 *len = size_fromInt (tchar - *dir);
438 /*@observer@*/ /*@null@*/ cstring osd_getEnvironmentVariable (cstring var)
440 /* evans - 2001-08-26 fixed OS instead of OS2 bug, reported by Alexander Mai */
441 # if defined(UNIX) || defined(OS2) || defined(MSDOS) || defined(WIN32)
442 char *val = getenv (cstring_toCharsSafe (var));
446 return cstring_undefined;
450 return cstring_makeLiteralTemp (val);
453 return cstring_undefined;
457 # if defined (WIN32) || defined (OS2) && defined (__IBMC__)
458 extern /*@external@*/ int _flushall (void) /*@modifies fileSystem@*/ ;
462 extern /*@external@*/ int system (const char *) /*@modifies fileSystem@*/ ;
464 int osd_system (cstring cmd)
467 /* system ("printenv"); */
468 # if defined (WIN32) || defined (OS2) && defined (__IBMC__)
472 res = system (cstring_toCharsSafe (cmd));
477 /* This should be defined by unistd.h */
479 extern /*@external@*/ int unlink (const char *) /*@modifies fileSystem@*/ ;
483 static bool s_tempError = FALSE;
485 void osd_setTempError (void)
490 int osd_unlink (cstring fname)
494 res = unlink (cstring_toCharsSafe (fname));
500 llcontbug (message ("Cannot remove temporary file: %s (%s)",
502 cstring_fromChars (strerror (errno))));
509 # if defined (WIN32) || defined (OS2) && defined (__IBMC__)
516 # if defined (WIN32) || defined (OS2) && defined (__IBMC__)
517 int pid = _getpid ();
519 __pid_t pid = getpid ();
525 cstring osd_fixDefine (cstring x)
528 llassert (cstring_isDefined (x));
530 if (strchr (x, '\'') != NULL) {
532 ** If there is a single quote, check for <ident>='<string>' and
533 ** produce <ident>=<string>
536 char *eqs = strchr (x, '=');
539 if (eqs[1] == '\'') {
540 char *endqu = strrchr (x, '\'');
543 if (*(endqu - 1) != '\\') {
544 if (*(endqu + 1) == '\0') {
549 def = cstring_fromChars (eqs + 2);
551 res = cstring_concat (cstring_fromChars (x), def);
562 return cstring_copy (x);
563 /*@noaccess cstring@*/
566 bool osd_fileIsReadable (cstring f)
568 FILE *fl = fileTable_openReadFile (context_fileTable (), f);
572 check (fileTable_closeFile (context_fileTable (), fl));
581 bool osd_isConnectChar (char c)
583 if (c == CONNECTCHAR)
588 # ifdef HASALTCONNECTCHAR
589 if (c == ALTCONNECTCHAR)
599 ** Returns true if c2 starts with the same path as c1
601 ** This is called by context_isSystemDir to determine if a
602 ** directory is on the system path.
604 ** In unix, this is just a string comparison. For Win32 and OS2, we need a more
605 ** complex comparison.
608 bool osd_equalCanonicalPrefix (cstring dirpath, cstring prefixpath)
610 llassert (cstring_isDefined (prefixpath));
612 if (cstring_isEmpty (dirpath))
614 return (cstring_isEmpty (prefixpath));
617 # if defined (WIN32) || defined (OS2)
619 /*@access cstring@*/ /* Moved this from cstring - should abstract it... */
622 ** If one has a drive specification, but the other doesn't, skip it.
625 if (strchr (dirpath, ':') == NULL
626 && strchr (prefixpath, ':') != NULL)
628 prefixpath = strchr (prefixpath, ':') + 1;
632 if (strchr (prefixpath, ':') == NULL
633 && strchr (dirpath, ':') != NULL)
635 dirpath = strchr (dirpath, ':') + 1;
640 int len = size_toInt (strlen (prefixpath));
644 for (i = 0, slen = 0; i < len; i++, slen++)
646 /* Allow any number of connect characters in any combination:
647 * c:/usr//src\/foo == c:\\usr/src\/foo
648 * After this we'll be at the last of such a sequence */
650 if (osd_isConnectChar (dirpath[slen]) && osd_isConnectChar (prefixpath[i]))
652 /* Skip one or more connect chars */
654 for (; osd_isConnectChar (dirpath[slen+1]); ++slen)
659 for (; osd_isConnectChar (prefixpath[i+1]); ++i)
664 /* Windows, MSDOS and OS/2 use case-insensitive path specs! */
665 else if (toupper (dirpath[slen]) != toupper (prefixpath[i]))
673 /*@noaccess cstring@*/
677 return (cstring_equalPrefix (dirpath, prefixpath));
683 ** This code provided by Herbert Martin Dietze, to canonicalize path names.
686 char *osd_getcwd (/*@returned@*/ char *str, size_t size)
688 return getcwd (str, size);
691 /*@null@*/ /*@observer@*/ char *
692 osd_dirNext (char *str)
694 char *p1 = strchr (str, '/');
695 char *p2 = strchr (str, '\\');
712 else /* both not null */
714 return (p1 < p2 ? p1 : p2) + 1;
719 osd_dirShift (char *str, size_t num) /*@modifies str@*/
723 assert (num <= strlen (str));
725 for (i = 0; str[i] != '\0'; i++)
727 str[i] = str[i + num];
732 osd_dirDotdot (char *str)
734 return str[0] == '.' && str[1] == '.' && osd_isConnectChar (str[2]);
738 osd_dirNormalize (char *str)
742 for (; osd_isConnectChar (str[0]); str++)
746 for (; str != NULL && osd_dirDotdot (str); str = osd_dirNext (str))
750 for (pos1 = pos2 = str;
752 pos2 = pos1, pos1 = osd_dirNext (pos1))
754 /* remove redundant `./' entry */
755 while (pos1[0] == '.' && osd_isConnectChar (pos1[1]))
757 osd_dirShift (pos1, 2);
760 /* remove redundant `foo/../' entry */
761 if (osd_dirDotdot (pos1) && pos2 < pos1)
763 osd_dirShift (pos2, pos1 - pos2 + 1);
764 osd_dirNormalize (str);
770 osd_dirAbsolute (char *str)
773 size_t size = PATH_MAX * sizeof (*ret);
775 DPRINTF (("Absolute for: %s", str));
777 # if defined (WIN32) || defined (OS2) || defined (MSDOS)
778 if (strlen (str) > 1 && str[1] == ':')
781 ** Its a drive letter
784 ret = dmalloc ((strlen (str) + 1) * sizeof (*ret));
789 if (osd_isConnectChar (str[0]))
791 ret = dmalloc ((strlen (str) + 1) * sizeof (*ret));
796 ret = dmalloc (size);
798 ret = osd_getcwd (ret, size);
799 ret = realloc (ret, (strlen (str) + strlen (ret) + 2) * sizeof (*ret));
806 strcat (ret, CONNECTSTR);
810 osd_dirNormalize (ret);
819 ** This code is adapted from:
821 ** http://src.openresources.com/debian/src/devel/HTML/S/altgcc_2.7.2.2.orig%20altgcc-2.7.2.2.orig%20protoize.c.html#1297
824 ** Protoize program - Original version by Ron Guilmette (rfg@segfault.us.com).
825 ** Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
827 ** This file is part of GNU CC.
829 ** GNU CC is free software; you can redistribute it and/or modify
830 ** it under the terms of the GNU General Public License as published by
831 ** the Free Software Foundation; either version 2, or (at your option)
832 ** any later version.
834 ** GNU CC is distributed in the hope that it will be useful,
835 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
836 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
837 ** GNU General Public License for more details.
839 ** You should have received a copy of the GNU General Public License
840 ** along with GNU CC; see the file COPYING. If not, write to
841 ** the Free Software Foundation, 59 Temple Place - Suite 330,
842 ** Boston, MA 02111-1307, USA.
846 ** Return the absolutized filename for the given relative
847 ** filename. Note that if that filename is already absolute, it may
848 ** still be returned in a modified form because this routine also
849 ** eliminates redundant slashes and single dots and eliminates double
850 ** dots to get a shortest possible filename from the given input
851 ** filename. The absolutization of relative filenames is made by
852 ** assuming that the given filename is to be taken as relative to
853 ** the first argument (cwd) or to the current directory if cwd is
857 /* A pointer to the current directory filename (used by abspath). */
858 static /*@only@*/ cstring osd_cwd = cstring_undefined;
860 static void osd_setWorkingDirectory (void)
862 # if defined (UNIX) || defined (OS2)
863 char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN);
864 char *cwd = getcwd (buf, MAXPATHLEN);
866 llassert (cstring_isUndefined (osd_cwd));
870 lldiagmsg (message ("Cannot get working directory: %s\n",
871 lldecodeerror (errno)));
872 osd_cwd = cstring_makeLiteral ("<missing directory>");
876 osd_cwd = cstring_fromCharsNew (cwd);
881 ; /* Don't know how to do this for non-POSIX platforms */
885 void osd_initMod (void)
887 osd_setWorkingDirectory ();
890 void osd_destroyMod (void)
892 cstring_free (osd_cwd);
893 osd_cwd = cstring_undefined;
896 cstring osd_absolutePath (cstring cwd, cstring filename)
898 # if defined (UNIX) || defined (OS2)
899 /* Setup the current working directory as needed. */
900 cstring cwd2 = cstring_isDefined (cwd) ? cwd : osd_cwd;
902 char *endp, *outp, *inp;
905 llassert (cstring_isDefined (cwd2));
906 llassert (cstring_isDefined (filename));
908 abs_buffer = (char *) dmalloc (cstring_length (cwd2) + cstring_length (filename) + 2);
912 ** Copy the filename (possibly preceded by the current working
913 ** directory name) into the absolutization buffer.
919 if (!osd_isConnectChar (filename[0])
921 && !(isalpha (filename[0]) && filename[1] == ':')
927 while ((*endp++ = *src_p++) != '\0')
932 *(endp-1) = CONNECTCHAR; /* overwrite null */
937 while ((*endp++ = *src_p++) != '\0')
943 /* Now make a copy of abs_buffer into abs_buffer, shortening the
944 filename (by taking out slashes and dots) as we go. */
946 outp = inp = abs_buffer;
947 *outp++ = *inp++; /* copy first slash */
950 *outp++ = *inp++; /* copy second slash */
958 else if (osd_isConnectChar (inp[0]) && osd_isConnectChar (outp[-1]))
963 else if (inp[0] == '.' && osd_isConnectChar (outp[-1]))
969 else if (osd_isConnectChar (inp[1]))
974 else if ((inp[1] == '.')
975 && (inp[2] == '\0' || osd_isConnectChar (inp[2])))
977 inp += (osd_isConnectChar (inp[2])) ? 3 : 2;
980 while (outp >= abs_buffer && !osd_isConnectChar (*outp))
985 if (outp < abs_buffer)
987 /* Catch cases like /.. where we try to backup to a
988 point above the absolute root of the logical file
991 llfatalbug (message ("Invalid file name: %s", filename));
1010 /* On exit, make sure that there is a trailing null, and make sure that
1011 the last character of the returned string is *not* a slash. */
1014 if (osd_isConnectChar (outp[-1]))
1017 /*@noaccess cstring@*/
1018 return cstring_fromChars (abs_buffer);
1020 DPRINTF (("Here: %s", filename));
1021 return cstring_copy (filename);
1026 ** Given a filename (and possibly a directory name from which the filename
1027 ** is relative) return a string which is the shortest possible
1028 ** equivalent for the corresponding full (absolutized) filename. The
1029 ** shortest possible equivalent may be constructed by converting the
1030 ** absolutized filename to be a relative filename (i.e. relative to
1031 ** the actual current working directory). However if a relative filename
1032 ** is longer, then the full absolute filename is returned.
1034 ** KNOWN BUG: subpart of the original filename is actually a symbolic link.
1036 ** this is really horrible code...surely someone has written a less buggy version of this!
1039 cstring osd_outputPath (cstring filename)
1041 # if defined (UNIX) || defined (OS2)
1044 cstring cwd_p = osd_cwd;
1046 int unmatched_slash_count = 0;
1047 size_t filename_len = cstring_length (filename);
1049 llassertretval (filename_len > 0, filename);
1051 /*@access cstring@*/
1053 rel_buffer = (char *) dmalloc (filename_len);
1054 rel_buf_p = rel_buffer;
1059 /* Need to prevent recursive assertion failures */
1060 return cstring_copy (filename);
1063 llassert (cwd_p != NULL);
1064 llassert (path_p != NULL);
1066 while ((*cwd_p != '\0') && (*cwd_p == *path_p))
1072 if ((*cwd_p == '\0') && (*path_p == '\0' || osd_isConnectChar (*path_p))) /* whole pwd matched */
1074 if (*path_p == '\0') /* input *is* the current path! */
1076 cstring_free (rel_buffer);
1077 return cstring_makeLiteral (".");
1081 cstring_free (rel_buffer);
1082 return cstring_fromCharsNew (path_p + 1);
1088 /* drl 2002-10/14 I had to put this code back*/
1089 /* 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
1092 /* evans 2002-02-05 This is horrible code, which I've removed. I couldn't find any
1093 ** test cases that need it, so I hope I'm not breaking anything.
1097 if (*path_p != '\0')
1102 while (cwd_p >= osd_cwd && !osd_isConnectChar (*cwd_p)) /* backup to last slash */
1109 unmatched_slash_count++;
1112 /* Find out how many directory levels in cwd were *not* matched. */
1113 while (*cwd_p != '\0')
1115 if (osd_isConnectChar (*cwd_p++))
1116 unmatched_slash_count++;
1119 /* Now we know how long the "short name" will be.
1120 Reject it if longer than the input. */
1121 if (unmatched_slash_count * 3 + strlen (path_p) >= filename_len)
1123 cstring_free (rel_buffer);
1124 /* fprintf (stderr, "Returning filename: %s [%p]\n", filename); */
1125 return cstring_copy (filename);
1128 /*drl 10-14-2002 end previously removed code */
1130 /* For each of them, put a `../' at the beginning of the short name. */
1131 while (unmatched_slash_count-- > 0)
1133 /* Give up if the result gets to be longer
1134 than the absolute path name. */
1135 char * temp_rel_buf_p;
1137 /*drl This comment is necessary because for some reason Splint
1138 does not realize that the pasts where rel_buf_p is released
1141 temp_rel_buf_p = rel_buf_p;
1144 if (rel_buffer + filename_len <= temp_rel_buf_p + 3)
1147 return cstring_copy (filename);
1152 *rel_buf_p++ = CONNECTCHAR;
1155 /* Then tack on the unmatched part of the desired file's name. */
1159 if (rel_buffer + filename_len <= rel_buf_p)
1161 cstring_free (rel_buffer);
1162 return cstring_copy (filename);
1164 } /*@-usereleased@*/
1165 while ((*rel_buf_p++ = *path_p++) != '\0') ;
1168 /*@=usereleased@*/ /* Splint limitation: shouldn't need these */
1171 if (osd_isConnectChar (*(rel_buf_p-1)))
1172 *--rel_buf_p = '\0';
1174 /* fprintf (stderr, "Returning buffer: %s [%p]\n", rel_buffer, rel_buffer); */
1177 /*@noaccess cstring@*/
1179 return cstring_copy (filename);
1183 cstring osd_getCurrentDirectory ()
1185 # if defined(MSDOS) || defined(OS2)
1186 return cstring_makeLiteralTemp ("");
1188 return cstring_makeLiteralTemp ("./");