/*@constant size_t INTPTR_MIN@*/
/*@constant size_t INTPTR_MAX@*/
-
-/*drl 3/5/2003
- added the __func__ identifier from C99
- This won't follow the same semantics as
- __func__ in C99
-
- FWIW C99 says that __func__ should have the value of the
- lexically enclosing function
- e.g. in the function foo __func__ == "foo"
- in bar __func__ == "bar"
-
- We're just having the value be constant here and picking
- an arbitary value.
-*/
-const char __func__[] = "function-name";
# include <stdlib.h>
# include <stdio.h>
+
+# ifndef WIN32
+/* Microsoft VC++ still doesn't support ISO C99... */
# include <stdbool.h>
+# endif
+
# include <string.h>
# include <ctype.h>
# include <float.h>
# define BOOL_H
+# ifdef WIN32
+# ifndef FALSE
+/*@constant bool FALSE=false@*/
+# define FALSE 0
+# endif
+
+# ifndef TRUE
+/*@constant bool TRUE=true@*/
+# define TRUE (!FALSE)
+# endif
+# else
# ifndef FALSE
/*@constant bool FALSE=false@*/
# define FALSE false
/*@constant bool TRUE=true@*/
# define TRUE true
# endif
+# endif
extern /*@observer@*/ cstring bool_unparse (bool p_b) /*@*/ ;
extern /*@observer@*/ cstring bool_dump (bool p_b) /*@*/ ;
/* different flavors of hash nodes --- also used in keyword table */
enum node_type {
T_NONE = 0,
- T_DEFINE = 1, /* the `#define' keyword */
- T_INCLUDE, /* the `#include' keyword */
- T_INCLUDE_NEXT, /* the `#include_next' keyword */
- T_IFDEF, /* the `#ifdef' keyword */
- T_IFNDEF, /* the `#ifndef' keyword */
- T_IF, /* the `#if' keyword */
- T_ELSE, /* `#else' */
- T_PRAGMA, /* `#pragma' */
- T_ELIF, /* `#elif' */
- T_UNDEF, /* `#undef' */
- T_LINE, /* `#line' */
- T_ERROR, /* `#error' */
- T_WARNING, /* `#warning' */
- T_ENDIF, /* `#endif' */
- T_IDENT, /* `#ident', used on system V. */
- T_SPECLINE, /* special symbol `__LINE__' */
- T_DATE, /* `__DATE__' */
- T_FILE, /* `__FILE__' */
- T_BASE_FILE, /* `__BASE_FILE__' */
- T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
- T_VERSION, /* `__VERSION__' */
- T_SIZE_TYPE, /* `__SIZE_TYPE__' */
- T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */
- T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */
- T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */
- T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */
- T_TIME, /* `__TIME__' */
- T_CONST, /* Constant value, used by `__STDC__' */
- T_MACRO, /* macro defined by `#define' */
+ T_DEFINE = 1, /* the #define keyword */
+ T_INCLUDE, /* the #include keyword */
+ T_INCLUDE_NEXT, /* the #include_next keyword */
+ T_IFDEF, /* the #ifdef keyword */
+ T_IFNDEF, /* the #ifndef keyword */
+ T_IF, /* the #if keyword */
+ T_ELSE, /* #else */
+ T_PRAGMA, /* #pragma */
+ T_ELIF, /* #elif */
+ T_UNDEF, /* #undef */
+ T_LINE, /* #line */
+ T_ERROR, /* #error */
+ T_WARNING, /* #warning */
+ T_ENDIF, /* #endif */
+ T_IDENT, /* #ident, used on system V. */
+ T_SPECLINE, /* special symbol __LINE__ */
+ T_DATE, /* __DATE__ */
+ T_FILE, /* __FILE__ */
+ T_BASE_FILE, /* __BASE_FILE__ */
+ T_INCLUDE_LEVEL, /* __INCLUDE_LEVEL__ */
+ T_FUNC, /* __func__ */
+ T_VERSION, /* __VERSION__ */
+ T_SIZE_TYPE, /* __SIZE_TYPE__ */
+ T_PTRDIFF_TYPE, /* __PTRDIFF_TYPE__ */
+ T_WCHAR_TYPE, /* __WCHAR_TYPE__ */
+ T_USER_LABEL_PREFIX_TYPE, /* __USER_LABEL_PREFIX__ */
+ T_REGISTER_PREFIX_TYPE, /* __REGISTER_PREFIX__ */
+ T_TIME, /* __TIME__ */
+ T_CONST, /* Constant value, used by __STDC__ */
+ T_MACRO, /* macro defined by #define */
T_DISABLED, /* macro temporarily turned off for rescan */
- T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */
+ T_SPEC_DEFINED, /* special defined macro for use in #if statements */
T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */
T_UNUSED /* Used for something not defined. */
} ;
# include "lclForwardTypes.h"
+# ifdef WIN32
+/* Microsoft doesn't support ISO C99 yet */
+typedef int bool;
+# endif
+
abst_typedef /*@null@*/ struct s_sRef *sRef;
abst_typedef /*@null@*/ struct s_uentry *uentry;
typedef struct s_hashNode *hashNode;
typedef unsigned int bits;
typedef long unsigned Handle;
-
-extern char *FormatInt (int p_i) /*@*/ ;
extern bool firstWord (char *p_s, char *p_w);
# endif
extern int /*pid_t*/ osd_getPid (void) ;
# endif
+# ifdef WIN32
+/* Win32 doesn't support ISO C99 correctly... */
+# define snprintf _snprintf
+# endif
+
+/*
+** Win32 convention?
+*/
+
+# if defined(__IBMC__) && defined(OS2)
+# define S_IFMT (unsigned short)0xFFFF
+# endif
+
+# if defined (OS2) || defined (MSDOS) || defined (WIN32)
+/*@constant observer cstring INCLUDEPATH_VAR@*/
+# define INCLUDEPATH_VAR cstring_makeLiteralTemp ("INCLUDE")
+# else
+/*@constant observer cstring INCLUDEPATH_VAR@*/
+# define INCLUDEPATH_VAR cstring_makeLiteralTemp ("CPATH")
+# endif
+
+#if defined (VMS)
+
+/*
+** VMS is here, but hasn't been tested for many releases. Not sure if this works.
+*/
+
+/*
+** Connection string inserted between directory and filename to make a
+** full path name.
+*/
+
+# define CONNECTSTR ":"
+# define CONNECTCHAR ':'
+
+/* Directory separator character for search list. */
+/*@constant static char PATH_SEPARATOR; @*/
+# define PATH_SEPARATOR ':'
+
+# elif defined(MSDOS) || defined(OS2) || defined(WIN32)
+
+/* Connection string inserted between directory and filename to make a */
+/* full path name. */
+
+/*@constant observer char *CONNECTSTR@*/
+# 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 ';'
+
+#else
+/* Connection string inserted between directory and filename to make a */
+/* full path name. */
+
+/*@constant observer char *CONNECTSTR@*/
+# define CONNECTSTR "/"
+
+/*@constant char CONNECTCHAR; @*/
+# define CONNECTCHAR '/'
+
+/* Directory separator character for search list. */
+/*@constant char PATH_SEPARATOR; @*/
+# define PATH_SEPARATOR ':'
+
+#endif
+
+
+# ifdef P_tmpdir
+
+# if defined(OS2) && defined(__IBMC__)
+/*@constant observer char *DEFAULT_TMPDIR; @*/
+# define DEFAULT_TMPDIR "."
+# else
+/*@constant observer char *DEFAULT_TMPDIR; @*/
+# define DEFAULT_TMPDIR P_tmpdir
+# endif
+# else
+# ifdef WIN32
+/*@constant observer char *DEFAULT_TMPDIR; @*/
+# define DEFAULT_TMPDIR "\\WINDOWS\\TEMP\\"
+# else
+/*@constant observer char *DEFAULT_TMPDIR; @*/
+# define DEFAULT_TMPDIR "/tmp/"
+# endif /* WIN32 */
+
+# endif /* P_tmpdir */
+
+# else
+# error "Multiple include"
+# endif
+
+
# else
# error "Multiple include"
# endif
+++ /dev/null
-/*
-** Copyright (c) Massachusetts Institute of Technology 1994, 1995, 1996.
-** See ../LICENSE for license information.
-*/
-
-# ifndef PORTAB_H
-# define PORTAB_H
-
-/*
-** Win32 convention?
-*/
-
-# if defined(__IBMC__) && defined(OS2)
-# define S_IFMT (unsigned short)0xFFFF
-# endif
-
-# if defined (OS2) || defined (MSDOS) || defined (WIN32)
-/*@constant observer cstring INCLUDEPATH_VAR@*/
-# define INCLUDEPATH_VAR cstring_makeLiteralTemp ("INCLUDE")
-# else
-/*@constant observer cstring INCLUDEPATH_VAR@*/
-# define INCLUDEPATH_VAR cstring_makeLiteralTemp ("CPATH")
-# endif
-
-#if defined (VMS)
-
-/*
-** VMS is here, but hasn't been tested for many releases. Not sure if this works.
-*/
-
-/*
-** Connection string inserted between directory and filename to make a
-** full path name.
-*/
-
-# define CONNECTSTR ":"
-# define CONNECTCHAR ':'
-
-/* Directory separator character for search list. */
-/*@constant static char PATH_SEPARATOR; @*/
-# define PATH_SEPARATOR ':'
-
-# elif defined(MSDOS) || defined(OS2) || defined(WIN32)
-
-/* Connection string inserted between directory and filename to make a */
-/* full path name. */
-
-/*@constant observer char *CONNECTSTR@*/
-# 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 ';'
-
-#else
-/* Connection string inserted between directory and filename to make a */
-/* full path name. */
-
-/*@constant observer char *CONNECTSTR@*/
-# define CONNECTSTR "/"
-
-/*@constant char CONNECTCHAR; @*/
-# define CONNECTCHAR '/'
-
-/* Directory separator character for search list. */
-/*@constant char PATH_SEPARATOR; @*/
-# define PATH_SEPARATOR ':'
-
-#endif
-
-
-# ifdef P_tmpdir
-
-# if defined(OS2) && defined(__IBMC__)
-/*@constant observer char *DEFAULT_TMPDIR; @*/
-# define DEFAULT_TMPDIR "."
-# else
-/*@constant observer char *DEFAULT_TMPDIR; @*/
-# define DEFAULT_TMPDIR P_tmpdir
-# endif
-# else
-# ifdef WIN32
-/*@constant observer char *DEFAULT_TMPDIR; @*/
-# define DEFAULT_TMPDIR "\\WINDOWS\\TEMP\\"
-# else
-/*@constant observer char *DEFAULT_TMPDIR; @*/
-# define DEFAULT_TMPDIR "/tmp/"
-# endif /* WIN32 */
-
-# endif /* P_tmpdir */
-
-# else
-# error "Multiple include"
-# endif
-
+++ /dev/null
-/*
-** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2003 University of Virginia,
-** Massachusetts Institute of Technology
-**
-** This program is free software; you can redistribute it and/or modify it
-** under the terms of the GNU General Public License as published by the
-** Free Software Foundation; either version 2 of the License, or (at your
-** option) any later version.
-**
-** This program is distributed in the hope that it will be useful, but
-** WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** General Public License for more details.
-**
-** The GNU General Public License is available from http://www.gnu.org/ or
-** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-** MA 02111-1307, USA.
-**
-** For information on splint: info@splint.org
-** To report a bug: splint-bug@splint.org
-** For more information: http://www.splint.org
-*/
-
-/*
-** constraintOutput.c
-*/
-
-# include "splintMacros.nf"
-# include "basic.h"
-# include "portab.h"
-
-
-
quote_string (pfile, string);
return;
}
+ case T_FUNC: /* added in ISO C99 */
+ {
+ /* We don't know the actual name of the function, but it doesn't matter */
+ char *string = "** function-name **";
+ cpplib_reserve (pfile, 3 + 4 * strlen (string));
+ quote_string (pfile, string);
+ return;
+ }
case T_INCLUDE_LEVEL:
true_indepth = 0;
cpplib_installBuiltin ("__DATE__", ctype_string, -1, T_DATE, 0, NULL, -1);
cpplib_installBuiltin ("__FILE__", ctype_string, -1, T_FILE, 0, NULL, -1);
cpplib_installBuiltin ("__BASE_FILE__", ctype_string, -1, T_BASE_FILE, 0, NULL, -1);
+ cpplib_installBuiltin ("__func__", ctype_string, -1, T_FUNC, 0, NULL, -1);
cpplib_installBuiltin ("__INCLUDE_LEVEL__", ctype_int, -1, T_INCLUDE_LEVEL, 0, NULL, -1);
cpplib_installBuiltin ("__VERSION__", ctype_string, -1, T_VERSION, 0, NULL, -1);
#ifndef NO_BUILTIN_SIZE_TYPE
# include "cscannerHelp.h"
# include "cgrammar.h"
# include "cgrammar_tokens.h"
-# include "portab.h"
+# include "osd.h"
/*@notfunction@*/
# define yyinput() (incColumn (), getc (yyin))
# include "cscannerHelp.h"
# include "cscanner.h"
# include "cgrammar_tokens.h"
+# include "portab.h"
static int lminput (void);
static int s_tokLength = 0;
# include "llmain.h"
# include "portab.h"
+# ifdef WIN32
+# include <io.h>
+# else
# if defined(__IBMC__) && defined(OS2)
# include <process.h>
# include <io.h>
# define S_IWUSR S_IWRITE
# define S_IXUSR S_IEXEC
# endif
+# endif
/*@access fileId*/
FILE *fileTable_createFile (fileTable ft, cstring fname)
{
# ifdef WIN32
- int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL); /* not supported by VS.net: , S_IRUSR | S_IWUSR); */
+ int fdesc = _open (cstring_toCharsSafe (fname),
+ O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
+ _S_IWRITE | S_IREAD);
# else
- int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+ int fdesc = open (cstring_toCharsSafe (fname),
+ O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
+ S_IRUSR | S_IWUSR);
# endif
if (fdesc == -1)
FILE *fileTable_createMacrosFile (fileTable ft, cstring fname)
{
- int fdesc = open (cstring_toCharsSafe (fname), O_RDWR | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR);
+# ifdef WIN32
+ int fdesc = _open (cstring_toCharsSafe (fname),
+ O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
+ _S_IREAD | _S_IWRITE);
+# else
+ int fdesc = open (cstring_toCharsSafe (fname),
+ O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
+ S_IRUSR | S_IWUSR);
+# endif
if (fdesc == -1)
{
*/
/*
* Modified by Herbert 04/19/97:
- * - added new include file portab.h.
+ * - added new include file portab.h (now in osd.h)
* - added new private function fileloc_filenameForCpp() to handle
* filenames belonging to "#line" statements for OS/2 and MSDOS. It
* gets called by fileloc_lineMarker() and fileloc_previousLineMarker()
# include "splintMacros.nf"
# include "basic.h"
# include "osd.h"
-# include "portab.h"
static /*@only@*/ fileloc fileloc_createPrim (flkind p_kind, fileId p_fid, int p_line, int p_col) /*@*/ ;
# include "portab.h"
# include "rcfiles.h"
# include "lslinit.h"
+# include "llmain.h"
/*
** from the CC man page:
}
# ifdef WIN32
/* Make Microsoft VC++ happy */
-# pragma warning (disable:4715)
+# pragma warning (disable:4715)
# endif
}
# ifdef WIN32
-# pragma warning (enable:4715)
+/* # pragma warning (enable:4715) */
# endif
typedef struct {
FK_BOOL, FK_NONE, regStringFlag, ARG_STRING,
"boolfalse",
FLG_BOOLFALSE,
- "set name of boolean false (default FALSE)",
+ "set name of boolean false (default false)",
NULL, 0, 0
},
{
FK_BOOL, FK_NONE, regStringFlag, ARG_STRING,
"booltrue",
FLG_BOOLTRUE,
- "set name of boolean true (default TRUE)",
+ "set name of boolean true (default true)",
NULL, 0, 0
},
{
FK_BOOL, FK_OPS, modeFlag,
"boolcompare",
FLG_BOOLCOMPARE,
- "comparison between bools (dangerous because of multiple TRUE values)",
+ "comparison between bools (dangerous because of multiple true values)",
"Two bool values are compared directly using a C primitive. This "
"may produce unexpected results since all non-zero values are "
- "considered TRUE, so different TRUE values may not be equal. "
+ "considered true, so different true values may not be equal. "
"The file bool.h (included in splint/lib) provides bool_equal "
"for safe bool comparisons.", 0, 0
},
# include "splintMacros.nf"
# include "basic.h"
+
# undef malloc
# undef realloc
# undef calloc
# include "dmalloc.h"
# endif
-# include "portab.h"
+# include "osd.h"
/*
** redefine undef'd memory ops
/*@=mustdefine@*/
-char *FormatInt (int i)
-{
- char temp[255]; /* assume the integer has at most 254 digits */
- char *outs;
- int sres = snprintf (temp, 255, "%i", i);
- check (sres >= 0 && sres <= 255);
- outs = (char *) dmalloc (sizeof (*outs) * (1 + strlen (temp)));
- strcpy (outs, temp);
-
- return (outs);
-}
-
bool firstWord (char *s, char *w)
{
llassert (s != NULL);
# include "help.h"
# include "osd.h"
# include "portab.h"
+# include "llmain.h"
# include "version.h"
static void
# include "lslparse.h"
# include "lh.h"
# include "llmain.h"
-# include "portab.h"
void
outputLCSFile (char *path, char *msg, char *specname)
# include "lcllib.h"
# include "llmain.h"
-# include "portab.h"
/*@-incondefs@*/ /*@-redecl@*/
extern /*:open:*/ /*@dependent@*/ FILE *yyin;
# include "basic.h"
# include "osd.h"
# include "help.h"
-
# include "gram.h"
# include "lclscan.h"
# include "scanline.h"
# include "Headers/version.h" /* Visual C++ finds the wrong version.h */
# include "lcllib.h"
# include "cgrammar.h"
+# include "rcfiles.h"
# include "llmain.h"
-# include "portab.h"
-
extern /*@external@*/ int yydebug;
static void cleanupFiles (void);
ret = mstring_concatFree (ret, GETPRINTF ("%.2lf", va_arg (pvar, double)));
break;
case XBOOL:
- ret = mstring_concatFree1 (ret, cstring_toCharsSafe
- (bool_unparse (va_arg (pvar, bool))));
+ ret = mstring_concatFree1
+ (ret, cstring_toCharsSafe
+ (bool_unparse (bool_fromInt ((va_arg (pvar, int))))));
+ /* va_arg should not use bool type */
break;
case XUENTRY:
ret = mstring_concatFree (ret, cstring_toCharsSafe
# include "splintMacros.nf"
# include "basic.h"
# include "osd.h"
-# include "portab.h"
/* from stat.h */
/*@ignore@*/
# include "splintMacros.nf"
# include "basic.h"
+# ifdef WIN32
+/*
+** Make Microsoft VC++ happy: its control checking produces too
+** many spurious warnings.
+*/
+
+# pragma warning (disable:4715)
+# endif
+
static /*@observer@*/ cstring stateAction_unparse (stateAction p_sa) /*@*/ ;
void stateInfo_free (/*@only@*/ stateInfo a)
}
# ifdef WIN32
/* Make Microsoft VC++ happy */
-# pragma warning (disable:4715)
+# pragma warning (disable : 4715)
# endif
}
-# ifdef WIN32
-# pragma warning (enable:4715)
-# endif
-
ekind
uentry_getKind (uentry e)
{
llassert (uentry_isValid (e));
-
return (e->ukind);
}
case TK_UNION:
default:
{
- llfatalbug (message ("declareType ERROR: unknown kind: %q",
- cstring_fromCharsO (FormatInt ((int)t->kind))));
+ llfatalbug (message ("declareType: unknown kind: %d",
+ (int) t->kind));
}
}
}
preds.c:30:7: Use of == with bool variables (risks inconsistency because of
multiple true values): b1 == b2
Two bool values are compared directly using a C primitive. This may produce
- unexpected results since all non-zero values are considered TRUE, so
- different TRUE values may not be equal. The file bool.h (included in
+ unexpected results since all non-zero values are considered true, so
+ different true values may not be equal. The file bool.h (included in
splint/lib) provides bool_equal for safe bool comparisons. (Use -boolcompare
to inhibit warning)
preds.c:35:7: Test expression for if not bool, type char: c
preds.c:30:7: Use of == with bool variables (risks inconsistency because of
multiple true values): b1 == b2
Two bool values are compared directly using a C primitive. This may produce
- unexpected results since all non-zero values are considered TRUE, so
- different TRUE values may not be equal. The file bool.h (included in
+ unexpected results since all non-zero values are considered true, so
+ different true values may not be equal. The file bool.h (included in
splint/lib) provides bool_equal for safe bool comparisons. (Use -boolcompare
to inhibit warning)
preds.c:35:7: Test expression for if not bool, type char: c