2007-02-19 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* src/context.c (context_resetAllFlags) [MSDOS, OS2, WIN32]: Replace
	conditionals MSDOS, OS2 and WIN32 with HAVE_DOS_FILE_SYSTEM defined
	in Headers/osd.h to select the code that reads "TMP" and "TEMP" from
	the environment.
	[HAVE_DOS_FILE_SYSTEM, __DJGPP__]: If TEMP and TMP are not set check
	for TMPDIR too.
	[HAVE_DOS_FILE_SYSTEM]: If TEMP, TMP or TMPDIR points to a directory
	check that it exist before using it, else default to DEFAULT_TMPDIR.
	(context_isSpecialFile): Use the OS dependent macro LEX_YY_C defined
	in Headers/osd.h instead of the hard coded string "lex.yy.c".

	* src/cpplib.c (cpplib_initializeReader): Replace "/include" with the
	OS dependent CONNECTSTR"include" in the check of default_prefix.
	(do_include) [WIN32, OS2]: Replace conditionals OS2 and WIN32 with
	HAVE_DOS_FILE_SYSTEM defined in Headers/osd.h to enable the checking
	for absolute paths with DOS syntax and use HAVE_DRIVE_SPECIFIER for
	checking.
	(do_include) [WIN32, OS2]: Replace conditionals OS2 and WIN32 with
	HAVE_DOS_FILE_SYSTEM defined in Headers/osd.h to enable the replacing
	of slashes to backslashes but instead of hard coding the replacement
	chars, ALTCONNECTCHAR and CONNECTCHAR are used.  ALTCONNECTCHAR will
	be replaced by CONNECTCHAR.
	(initialize_builtins): If UNAME is set to MS-DOS then add MSDOS family
	of preprocessor symbols to the universal symbol table.

	* src/cppmain.c (cppProcess): Remove double initialization of variable
	opts->out_fname.

	* src/cscannerHelp.c (cscannerHelp_handleSpecial) [MSDOS, OS2, WIN32]:
	Replace conditionals MSDOS, OS2 and WIN32 with HAVE_DOS_FILE_SYSTEM
	defined in Headers/osd.h to select code that removes multiples connect
	chars in the path string.
	Also change the used logic to allow for the use of alternate connect
	chars.

	* src/Headers/constants.h: [MSDOS]: Add definition for macro ALTRCFILE.
	[MSDOS]: Define LLSTRICTLIBS_NAME to "stdstrict" instead of
	"standardstrict" because the later maps to "standard" on a file system
	with 8.3 filename restriction.
	[DEFAULT_SYSTEMDIR]: For DJGPP set DEFAULT_SYSTEMDIR to /dev/env/DJDIR,
	the root of the installation tree.

	* src/Headers/osd.h: Define a new conditional section for DJGPP.
	[__DJGPP__]: The value of the conditionals ALTCONNECTCHAR and
	CONNECTCHAR is reversed compared with the definition of this values
	for MSDOS.
	[MSDOS, OS2, WIN32]: Remove the definition of the conditional
	HASALTCONNECTCHAR from inside the OS specific definition sections and
	define it if ALTCONNECTCHAR has been defined.
	[MSDOS, OS2, WIN32]: Define new macros HAVE_DOS_FILE_SYSTEM,
	HAVE_DRIVE_SPECIFIER and IS_DOS_STYLE_ABS_PATH.
	[VMS, __DJGPP__, MSDOS, OS2, WIN32]: New macro LEX_YY_C defined.  In
	the case of DJGPP, pathconf() is used to determinate if "lex.yy.c" or
	"lexyy.c" shall be used depending on if LFN support is available or
	not.  For all other supported OS/ports the default value is set to
	"lex.yy.c".

	* src/filelib.c (fileLib_getExtension): Extract basename from filename
	before searching for an extension.
	(fileLib_removeAnyExtension): Extract basename from filename before
	searching for an extension.
	(removePreDirs) [MSDOS, OS2]: Replace conditionals MSDOS and OS2 with
	HAVE_DOS_FILE_SYSTEM defined in Headers/osd.h.  If HASALTCONNECTCHAR is
	defined check also for ALTCONNECTCHAR in the path string.
	Check also for the existance of remainders from double path delimiters
	before trying to remove them.

	* src/osd.c (osd_getPid) [__DJGPP__]: Use pid_t as return type.
	(osd_getPath): Use HAVE_DOS_FILE_SYSTEM conditional defined in
	Headers/osd.h instead of MSDOS, OS2 and WIN32.
	(osd_getPath) [HAVE_DOS_FILE_SYSTEM]: Check for ALTCONNECTCHAR too.
	(osd_fileExists): Replace conditionals OS2 and WIN32 with
	HAVE_DOS_FILE_SYSTEM defined in Headers/osd.h.
	(osd_setWorkingDirectory) [OS2]: Fix wrong preprocessor command.
	(osd_absolutePath) [OS2]: Replace OS2 with HAVE_DOS_FILE_SYSTEM defined
	in Headers/osd.h when checking for absolute path.
	(osd_absolutePath) [HAVE_DOS_FILE_SYSTEM]: Fix the broken logic to
	check if the given path is relative or absolute and insert the cwd
	string into the path string if and only if both make reference to
	the same partition.
	(osd_getCurrentDirectory): Use HAVE_DOS_FILE_SYSTEM conditionaldefined
	in Headers/osd.h instead of MSDOS, OS2 and WIN32.

	* test/Makefile.in (rc): If compiling DJGPP port use rc3.splintrc.djgpp
	and rc3.expect.djgpp when running the rc test cases.

	* test/db1 (test): Use @ in the command of test target.

	* test/db2 (test): Use @ in the command of test target.

	* test/rc3.expect.djgpp: New file.  Reflect the output produced by
	the DJGPP port when running the rc testcase.

	* test/rc3.splintrc.djgpp: New file.  Use /dev/env/TMPDIR/ instead of
	unix centric /tmp/

	* test/tests2.4/Makefile (driverstub): If compiling DJGPP port use
	/dev/env/DJDIR/ instead of unix centric /usr/ as value for sysdirs
	when running the driverstub test case.


diff -aprNU5 splint-3.1.2.orig/src/Headers/constants.h splint-3.1.2/src/Headers/constants.h
--- splint-3.1.2.orig/src/Headers/constants.h	2004-07-31 19:04:28 +0000
+++ splint-3.1.2/src/Headers/constants.h	2008-02-19 22:09:44 +0000
@@ -9,18 +9,26 @@
 
 /*
  * This is constants.h from Mike Smith's Win32 port of splint.
  * Modified by Herbert 04/19/97:
  * added conditional 'OS2' to conditional 'MSDOS'
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * -added definition of 'ALTRCFILE' for MSDOS
+ * -for MSDOS define 'LLSTRICTLIBS_NAME' to 'stdstrict' because 'standardstrict'
+ *  maps to 'standard' on a file system with 8.3 filename restriction.
+ * -added conditional section for DJGPP to define macro 'DEFAULT_SYSTEMDIR'
  */
 
 # ifndef CONSTANTS_H
 # define CONSTANTS_H
 
 # if defined(MSDOS) 
 /*@constant observer char *RCFILE; @*/
 # define RCFILE         "splint.rc"
+
+/*@constant observer char *ALTRCFILE; @*/
+# define ALTRCFILE      "lclint.rc"
 # else
 /*@constant observer char *RCFILE; @*/
 # define RCFILE         ".splintrc"
 
 /*@constant observer char *ALTRCFILE; @*/
@@ -34,12 +42,17 @@
 # define LCLIMPORTDIR           "LCLIMPORTDIR"
 
 /*@constant observer char *LLSTDLIBS_NAME; @*/
 # define LLSTDLIBS_NAME          "standard"
 
+# if defined(MSDOS)
+/*@constant observer char *LLSTRICTLIBS_NAME; @*/
+# define LLSTRICTLIBS_NAME      "stdstrict"
+# else
 /*@constant observer char *LLSTRICTLIBS_NAME; @*/
 # define LLSTRICTLIBS_NAME      "standardstrict"
+# endif
 
 /*@constant observer char *LLUNIXLIBS_NAME; @*/
 # define LLUNIXLIBS_NAME        "unix"
 
 /*@constant observer char *LLUNIXSTRICTLIBS_NAME; @*/
@@ -97,10 +110,13 @@
 # define PPMRCODE "@@MR@@"  
 
 # ifdef OS2
 /*@constant observer char *DEFAULT_SYSTEMDIR; @*/
 # define DEFAULT_SYSTEMDIR "/os2/"
+# elif defined (__DJGPP__)
+/*@constant observer char *DEFAULT_SYSTEMDIR; @*/
+# define DEFAULT_SYSTEMDIR "/dev/env/DJDIR/"
 # else                            
 /*@constant observer char *DEFAULT_SYSTEMDIR; @*/
 # define DEFAULT_SYSTEMDIR "/usr/"
 # endif
 
diff -aprNU5 splint-3.1.2.orig/src/Headers/osd.h splint-3.1.2/src/Headers/osd.h
--- splint-3.1.2.orig/src/Headers/osd.h	2003-04-22 01:25:50 +0000
+++ splint-3.1.2/src/Headers/osd.h	2008-02-19 22:10:34 +0000
@@ -4,10 +4,25 @@
 **
 */
 /*
 ** osd.h
 */
+/*
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * - a new conditional section for DJGPP has been defined to revert
+ *   the values of CONNECTCHAR and ALTCONNECTCHAR compared with the
+ *   definition of this values for MSDOS.
+ * - remove the definition of the conditional HASALTCONNECTCHAR from
+ *   inside the OS specific definition sections and define it if
+ *   ALTCONNECTCHAR has been defined.
+ * - added new conditionals 'HAVE_DOS_FILE_SYSTEM', 'HAVE_DRIVE_SPECIFIER'
+ *   and 'IS_DOS_STYLE_ABS_PATH' if MSDOS or OS2 or WIN32 are defined.
+ * - new macro LEX_YY_C defined.  In the case of the DJGPP port, pathconf()
+ *   is used to determinate if "lex.yy.c" or "lexyy.c" shall be used depending
+ *   if LFN support is available or not.  For all other supported OS/ports the
+ *   default value "lex.yy.c" is set.
+ */
 
 # ifndef OSD_H
 # define OSD_H
 
 /* Macro to substitute for ## because VAX C currently doesn't allow it. */
@@ -140,10 +155,39 @@ extern int /*pid_t*/ osd_getPid (void) ;
 
 /* Directory separator character for search list. */
 /*@constant static char PATH_SEPARATOR; @*/
 # define PATH_SEPARATOR ':'
 
+/*@constant observer char *LEX_YY_C; @*/
+# define LEX_YY_C	"lex.yy.c"
+
+# elif defined(__DJGPP__)
+
+/* Although DJGPP is a DOS compiler environment, slashes are prefered  */
+/* over backslashes as directory separator character.                  */
+/* Connection string inserted between directory and filename to make   */
+/* full path name.                                                     */
+
+/*@constant observer char *CONNECTSTR@*/
+# define CONNECTSTR	"/"
+
+/*@constant char CONNECTCHAR@*/
+# define CONNECTCHAR	'/'
+
+/*@constant char ALTCONNECTCHAR@*/
+# define ALTCONNECTCHAR	'\\'
+
+/* Directory separator character for search list. */
+
+/*@constant char PATH_SEPARATOR; @*/
+# define PATH_SEPARATOR ';'
+
+# include <unistd.h>
+
+/*@constant observer char *LEX_YY_C; @*/
+# define LEX_YY_C	((pathconf(NULL, _PC_NAME_MAX) > 12) ? "lex.yy.c" : "lexyy.c")
+
 # elif defined(MSDOS) || defined(OS2) || defined(WIN32)
 
 /* Connection string inserted between directory and filename to make a  */
 /* full path name.							*/
 
@@ -151,20 +195,21 @@ extern int /*pid_t*/ osd_getPid (void) ;
 # define CONNECTSTR	"\\"
 
 /*@constant char CONNECTCHAR@*/
 # define CONNECTCHAR	'\\'
 
-# define HASALTCONNECTCHAR
-
 /*@constant char ALTCONNECTCHAR@*/
 # define ALTCONNECTCHAR '/'
 
 /* Directory separator character for search list. */
 
 /*@constant char PATH_SEPARATOR; @*/
 # define PATH_SEPARATOR ';'
 
+/*@constant observer char *LEX_YY_C; @*/
+# define LEX_YY_C	"lex.yy.c"
+
 #else
 /* Connection string inserted between directory and filename to make a  */
 /* full path name.							*/
 
 /*@constant observer char *CONNECTSTR@*/
@@ -175,10 +220,23 @@ extern int /*pid_t*/ osd_getPid (void) ;
 
 /* Directory separator character for search list. */
 /*@constant char PATH_SEPARATOR; @*/
 # define PATH_SEPARATOR ':'
 
+/*@constant observer char *LEX_YY_C; @*/
+# define LEX_YY_C	"lex.yy.c"
+
+#endif
+
+#ifdef ALTCONNECTCHAR
+# define HASALTCONNECTCHAR
+#endif
+
+#if defined (MSDOS) || defined (OS2) || defined (WIN32)
+# define HAVE_DOS_FILE_SYSTEM
+# define HAVE_DRIVE_SPECIFIER(n)   ((((n)[0] >= 'A' && (n)[0] <= 'Z') || ((n)[0] >= 'a' && (n)[0] <= 'z')) && (n)[1] == ':')
+# define IS_DOS_STYLE_ABS_PATH(n)  (HAVE_DRIVE_SPECIFIER((n)) && osd_isConnectChar((n)[2]))
 #endif
 
 
 # ifdef P_tmpdir
 
diff -aprNU5 splint-3.1.2.orig/src/context.c splint-3.1.2/src/context.c
--- splint-3.1.2.orig/src/context.c	2004-07-31 19:04:26 +0000
+++ splint-3.1.2/src/context.c	2008-02-19 22:11:32 +0000
@@ -30,10 +30,19 @@
  * - changed occurrances of '/' as path delimiters to macro from portab.h
  * - changed the handling of the tmp directory -- will no longer always be
  *   ".", if possible, environment variables "TMP" or, if not set, "TMP", 
  *   or, if not set "." will be used.
  */
+/*
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * - use HAVE_DOS_FILE_SYSTEM conditional instead of MSDOS, OS2 and WIN32 in context_resetAllFlags().
+ * - for DJGPP also check for "TMPDIR" in context_resetAllFlags().
+ * - if "TEMP", "TMP" or "TMPDIR" points to some directory, make sure that it really
+ *   exists, else default to DEFAULT_TMPDIR in context_resetAllFlags().
+ * - use the OS dependent macro LEX_YY_C instead of the hard coded string "lex.yy.c"
+ *   in context_isSpecialFile().
+ */
 
 # include "splintMacros.nf"
 # include "basic.h"
 
 # include "usymtab_interface.h"
@@ -787,24 +796,30 @@ context_resetAllFlags (void) 
 	      {
 		val = cstring_copy (osd_getEnvironment (cstring_makeLiteralTemp (LCLIMPORTDIR), cstring_makeLiteralTemp (DEFAULT_LCLIMPORTDIR)));
 		break;
 	      }
 	    case FLG_TMPDIR: 
-# if defined(OS2) || defined(MSDOS) || defined(WIN32)
+# ifdef HAVE_DOS_FILE_SYSTEM
               {
                 char *env = osd_getEnvironmentVariable ("TMP");
 
                 if (env == NULL)
                   {
                     env = osd_getEnvironmentVariable ("TEMP");
                   }
 
-                val = cstring_makeLiteral (env != NULL ? env : DEFAULT_TMPDIR);
+# ifdef __DJGPP__
+                if (env == NULL)
+                  {
+                    env = osd_getEnvironmentVariable ("TMPDIR");
+                  }
+# endif
+                val = cstring_makeLiteral ((env != NULL && osd_fileExists (env)) ? env : DEFAULT_TMPDIR);
 	      }
 # else
 	      val = cstring_makeLiteral (DEFAULT_TMPDIR);
-# endif /* !defined(OS2) && !defined(MSDOS) */
+# endif /* !defined(HAVE_DOS_FILE_SYSTEM) */
 
 	      break;
 	    case FLG_BOOLTYPE:
 	      val = cstring_makeLiteral (DEFAULT_BOOLTYPE); break;
 	    case FLG_BOOLFALSE:
@@ -930,11 +945,11 @@ context_resetAllFlags (void) 
 
   /*drl 1/18/2002*/
   gc.flags[FLG_WARNSYSFILES] = TRUE;
 
   /*
-  ** On by default for Win32, but not Unix
+  ** On by default for DOS, OS2 and Win32, but not Unix
   */
 
 # if defined (WIN32) || defined (OS2)
   gc.flags[FLG_PARENFILEFORMAT] = TRUE;
   gc.flags[FLG_CASEINSENSITIVEFILENAMES] = TRUE;
@@ -1394,11 +1409,11 @@ context_isSpecialFile (cstring fname)
 {
   cstring ext = fileLib_getExtension (fname);
   
   return (cstring_equalLit (ext, ".y") 
 	  || cstring_equalLit (ext, ".l")
-	  || cstring_equalLit (fname, "lex.yy.c"));
+	  || cstring_equalLit (fname, LEX_YY_C));
 }
 
 bool
 context_isSystemDir (cstring dir)
 {
diff -aprNU5 splint-3.1.2.orig/src/cpplib.c splint-3.1.2/src/cpplib.c
--- splint-3.1.2.orig/src/cpplib.c	2007-07-13 22:17:48 +0000
+++ splint-3.1.2/src/cpplib.c	2008-02-19 22:12:04 +0000
@@ -52,10 +52,26 @@ Foundation, 59 Temple Place - Suite 330,
  * Herbert 06/12/2000:
  * - OS2 drive specs like WIN32
  * - Includes for IBMs OS/2 compiler
  */
 
+/*
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * - Replace "/include" with the OS dependent CONNECTSTR"include"
+ *   in the check of default_prefix in cpplib_initializeReader().
+ * - Replace conditionals OS2 and WIN32 with HAVE_DOS_FILE_SYSTEM
+ *   to enable the checking for absolute paths with DOS syntax and
+ *   use HAVE_DRIVE_SPECIFIER for checking in do_include().
+ * - Replace conditionals OS2 and WIN32 with HAVE_DOS_FILE_SYSTEM
+ *   to enable the replacing of slashes to backslashes in do_include().
+ *   Instead of hard coding the replacement chars, ALTCONNECTCHAR and
+ *   CONNECTCHAR are used.  ALTCONNECTCHAR will be replaced by CONNECTCHAR.
+ * - If UNAME is set to MS-DOS then add MSDOS family of preprocessor
+ *   symbols to the universal symbol table in initialize_builtins().
+ */
+
+
 # include <ctype.h>
 # include <stdio.h>
 # include <signal.h>
 # ifdef __STDC__
 # include <stdlib.h>
@@ -3860,10 +3876,30 @@ initialize_builtins (cppReader *pfile)
       cpplib_installBuiltin ("__OPEN_MAX", ctype_int, -1, T_CONST, 20, NULL, -1);
       cpplib_installBuiltin ("__STDC__", ctype_int, -1, T_CONST, 2, NULL, -1);
       cpplib_installBuiltin ("__sparc", ctype_int, -1, T_CONST, 2, NULL, -1);
       /*       This define  "-Dfileno(f)=0" should be inserted but we're going to stick to deinfe constants for now...*/
     }
+  else if(! strcmp (UNAME, "MS-DOS"))
+    {
+#if defined(MSDOS)
+      cpplib_installBuiltin ("MSDOS", ctype_int, -1, T_CONST, 1, NULL, -1);
+#endif
+#if defined(__MSDOS)
+      cpplib_installBuiltin ("__MSDOS", ctype_int, -1, T_CONST, 1, NULL, -1);
+#endif
+#if defined(__MSDOS__)
+      cpplib_installBuiltin ("__MSDOS__", ctype_int, -1, T_CONST, 1, NULL, -1);
+#endif
+#if defined(__DJGPP__)
+      cpplib_installBuiltin ("DJGPP", ctype_int, -1, T_CONST, 2, NULL, -1);
+      cpplib_installBuiltin ("__DJGPP", ctype_int, -1, T_CONST, 2, NULL, -1);
+      cpplib_installBuiltin ("__DJGPP__", ctype_int, -1, T_CONST, 2, NULL, -1);
+      cpplib_installBuiltin ("DJGPP_MINOR", ctype_int, -1, T_CONST, 4, NULL, -1);
+      cpplib_installBuiltin ("__DJGPP_MINOR", ctype_int, -1, T_CONST, 4, NULL, -1);
+      cpplib_installBuiltin ("__DJGPP_MINOR__", ctype_int, -1, T_CONST, 4, NULL, -1);
+#endif
+    }
   else
     {
       /*
 	types which we have not explictedly handled.
 	AIX, FreeBSD, IRIX, Mach
@@ -4796,12 +4832,12 @@ do_include (cppReader *pfile, struct dir
   /* + 2 added for '.h' on VMS (to support '#include filename') */
 
   /* If specified file name is absolute, just open it.  */
 
   if (osd_isConnectChar (*fbeg)
-# if defined (WIN32) || defined (OS2)
-      || (*(fbeg + 1) == ':')
+# ifdef HAVE_DOS_FILE_SYSTEM
+      || HAVE_DRIVE_SPECIFIER (fbeg)
 # endif
       )
     {
       fname = cstring_copyLength (fbeg, flen);
       
@@ -4846,17 +4882,19 @@ do_include (cppReader *pfile, struct dir
 	  fname = cstring_concatLength (fname, fbeg, flen);
 
 	  DPRINTF (("fname: %s", fname));
 	  
 	  /* Win32 directory fix from Kay Buschner. */
-#if defined (WIN32) || defined (OS2)
+	  /* Also required by MSDOS.
+	     Use ALTCONNECTCHAR and CONNECTCHAR instead of hard coded slash and backslash. */
+#ifdef HAVE_DOS_FILE_SYSTEM
 	  /* Fix all unixdir slashes to win dir slashes */
 	  if (searchptr->fname && (searchptr->fname[0] != 0)) 
 	    {
-	      cstring_replaceAll (fname, '/', '\\');
+	      cstring_replaceAll (fname, ALTCONNECTCHAR, CONNECTCHAR);
 	    }
-#endif /* WIN32 */
+#endif /* HAVE_DOS_FILE_SYSTEM */
 
 #ifdef VMS
 	  /* Change this 1/2 Unix 1/2 VMS file specification into a
 	     full VMS file specification */
 	  if (searchptr->fname && (searchptr->fname[0] != 0)) {
@@ -7607,12 +7645,12 @@ void cpplib_initializeReader (cppReader 
     char *default_prefix = mstring_copy (GCC_INCLUDE_DIR);
     size_t default_len = 0;
     
     /* Remove the `include' from /usr/local/lib/gcc.../include.  */
     if (default_prefix != NULL) {
-      if (!strcmp (default_prefix + strlen (default_prefix) - 8, "/include")) {
-	default_len = strlen (default_prefix) - 7;
+      if (!strcmp (default_prefix + strlen (default_prefix) - sizeof(CONNECTSTR"include"), CONNECTSTR"include")) {
+	default_len = strlen (default_prefix) - sizeof("include");
 	default_prefix[default_len] = 0;
       }
     }
     
     /* Search "translated" versions of GNU directories.
diff -aprNU5 splint-3.1.2.orig/src/cppmain.c splint-3.1.2/src/cppmain.c
--- splint-3.1.2.orig/src/cppmain.c	2003-04-14 04:13:00 +0000
+++ splint-3.1.2/src/cppmain.c	2008-02-19 22:12:36 +0000
@@ -104,11 +104,10 @@ int cppProcess (/*@dependent@*/ cstring 
 		/*@dependent@*/ cstring outfile) 
 {
   FILE *ofile;
   struct cppOptions *opts = CPPOPTIONS (&g_cppState);
   
-  opts->out_fname = outfile;
   opts->in_fname = infile;
   opts->out_fname = outfile;
   
   if (cpplib_fatalErrors (&g_cppState))
     {
diff -aprNU5 splint-3.1.2.orig/src/cscannerHelp.c splint-3.1.2/src/cscannerHelp.c
--- splint-3.1.2.orig/src/cscannerHelp.c	2004-07-31 19:04:26 +0000
+++ splint-3.1.2/src/cscannerHelp.c	2008-02-19 22:13:06 +0000
@@ -26,10 +26,18 @@
 **
 ** Most of this code was in cscanner.l, but moved here to separate it
 ** from the flex-generated code.
 */
 
+/*
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * - Replace conditionals MSDOS, OS2 and WIN32 with HAVE_DOS_FILE_SYSTEM to
+ *   select code that removes multiples connect chars in the path string.
+ *   Also change the used logic to allow for the use of alternate connect
+ *   chars in cscannerHelp_handleSpecial().
+ */
+
 # include "splintMacros.nf"
 # include "basic.h"
 # include "cscannerHelp.h"
 # include "cscanner.h"
 # include "cgrammar_tokens.h"
@@ -760,11 +768,11 @@ bool cscannerHelp_handleSpecial (char *y
 	}
 
       llassert (*tmp == '\"');
       *tmp = '\0';
 
-# if defined(OS2) || defined(MSDOS) || defined(WIN32)
+# ifdef HAVE_DOS_FILE_SYSTEM
 
       /*
       ** DOS-like path delimiters get delivered in pairs, something like 
       ** \"..\\\\file.h\", so we have to make it normal again. We do NOT
       ** remove the pre dirs yet as we usually specify tmp paths relative
@@ -772,41 +780,50 @@ bool cscannerHelp_handleSpecial (char *y
       ** the hash table.  If this method fails we try it again later. 
       */
 
       {
 	char *stmp = fname;
-	
+	unsigned int i, j;
+
 	/*
 	** Skip past the drive marker.
 	*/
 	
 	if (strchr (stmp, ':') != NULL)
 	  {
 	    stmp = strchr (stmp, ':') + 1;
 	  }
-	
-	while ((stmp = strchr (stmp, CONNECTCHAR)) != NULL )
+
+	for (i = 0, j = 1; stmp[i]; i = j, j++)
 	  {
-	    if (*(stmp+1) == CONNECTCHAR)
+	    if ((stmp[i] == CONNECTCHAR
+# ifdef HASALTCONNECTCHAR
+	         || stmp[i] == ALTCONNECTCHAR
+#endif
+	        ) &&
+	        (stmp[j] == CONNECTCHAR
+# ifdef HASALTCONNECTCHAR
+	         || stmp[j] == ALTCONNECTCHAR
+#endif
+	        )
+	       )
 	      {
-		memmove (stmp, stmp+1, strlen (stmp));
+		memmove (stmp + i, stmp + j, strlen (stmp + i));
 	      }
-	    
-	    stmp++;
 	  }
 	
 	fid = fileTable_lookupBase (context_fileTable (), fname);
 	if (!(fileId_isValid (fid)))
 	  {
 	    fname = removePreDirs (fname);
 	    fid = fileTable_lookupBase (context_fileTable (), fname);
 	  }
       }
-# else  /* !defined(OS2) && !defined(MSDOS) */
+# else  /* !HAVE_DOS_FILE_SYSTEM */
       fname = removePreDirs (fname);
       fid = fileTable_lookupBase (context_fileTable (), fname);      
-# endif /* !defined(OS2) && !defined(MSDOS) */
+# endif /* !HAVE_DOS_FILE_SYSTEM */
       
       if (!(fileId_isValid (fid)))
 	{
 	  if (context_inXHFile ())
 	    {
diff -aprNU5 splint-3.1.2.orig/src/fileLib.c splint-3.1.2/src/fileLib.c
--- splint-3.1.2.orig/src/fileLib.c	2003-04-20 22:55:06 +0000
+++ splint-3.1.2/src/fileLib.c	2008-02-19 22:13:32 +0000
@@ -23,10 +23,18 @@
 */
 /*
 ** fileLib.c
 */
 
+/*
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * - use only the basename of the filename to determinate the file extension in fileLib_removeAnyExtension().
+ * - use only the basename of the filename to determinate the file extension in fileLib_getExtension().
+ * - check for remainders from double path delimiters before trying to remove them in removePreDirs().
+ * - check for ALTCONNECTCHAR in the path also in removePreDirs().
+ */
+
 # include "splintMacros.nf"
 # include "basic.h"
 # include "osd.h"
 
 bool
@@ -100,11 +108,11 @@ fileLib_removePathFree (/*@only@*/ cstri
     return cstring_undefined;
   }
 
   t = strrchr (s, CONNECTCHAR);
 
-# ifdef ALTCONNECTCHAR
+# ifdef HASALTCONNECTCHAR
   {
     char *at = strrchr (s, ALTCONNECTCHAR);
     if (t == NULL || (at > t)) {
       t = at;
     }
@@ -128,17 +136,29 @@ fileLib_removePathFree (/*@only@*/ cstri
 fileLib_removeAnyExtension (cstring s)
 {
   /*@access cstring@*/
   char *ret;
   char *t;
+  unsigned int i;
 
 
   if (cstring_isUndefined (s)) {
     return cstring_undefined;
   } 
 
-  t = strrchr (s, '.');
+  for (i = strlen(s); i; i--)
+    {
+       if ((s[i] == CONNECTCHAR)
+# ifdef HASALTCONNECTCHAR
+           || (s[i] == ALTCONNECTCHAR)
+# endif
+          )
+         {
+            break;
+         }
+    }
+  t = strrchr (s + i, '.');
 
   if (t == (char *) 0)
     {
       return mstring_copy (s);
     }
@@ -175,35 +195,54 @@ bool fileLib_hasExtension (cstring s, cs
   return cstring_equal (fileLib_getExtension (s), ext);
 }
 
 /*@observer@*/ cstring fileLib_getExtension (/*@returned@*/ cstring s)
 {
+  unsigned int i;
+
   llassert (cstring_isDefined (s));
 
   /*@access cstring@*/
-  return (strrchr(s, '.'));
+  for (i = strlen(s); i; i--)
+    {
+       if ((s[i] == CONNECTCHAR)
+# ifdef HASALTCONNECTCHAR
+           || (s[i] == ALTCONNECTCHAR)
+# endif
+          )
+         {
+            break;
+         }
+    }
+  return (strrchr(s + i, '.'));
   /*@noaccess cstring@*/
 }
 
 cstring removePreDirs (cstring s)
 {
   /*@access cstring@*/
 
   llassert (cstring_isDefined (s));
 
-  while (*s == '.' && *(s + 1) == CONNECTCHAR) 
+  while (*s == '.' && 
+         ((*(s + 1) == CONNECTCHAR)
+# ifdef HASALTCONNECTCHAR
+          || (*(s + 1) == ALTCONNECTCHAR)
+# endif
+         )
+        )
     {
       s += 2;
     }
 
-# if defined(OS2) || defined(MSDOS)
+# ifdef HAVE_DOS_FILE_SYSTEM
   /* remove remainders from double path delimiters... */
-  while (*s == CONNECTCHAR) 
+  while (osd_isConnectChar (s[0]) && osd_isConnectChar (s[1]))
     {
       ++s;
     }
-# endif /* !defined(OS2) && !defined(MSDOS) */
+# endif /* !HAVE_DOS_FILE_SYSTEM */
 
   return s;
   /*@noaccess cstring@*/
 }
 
diff -aprNU5 splint-3.1.2.orig/src/osd.c splint-3.1.2/src/osd.c
--- splint-3.1.2.orig/src/osd.c	2007-07-13 22:18:20 +0000
+++ splint-3.1.2/src/osd.c	2008-02-19 22:23:10 +0000
@@ -39,10 +39,26 @@
  * - handle files like in WIN32 for OS/2 in osd_fileExists()
  * Herbert 02/17/2002:
  * - added OS/2 support to absolute file names
  */
 
+/*
+ * Modified by Juan M. Guerrero <juan.guerrero@gmx.de> 2008-02-19:
+ * -added DJGPP specific return type for getpid() in osd_getPid().
+ * -use HAVE_DOS_FILE_SYSTEM conditional instead of MSDOS, OS2 and WIN32 in osd_getPath().
+ * -check for ALTCONNECTCHAR in osd_getPath() too.
+ * -use HAVE_DOS_FILE_SYSTEM conditional instead of OS2 and WIN32 in osd_fileExists().
+ * -replace OS2 with HAVE_DOS_FILE_SYSTEM when checking for absolute path in osd_absolutePath().
+ * -fix the broken logic to check if a DOS style path is absolute or relative.
+ *  The relative path c:foo\bar is something completely different than
+ *  the absolute path c:\foo\bar.  On DOS/WINDOWS file systems every partition
+ *  has its own root directory and thus its own cwd so it must be checked if we
+ *  are dealing with the same partition before prepending the cwd string in the
+ *  relative path string.
+ * -use HAVE_DOS_FILE_SYSTEM conditional instead of OS2 and WIN32 in osd_getCurrentDirectory().
+ */
+
 /*@-allmacros*/
 /*@ignore@*/
 # include <sys/types.h>
 # include <sys/stat.h>
 /* Fix suggested by Lars Rasmussen */
@@ -175,15 +191,19 @@ osd_getPath (cstring path, cstring file,
 
   *returnPath = cstring_undefined;
 
   if (fullPath == NULL 
       || 
-# if defined(OS2) || defined(MSDOS) || defined(WIN32)
+# ifdef HAVE_DOS_FILE_SYSTEM
       /* under OS/2 and MSDOS the includePath may be empty, if so, search 
        * the current directory. */
       *fullPath == '\0' || 
-      (*file == CONNECTCHAR || (file[0] != '\0' && file[1] == ':'))
+      (*file == CONNECTCHAR ||
+# ifdef HASALTCONNECTCHAR
+       *file == ALTCONNECTCHAR ||
+# endif
+       (file[0] != '\0' && file[1] == ':'))
 # else
       (*file == CONNECTCHAR)
 # endif
       )
     {
@@ -301,11 +321,11 @@ osd_fileExists (cstring filespec)
 {
 # ifdef UNIX
   struct stat buf;
   /*@i3@*/ return (stat (cstring_toCharsSafe (filespec), &buf) == 0); /* spurious */
 # else
-# if defined (WIN32) || defined (OS2)
+# ifdef HAVE_DOS_FILE_SYSTEM
   FILE *test = fileTable_openReadFile (context_fileTable (), filespec);
   
   if (test != NULL) 
     {
       (void) fileTable_closeFile (context_fileTable (),test);
@@ -513,10 +533,12 @@ int /* pid_t */
 # endif
 osd_getPid ()
 {
 # if defined (WIN32) || defined (OS2) && defined (__IBMC__)
   int pid = _getpid ();
+# elif defined (__DJGPP__)
+  pid_t pid = getpid ();
 # else
   __pid_t pid = getpid ();
 # endif
 
   return (int) pid;
@@ -893,11 +915,11 @@ void osd_destroyMod (void)
   osd_cwd = cstring_undefined;
 }
 
 cstring osd_absolutePath (cstring cwd, cstring filename)
 {
-# if defined (UNIX) || defined (OS2)
+# if defined (UNIX) || defined (HAVE_DOS_FILE_SYSTEM)
   /* Setup the current working directory as needed.  */
   cstring cwd2 = cstring_isDefined (cwd) ? cwd : osd_cwd;
   char *abs_buffer;
   char *endp, *outp, *inp;
 
@@ -907,20 +929,33 @@ cstring osd_absolutePath (cstring cwd, c
 
   abs_buffer = (char *) dmalloc (cstring_length (cwd2) + cstring_length (filename) + 2);
   endp = abs_buffer;
   
   /*
-  ** Copy the  filename (possibly preceded by the current working
+  ** Copy the filename (possibly preceded by the current working
   ** directory name) into the absolutization buffer.  
   */
   
   {
     const char *src_p;
 
     if (!osd_isConnectChar (filename[0])
-# ifdef OS2
-	&& !(isalpha (filename[0]) && filename[1] == ':')
+# ifdef HAVE_DOS_FILE_SYSTEM
+	/*
+	 *  On DOS/OS2/WINDOWS file systems every partition
+	 *  has its own root directory and thus its own
+	 *  cwd so check if we are dealing with the same
+	 *  partition by comparing the drive letter
+	 *  before prepending the cwd string to the
+	 *  relative path string.
+	 *  Attention: the relative path c:foo\bar is something
+	 *  completely different than the absolute path c:\foo\bar.
+	 */
+	&& !IS_DOS_STYLE_ABS_PATH (filename)                                                      /*  c:/foo/bar  */
+	&& (!HAVE_DRIVE_SPECIFIER (filename)                                                      /*  foo/bar     */
+	    || (HAVE_DRIVE_SPECIFIER (filename) && (tolower (filename[0]) == tolower (cwd2[0])))  /*  c:foo/var   */
+	   )
 # endif
 	)
       {
         src_p = cwd2;
 
@@ -1180,11 +1215,11 @@ cstring osd_outputPath (cstring filename
 # endif
 }
 
 cstring osd_getCurrentDirectory ()
 {
-# if defined(MSDOS) || defined(OS2)
+# ifdef HAVE_DOS_FILE_SYSTEM
   return cstring_makeLiteralTemp ("");
 # else
   return cstring_makeLiteralTemp ("./");
 # endif
 }
diff -aprNU5 splint-3.1.2.orig/test/Makefile.in splint-3.1.2/test/Makefile.in
--- splint-3.1.2.orig/test/Makefile.in	2007-07-13 21:11:14 +0000
+++ splint-3.1.2/test/Makefile.in	2008-02-19 22:15:02 +0000
@@ -977,13 +977,19 @@ fulltest:
 	@echo ""
 	@echo "Tests:"
 	@echo ""
 	@for TEST in $(SPLINTTESTS); do \
 	   echo "Checking $$TEST..."; \
-	   $(MAKE) $$TEST 2>&1 | $(CLEANOUTPUT) >$$TEST.out && \
-	     $(DIFF) $(DIFFFLAGS) $$TEST.expect $$TEST.out || \
-               echo "*** FAIL ***"; \
+	   if test "x$$TEST" = "xrc" && test "x$$DJGPP" != "x"; then \
+	     $(MAKE) $$TEST 2>&1 | $(CLEANOUTPUT) >$$TEST.out && \
+	       $(DIFF) $(DIFFFLAGS) $$TEST.expect.djgpp $$TEST.out || \
+                 echo "*** FAIL ***"; \
+	   else \
+	     $(MAKE) $$TEST 2>&1 | $(CLEANOUTPUT) >$$TEST.out && \
+	       $(DIFF) $(DIFFFLAGS) $$TEST.expect $$TEST.out || \
+                 echo "*** FAIL ***"; \
+	   fi \
 	 done
 
 ### Rules for tests start here
 
 .PHONY: abstptr
@@ -1528,11 +1534,15 @@ printflike:
 rc:
 	-$(SPLINTR) -DMYSTERY='"a flag\"wicked cool"' rc.c -expect 1
 	-$(SPLINTR) -DMYSTERY=12 rc.c -expect 1
 	-$(SPLINTR) -f rc1.splintrc rc.c -expect 1
 	-$(SPLINTR) -UMYSTERY -f rc1.splintrc rc.c -expect 1
+ifeq ($(strip $(DJGPP)),)
 	-$(SPLINTR) -f rc3.splintrc rc.c -expect 1
+else
+	-$(SPLINTR) -f rc3.splintrc.djgpp rc.c -expect 1
+endif
 
 .PHONY: rcfiles
 rcfiles:
 	cd rcfiles; ${MAKE} SPLINT="-$(SPLINTPNEST)"
 
diff -aprNU5 splint-3.1.2.orig/test/db1/Makefile splint-3.1.2/test/db1/Makefile
--- splint-3.1.2.orig/test/db1/Makefile	2003-07-10 20:33:24 +0000
+++ splint-3.1.2/test/db1/Makefile	2008-02-19 22:15:02 +0000
@@ -16,12 +16,12 @@ LCSFILES = bool.lcs dbase.lcs employee.l
 
 MODULES = bool.lcl employee eref empset ereftab erc dbase drive.c
 OBJS = dbase.o employee.o empset.o erc.o eref.o ereftab.o 
 
 test: 
-	$(MAKE) -e clean
-	$(MAKE) -e check
+	@$(MAKE) -e clean
+	@$(MAKE) -e check
 
 ###
 ### Removed +showscan, produces different results on different platforms
 ###
 
diff -aprNU5 splint-3.1.2.orig/test/db2/Makefile splint-3.1.2/test/db2/Makefile
--- splint-3.1.2.orig/test/db2/Makefile	2003-04-20 20:07:54 +0000
+++ splint-3.1.2/test/db2/Makefile	2008-02-19 22:15:02 +0000
@@ -16,12 +16,12 @@ LCSFILES = dbase.lcs employee.lcs empset
 
 MODULES = employee eref empset ereftab erc dbase drive.c
 OBJS = dbase.o employee.o empset.o erc.o eref.o ereftab.o 
 
 test: 
-	$(MAKE) -e clean
-	$(MAKE) -e check
+	@$(MAKE) -e clean
+	@$(MAKE) -e check
 
 check: $(LCSFILES)
 	-$(SPLINT) -exportlocal -showcol -allimponly -macrovarprefixexclude $(MODULES) -bufferoverflowhigh -expect 15
 	-$(SPLINT) -exportlocal -showcol +allimponly $(MODULES) -bufferoverflowhigh -expect 25
 	-$(SPLINT) -exportlocal -showcol -memchecks -macrovarprefixexclude -bufferoverflowhigh $(MODULES)
diff -aprNU5 splint-3.1.2.orig/test/rc.expect.djgpp splint-3.1.2/test/rc.expect.djgpp
--- splint-3.1.2.orig/test/rc.expect.djgpp	1970-01-01 00:00:00 +0000
+++ splint-3.1.2/test/rc.expect.djgpp	2008-02-19 22:15:02 +0000
@@ -0,0 +1,35 @@
+
+rc.c: (in function f)
+rc.c:3:10: Observer storage returned without qualification:
+              "a flag\"wicked cool"
+   rc.c:3:10: Storage becomes observer
+
+Finished checking --- 1 code warning, as expected
+
+rc.c: (in function f)
+rc.c:3:10: Return value type int does not match declared type char *: 12
+
+Finished checking --- 1 code warning, as expected
+
+rc2.splintrc:1:18: Setting +boolint redundant with current value
+rc.c: (in function f)
+rc.c:3:10: Observer storage returned without qualification: "a silly\"flag\"\\"
+   rc.c:3:10: Storage becomes observer
+
+Finished checking --- 1 code warning, as expected
+
+rc2.splintrc:1:18: Setting +boolint redundant with current value
+rc.c: (in function f)
+rc.c:3:10: Unrecognized identifier: MYSTERY
+
+Finished checking --- 1 code warning, as expected
+
+rc3.splintrc.djgpp:6:3: Flag dump must be followed by a string
+  A flag is not recognized or used in an incorrect way (Use -badflag to inhibit
+  warning)
+rc3.splintrc.djgpp:6:3: Cannot list files in .splintrc files:
+                           internalnamelen, 73 (probable missing + or -)
+rc.c: (in function f)
+rc.c:3:10: Unrecognized identifier: MYSTERY
+
+Finished checking --- 1 code warning, as expected
diff -aprNU5 splint-3.1.2.orig/test/rc3.splintrc.djgpp splint-3.1.2/test/rc3.splintrc.djgpp
--- splint-3.1.2.orig/test/rc3.splintrc.djgpp	1970-01-01 00:00:00 +0000
+++ splint-3.1.2/test/rc3.splintrc.djgpp	2008-02-19 22:15:02 +0000
@@ -0,0 +1,6 @@
+-externalnamelen 		23
+internalnamelen	73
++tmpdir /dev/env/DJDIR/
+-tmpdir /dev/env/DJDIR
+                  -dump
+  
diff -aprNU5 splint-3.1.2.orig/test/tests2.4/Makefile splint-3.1.2/test/tests2.4/Makefile
--- splint-3.1.2.orig/test/tests2.4/Makefile	2003-04-16 22:41:40 +0000
+++ splint-3.1.2/test/tests2.4/Makefile	2008-02-19 22:15:02 +0000
@@ -68,11 +68,15 @@ subdir:
 
 fink:
 	$(SPLINT) fink.c 
 
 driverstub:
+ifeq ($(strip $(DJGPP)),)
 	$(SPLINT) driverstub.c -sysdirs "/usr/"
+else
+	$(SPLINT) driverstub.c -sysdirs "/dev/env/DJDIR/"
+endif
 
 alignof:
 	$(SPLINT) alignof.c -expect 2
 
 source:
