]> andersk Git - splint.git/blobdiff - src/message.c
Making fixes for Microsoft Visual C++ compiler.
[splint.git] / src / message.c
index 53fe670a138d8d9f6703522c9e760073573c9e35..55129890f9a665e46f8170952097d2c0003412a3 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2000 University of Virginia,
+** 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
 ** 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 more information: http://lclint.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
 */
 /*
 ** message.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
  
 /* patch for linux? solaris? */
@@ -37,20 +37,26 @@ typedef enum
 {
   XINVALID, 
   XCHAR, XSTRING, XSTRINGFREE, XTSTRINGFREE, XINT, XFLOAT, XBOOL, XUENTRY,
-  XPERCENT, XCTYPE, XPLURAL, XREPREFIX, XFILELOC
+  XPERCENT, XCTYPE, XPLURAL, XREPREFIX, XFILELOC, XPOINTER
 } ccode;
 
-/* char *s, anytype v */
+/*@function void GETPRINTF (char *p_s, anytype p_v) modifies strbuf@*/
+
 /*@notfunction@*/
-# define GETPRINTF(s,v) (sprintf (strbuf, s, v), mstring_copy (strbuf))
+# ifndef WIN32
+  /* ISO requires this, but not all implementations (e.g., Microsoft's) provide it */
+# define GETPRINTF(s,v) (snprintf (strbuf, 64, s, v), mstring_copy (strbuf))
+# else
+  /* MS provides _snprintf instead */
+# define GETPRINTF(s,v) (_snprintf (strbuf, 64, s, v), mstring_copy (strbuf))
+# endif
 
 /*
 ** returns control code indicated by *c, and
 ** advances *c to next character.
 */
 
-static ccode
-  identify_control (char **s)
+static ccode identify_control (char **s)
 {
   char c;
 
@@ -64,7 +70,7 @@ static ccode
 
   if (c >= '0' && c <= '9')
     {
-      modcode = getInt (s);
+      modcode = reader_getInt (s);
     }
 
   c = **s;
@@ -100,9 +106,11 @@ static ccode
       return (XBOOL);
     case 't':
       return (XCTYPE);
+    case 'p':
+      return (XPOINTER);
     case 'l':
       return (XFILELOC);
-    case 'p':
+    case '&':
       return (XPLURAL);
     case 'r':
       return (XREPREFIX);
@@ -185,7 +193,7 @@ message (/*@temp@*/ char *fmt, ...)
                if (modcode != 0)
                  {
                    ret = mstring_concatFree (ret, cstring_toCharsSafe 
-                                         (cstring_fill (s, modcode)));
+                                             (cstring_fill (s, size_fromInt (modcode))));
                  }
                else
                  {
@@ -204,7 +212,7 @@ message (/*@temp@*/ char *fmt, ...)
                if (modcode != 0)
                  {
                    ret = mstring_concatFree (ret, cstring_toCharsSafe 
-                                             (cstring_fill (s, modcode)));
+                                             (cstring_fill (s, size_fromInt (modcode))));
                  }
                else
                  {
@@ -235,11 +243,13 @@ message (/*@temp@*/ char *fmt, ...)
              ret = mstring_concatFree (ret, GETPRINTF ("%d", lastint));
              break;
            case XFLOAT:
-             ret = mstring_concatFree (ret, GETPRINTF ("%e", va_arg (pvar, double)));
+             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 
@@ -250,6 +260,10 @@ message (/*@temp@*/ char *fmt, ...)
              ret = mstring_concatFree1 (ret, cstring_toCharsSafe 
                                   (ctype_unparse (va_arg (pvar, ctype)))); 
              break;
+           case XPOINTER:
+             ret = mstring_concatFree (ret, GETPRINTF ("%p", va_arg (pvar, void *)));
+             break;
+
            case XFILELOC:
              ret = mstring_concatFree (ret, cstring_toCharsSafe 
                                   (fileloc_unparse (va_arg (pvar, fileloc))));
This page took 0.043077 seconds and 4 git commands to generate.