]> andersk Git - splint.git/blobdiff - src/nameChecks.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / nameChecks.c
index df19ab01a450ad8ffcf3cb8a1a248ce4426a9f90..20e8fa5245eb9c978dce80829dbcf04ca5472f3f 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
 */
 /*
 ** nameChecks.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "nameChecks.h"
 
 static bool checkCzechName (uentry p_ue, flagcode p_czechflag, bool p_report)
-  /*@modifies p_ue, g_msgstream@*/ ;
+  /*@modifies p_ue, g_warningstream@*/ ;
 
 static bool checkSlovakName (uentry p_ue, flagcode p_slovakflag, bool p_report)
-  /*@modifies p_ue, g_msgstream@*/ ;
+  /*@modifies p_ue, g_warningstream@*/ ;
 
 static cstring czechPrefix (cstring name)
 {
@@ -42,7 +42,7 @@ static cstring czechPrefix (cstring name)
 
 static cstring slovakPrefix (cstring name)
 {
-  int i = 0;
+  size_t i = 0;
 
   cstring_chars (name, c)
     {
@@ -119,9 +119,9 @@ static bool matchPrefix (cstring name, cstring prefix)
     }
   else
     {
-      int namelen = cstring_length (name);
+      size_t namelen = cstring_length (name);
       int last = (int) '\0';
-      int n = 1;
+      size_t n = 1;
 
       cstring_chars (prefix, pc)
        {
@@ -131,7 +131,6 @@ static bool matchPrefix (cstring name, cstring prefix)
            {
              n++;
 
-             
              while (n <= namelen)
                {
                  nc = (int) cstring_getChar (name, n);
@@ -140,6 +139,7 @@ static bool matchPrefix (cstring name, cstring prefix)
                    {
                      return FALSE;
                    }
+
                  n++;
                }
 
@@ -149,7 +149,8 @@ static bool matchPrefix (cstring name, cstring prefix)
            {
              if (n > namelen)
                {
-                 if ((cstring_length (prefix) >= n + 1)
+                 if (namelen > 1
+                     && (cstring_length (prefix) >= n + 1)
                      && cstring_getChar (prefix, n + 1) == '*')
                    {
                      return TRUE;
@@ -238,7 +239,7 @@ namespaceName (flagcode flag) /*@*/
     }
 }
 
-void 
+void
 checkPrefix (uentry ue)
 {
   cstring name = cstring_undefined;
@@ -264,7 +265,7 @@ checkPrefix (uentry ue)
     {
       flag = FLG_FILESTATICPREFIX;
     }
-  else if (uentry_isGlobal (ue))
+  else if (uentry_isGlobalVariable (ue))
     {
       flag = FLG_GLOBPREFIX;
     }
@@ -335,13 +336,14 @@ checkPrefix (uentry ue)
 
   if (context_getFlag (flag))
     {
-      name = uentry_getName (ue);
-      
+      name = uentry_observeRealName (ue);
       
       if (!matchPrefix (name, context_getString (flag)))
        {
-         if (optgenerror
-             (flag,
+         llassert (flag != FLG_NAMECHECKS);
+
+         if (optgenerror2
+             (flag, FLG_NAMECHECKS,
               message ("%s %s name is not consistent with %s "
                        "namespace prefix \"%s\"",
                        uentry_ekindName (ue),
@@ -413,13 +415,13 @@ checkPrefix (uentry ue)
                {
                  if (cstring_isUndefined (name))
                    {
-                     name = uentry_getName (ue);
+                     name = uentry_observeRealName (ue);
                    }
                  
                  if (matchPrefix (name, context_getString (rcode)))
                    {
-                     if (optgenerror
-                         (code,
+                     if (optgenerror2
+                         (code, FLG_NAMECHECKS,
                           message
                           ("%s %s name is not a %s (it is a %s), "
                            "but matches the %s "
@@ -439,8 +441,6 @@ checkPrefix (uentry ue)
            }
        } 
     } end_excludeFlagCodes ;
-
-  cstring_free (name);
 }
 
 static void
@@ -468,7 +468,7 @@ checkNationalName (uentry ue)
     }
   else if (uentry_isVariable (ue))
     {
-      if (uentry_isGlobal (ue) && context_getFlag (FLG_GLOBPREFIX))
+      if (uentry_isGlobalVariable (ue) && context_getFlag (FLG_GLOBPREFIX))
        {
          /* prefix checks supercede national naming checks */
          return;
@@ -480,7 +480,7 @@ checkNationalName (uentry ue)
     }
   else if (uentry_isConstant (ue))
     {
-      if (uentry_isGlobal (ue) && context_getFlag (FLG_CONSTPREFIX))
+      if (uentry_isGlobalVariable (ue) && context_getFlag (FLG_CONSTPREFIX))
        {
          /* prefix checks supercede national naming checks */
          return;
@@ -532,8 +532,8 @@ checkNationalName (uentry ue)
            {
              if (isupper ((unsigned char) c))
                {
-                 if (optgenerror
-                     (FLG_CZECHOSLOVAKTYPES,
+                 if (optgenerror2
+                     (FLG_CZECHOSLOVAKTYPES, FLG_NAMECHECKS,
                       message
                       ("%s %q name violates Czechoslovak naming convention.  "
                        "Czechoslovak datatype names should not use uppercase "
@@ -549,8 +549,8 @@ checkNationalName (uentry ue)
 
              if (c == '_' && charno != 2 && charno != 3)
                {
-                 if (optgenerror
-                     (FLG_CZECHOSLOVAKTYPES,
+                 if (optgenerror2
+                     (FLG_CZECHOSLOVAKTYPES, FLG_NAMECHECKS,
                       message ("%s %q name violates Czechoslovak naming "
                                "convention.  Czechoslovak datatype names "
                                "should not use the _ charater.",
@@ -575,8 +575,8 @@ checkNationalName (uentry ue)
          
          if (!okay)
            {
-             if (optgenerror
-                 (czechoslovakflag,
+             if (optgenerror2
+                 (czechoslovakflag, FLG_NAMECHECKS,
                   message ("%s %q name is not consistent with Czechoslovak "
                            "naming convention.",
                            uentry_ekindName (ue),
@@ -608,8 +608,8 @@ static bool checkCzechName (uentry ue, flagcode czechflag, bool report)
            {
              if (report)
                {
-                 if (optgenerror
-                     (FLG_CZECHTYPES,
+                 if (optgenerror2
+                     (FLG_CZECHTYPES, FLG_NAMECHECKS,
                       message 
                       ("%s %q name violates Czech naming convention.  "
                        "Czech datatype names should not use the _ charater.",
@@ -643,8 +643,8 @@ static bool checkCzechName (uentry ue, flagcode czechflag, bool report)
                {
                  if (report)
                    {
-                     if (optgenerror
-                         (czechflag,
+                     if (optgenerror2
+                         (czechflag, FLG_NAMECHECKS,
                           message ("%s %q name is not consistent with Czech "
                                    "naming convention.  The name should "
                                    "begin with %s_",
@@ -671,8 +671,8 @@ static bool checkCzechName (uentry ue, flagcode czechflag, bool report)
                {
                  if (report)
                    {
-                     if (optgenerror
-                         (czechflag,
+                     if (optgenerror2
+                         (czechflag, FLG_NAMECHECKS,
                           message ("%s %q name is not consistent with Czech "
                                    "naming convention.  Accessible types: %q",
                                    uentry_ekindName (ue),
@@ -747,7 +747,7 @@ static bool checkCzechName (uentry ue, flagcode czechflag, bool report)
                        }
                    }
                }
-             else if (ctype_isBool (ct))
+             else if (ctype_isManifestBool (ct))
                {
                  if (context_canAccessBool ())
                    {
@@ -819,8 +819,8 @@ static bool checkCzechName (uentry ue, flagcode czechflag, bool report)
                    {
                      if (report)
                        {
-                         if (optgenerror
-                             (czechflag,
+                         if (optgenerror2
+                             (czechflag, FLG_NAMECHECKS,
                               message 
                               ("%s %q name violates Czech naming convention.  "
                                "Czech prefix %s is not the name of a type.",
@@ -863,8 +863,8 @@ static bool checkSlovakName (uentry ue, flagcode slovakflag, bool report)
                {
                  if (report)
                    {
-                     if (optgenerror
-                         (FLG_SLOVAKTYPES,
+                     if (optgenerror2
+                         (FLG_SLOVAKTYPES, FLG_NAMECHECKS,
                           message 
                           ("%s %q name violates Slovak naming convention.  "
                            "Slovak datatype names should not use uppercase "
@@ -898,8 +898,8 @@ static bool checkSlovakName (uentry ue, flagcode slovakflag, bool report)
                {
                  if (report)
                    {
-                     if (optgenerror
-                         (slovakflag,
+                     if (optgenerror2
+                         (slovakflag, FLG_NAMECHECKS,
                           message ("%s %q name is not consistent with Slovak "
                                    "naming convention.  Accessible types: %q",
                                    uentry_ekindName (ue),
@@ -922,8 +922,8 @@ static bool checkSlovakName (uentry ue, flagcode slovakflag, bool report)
                    {
                      if (report)
                        {
-                         if (optgenerror
-                             (slovakflag,
+                         if (optgenerror2
+                             (slovakflag, FLG_NAMECHECKS,
                               message ("%s %q name is not consistent with "
                                        "Slovak naming convention.  The "
                                        "name should begin with %s followed "
@@ -995,7 +995,7 @@ static bool checkSlovakName (uentry ue, flagcode slovakflag, bool report)
                        }
                    }
                }
-             else if (ctype_isBool (ct))
+             else if (ctype_isManifestBool (ct))
                {
                  if (context_canAccessBool ())
                    {
@@ -1067,8 +1067,8 @@ static bool checkSlovakName (uentry ue, flagcode slovakflag, bool report)
                    {
                      if (report)
                        {
-                         if (optgenerror
-                             (slovakflag,
+                         if (optgenerror2
+                             (slovakflag, FLG_NAMECHECKS,
                               message 
                               ("%s %q name violates Slovak naming convention.  "
                                "Slovak prefix %s is not the name of a type.",
@@ -1095,7 +1095,7 @@ static bool checkSlovakName (uentry ue, flagcode slovakflag, bool report)
 }
 
 void
-checkGlobalName (uentry ue)
+checkExternalName (uentry ue)
 {
   if (!uentry_isStatic (ue) && uentry_hasName (ue))
     {
@@ -1110,7 +1110,23 @@ checkGlobalName (uentry ue)
 void
 checkLocalName (/*@unused@*/ uentry ue)
 {
-  ;
+  /*
+  ** No local checks (yet)
+  */
+
+  return;
+}
+
+void
+checkFileScopeName (/*@unused@*/ uentry ue)
+{
+  /*
+  ** No file scope checks (yet)
+  */
+
+  /* add a file scope naming convention policy? */
+
+  return;
 }
 
 /*
@@ -1126,12 +1142,15 @@ checkLocalName (/*@unused@*/ uentry ue)
 /*@constant int NCPPNAMES@*/
 # define NCPPNAMES 39
 
-bool checkCppName (cstring name, fileloc loc)
+void
+checkCppName (uentry ue)
 {
+  cstring name = uentry_observeRealName (ue);
+
   static ob_mstring cppNames[NCPPNAMES] =
     {
       "and", "and_eq", "asm", 
-      "bitand", "bitor", "bool", /* gasp: "bool", is special for lclint */
+      "bitand", "bitor", "bool", /* gasp: "bool", is special for splint */
       "catch", "class", "compl", "const_class",
       "delete", "dynamic_cast", "false", "friend",
       "inline", "mutable", "namespace", "new",
@@ -1146,21 +1165,23 @@ bool checkCppName (cstring name, fileloc loc)
   if (cstring_isDefined (cstring_bsearch (name, &cppNames[0],
                                          NCPPNAMES)))
     {
-      return (optgenerror
-             (FLG_CPPNAMES,
-              message ("Name %s is a keyword or reserved word in C++",
-                       name),
-              loc));
+      if (optgenerror2
+         (FLG_CPPNAMES, FLG_NAMECHECKS,
+          message ("Name %s is a keyword or reserved word in C++",
+                   name),
+          uentry_whereLast (ue)))
+       {
+         uentry_setHasNameError (ue);
+       }
     }
-
-  return FALSE;
 }
 
-bool
-checkAnsiName (cstring name, fileloc loc)
+void
+checkAnsiName (uentry ue)
 {
   bool hasError = FALSE;
-  int length = cstring_length (name);
+  cstring name = uentry_observeRealName (ue);
+  size_t length = cstring_length (name);
   char fchar = (length >= 1) ? cstring_firstChar (name) : '\0';
   char schar = (length >= 2) ? cstring_secondChar (name) : '\0';
   char tchar = (length >= 3) ? cstring_getChar (name, 3) : '\0';
@@ -1178,12 +1199,11 @@ checkAnsiName (cstring name, fileloc loc)
 # include "reservedNames.nf"
     } ;
 
-  if (fileloc_isSystemFile (loc) || fileloc_isBuiltin (loc))
-    {
-      return FALSE;  /* no errors for system files */
-    }
-
 # if 0
+  /*
+  ** This code is for checking reservedNames.nf
+  */
+
   {
     int i = 0;
     char *lastname = NULL;
@@ -1201,26 +1221,56 @@ checkAnsiName (cstring name, fileloc loc)
     nreservedNames = i - 1;
   }
 # endif
+
+  if (fileloc_isSystemFile (uentry_whereLast (ue)) || fileloc_isBuiltin (uentry_whereLast (ue)))
+    {
+      return;  /* no errors for system files */
+    }
   
   if (cstring_isDefined (cstring_bsearch (name, &reservedNames[0],
                                          NRESERVEDNAMES)))
     {
-      return (optgenerror
-             (FLG_ANSIRESERVED,
-              message ("Name %s is reserved for the standard library",
-                       name),
-              loc));
+      hasError |= optgenerror2
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
+        message ("Name %s is reserved for the standard library",
+                 name),
+        uentry_whereLast (ue));
     }
 
-  if (fchar == '_')
+  if (uentry_isFileStatic (ue) || uentry_isVisibleExternally (ue) || uentry_isAnyTag (ue)
+      || context_getFlag (FLG_ISORESERVEDLOCAL))
     {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
-        message 
-        ("Name %s is in the implementation name space (any identifier "
-         "beginning with underscore)", 
-         name),
-        loc);
+      if (fchar == '_')
+       {
+         hasError |= optgenerror2
+           (FLG_ISORESERVED, FLG_NAMECHECKS,
+            message 
+            ("Name %s is in the implementation name space (any identifier "
+             "beginning with underscore)", 
+             name),
+            uentry_whereLast (ue));
+       }
+    }
+  else
+    {
+      /*
+      ** ISO 7.1.3:
+      ** - All identifiers that begin with an underscore and either an uppercase
+      ** letter or another underscore are always reserved for any use.
+      */
+      
+      if (fchar == '_' 
+         && (schar == '_' || isupper ((int) schar)))
+       {
+         hasError |= optgenerror2
+           (FLG_ISORESERVED, FLG_NAMECHECKS,
+            message 
+            ("Name %s is in the implementation name space (any identifier "
+             "beginning with underscore and either an uppercase letter or "
+             "another underscore is always reserved for any use)", 
+             name),
+            uentry_whereLast (ue));
+       }
     }
 
   /*
@@ -1228,181 +1278,230 @@ checkAnsiName (cstring name, fileloc loc)
   **
   ** Macros that begin with E and a digit or E and an uppercase letter ...
   */
-
-  else if (fchar == 'E' && (isdigit ((int) schar) 
-                           || isupper ((int) schar)))
+  
+  if (fchar == 'E' && (isdigit ((int) schar) 
+                      || isupper ((int) schar)))
     {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
+      hasError |= optgenerror2
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message 
-        ("Name %s is reserved for future ANSI library extensions. "
+        ("Name %s is reserved for future library extensions. "
          "Macros beginning with E and a digit or uppercase letter "
-         "may be added to <errno.h>. (See ANSI, Section 4.13.1)",
+         "may be added to <errno.h>. (ISO99:7.26.3)",
          name),
-        loc);
+        uentry_whereLast (ue));
     }
-  
-  /*
-  ** 4.13.2 Character Handling <ctype.h>
-  **
-  ** Function names that begin with either "is" or "to" and a lowercase letter ...
-  */
 
-  else if (((fchar == 'i' && schar == 's') 
-           || (fchar == 't' && schar == 'o'))
-          && (islower ((int) tchar)))
-    {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
-        message
-        ("Name %s is reserved for future ANSI library extensions.  "
-         "Functions beginning with \"is\" or \"to\" and a lowercase "
-         "letter may be added to <ctype.h>. (See ANSI, Section 4.13.2)",
-         name),
-        loc);
-    }
-  
   /*
   ** 4.13.3 Localization <locale.h>
   **
   ** Macros that begin with LC_ and an uppercase letter ...
   */
-
-  else if (length >= 4 
-          && ((fchar == 'L')
-              && (schar == 'C')
-              && (tchar == '_'))
-          && (isupper ((int) rchar)))
+  
+  if (length >= 4 
+      && ((fchar == 'L')
+         && (schar == 'C')
+         && (tchar == '_'))
+      && (isupper ((int) rchar)))
     {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
+      hasError |= optgenerror2
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message
-        ("Name %s is reserved for future ANSI library extensions.  "
+        ("Name %s is reserved for future library extensions.  "
          "Macros beginning with \"LC_\" and an uppercase letter may "
-         "be added to <locale.h>. (See ANSI, Section 4.13.3)",
+         "be added to <locale.h>. (ISO99:7.26.5)",
          name),
-        loc);
+        uentry_whereLast (ue));
     }
-  
-  /*
-  ** 4.13.4 Mathematics <math.h>
-  **
-  ** The names of all existing functions declared in the <math.h> header, 
-  ** suffixed with f or l...
-  */
 
-  else if ((cstring_lastChar (name) == 'f' || cstring_lastChar (name) == 'l')
-          && 
-          (((length == 4)
-            && ((cstring_equalPrefix (name, "cos") ||
-                 cstring_equalPrefix (name, "sin") ||
-                 cstring_equalPrefix (name, "tan") ||
-                 cstring_equalPrefix (name, "exp") ||
-                 cstring_equalPrefix (name, "log") ||
-                 cstring_equalPrefix (name, "pow"))))
-           || ((length == 5)
-               && ((cstring_equalPrefix (name, "acos") ||
-                    cstring_equalPrefix (name, "asin") ||
-                    cstring_equalPrefix (name, "atan") ||
-                    cstring_equalPrefix (name, "cosh") ||
-                    cstring_equalPrefix (name, "sinh") ||
-                    cstring_equalPrefix (name, "sqrt") ||
-                    cstring_equalPrefix (name, "ceil") ||
-                    cstring_equalPrefix (name, "fabs") ||
-                    cstring_equalPrefix (name, "fmod") ||
-                    cstring_equalPrefix (name, "tanh") ||
-                    cstring_equalPrefix (name, "modf"))))
-           || ((length == 6)
-               && ((cstring_equalPrefix (name, "atan2") ||
-                    cstring_equalPrefix (name, "floor") ||
-                    cstring_equalPrefix (name, "frexp") ||
-                    cstring_equalPrefix (name, "ldexp") ||
-                    cstring_equalPrefix (name, "log10"))))))
-    {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
-        message
-        ("Name %s is reserved for future ANSI library extensions.  "
-         "The names of all existing functions in <math.h> suffixed "
-         "with 'f' or 'l' may be added to <math.h>. (See ANSI, Section 4.13.4)",
-         name),
-        loc);
-    }
-  
   /*
   ** 4.13.5 Signal Handling <signal.h>
   **
   ** Macros that begin with either SIG or SIG_ and an uppercase letter or...
   */
-
-  else if (fchar == 'S' && schar == 'I' && tchar == 'G'
+  
+  if (fchar == 'S' && schar == 'I' && tchar == 'G'
           && ((rchar == '_' && ((length >= 5 
                                  && isupper ((int) cstring_getChar (name, 5)))))
               || (isupper ((int) rchar))))
     {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
+      hasError |= optgenerror2
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message
-        ("Name %s is reserved for future ANSI library extensions.  "
+        ("Name %s is reserved for future library extensions.  "
          "Macros that begin with SIG and an uppercase letter or SIG_ "
          "and an uppercase letter may be added to "
-         "<signal.h>. (See ANSI, Section 4.13.5)",
+         "<signal.h>. (ISO99:7.14)",
          name),
-        loc);
+        uentry_whereLast (ue));
     }
-  
-  /*
-  ** 4.13.6 Input/Output <stdio.h>
-  **
-  ** (nothing to check)
-  */
 
   /*
-  ** 4.13.7 General Utilities <stdlib.h>
-  **
-  ** Functions names that begin with str and a lowercase letter may be added to <stdlib.h>.
+  ** evans - 2002-12-16: added this check (even though it is not required by ISO)
   */
 
-  else if (fchar == 's' && schar == 't' && tchar == 'r' 
-          && (islower ((int) rchar)))
+  if (fchar == 'S' && schar == 'A' && tchar == '_')
     {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
-        message
-        ("Name %s is reserved for future ANSI library extensions.  "
-         "Functions that begin with \"str\" and a lowercase letter "
-         "may be added to <stdlib.h> or <string.h>. (See ANSI, Section 4.13.7)",
+      hasError |= optgenerror2
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
+        message 
+        ("Name %s may be defined as a macro by Linux library. "
+         "It is not research by the ISO specification, but may produce conflicts on some systems.",
          name),
-        loc);
+        uentry_whereLast (ue));
     }
-  
-  /*
-  ** 4.13.8 String Handling <string.h>
-  **
-  ** Function names that begin with str, mem, or wcs and a lowercase letter ...
-  **
-  ** (Note: already checked "str" above.)
-  */
 
-  else if (((fchar == 'm' && schar == 'e' && tchar == 'm')
-           || (fchar == 'w' && schar == 'c' && tchar == 's'))
-          && (islower ((int) rchar)))
+  if ((uentry_isVisibleExternally (ue) && !uentry_isAnyTag (ue))
+      || context_getFlag (FLG_ISORESERVEDLOCAL))
     {
-      hasError = optgenerror
-       (FLG_ANSIRESERVED,
-        message
-        ("Name %s is reserved for future ANSI library extensions.  "
-         "Functions that begin with \"mem\" or \"wcs\" and a "
-         "lowercase letter letter may be added to <string.h>. (See ANSI, Section 4.13.8)",
-         name),
-        loc);
+      flagcode flg;
+
+      DPRINTF (("Okay...: %s", uentry_unparse (ue)));
+
+      if (uentry_isVisibleExternally (ue) && !uentry_isAnyTag (ue))
+       {
+         flg = FLG_ISORESERVED;
+       }
+      else
+       {
+         flg = FLG_ISORESERVEDLOCAL;
+       }
+
+      DPRINTF (("ue: %s", uentry_unparseFull (ue)));
+
+      /*
+      ** These restrictions only apply to identifiers with global linkage.
+      */
+
+      /*
+      ** 4.13.2 Character Handling <ctype.h>
+      **
+      ** Function names that begin with either "is" or "to" and a lowercase letter ...
+      */
+      
+      if (((fchar == 'i' && schar == 's') 
+          || (fchar == 't' && schar == 'o'))
+         && (islower ((int) tchar)))
+       {
+         hasError |= optgenerror2
+           (flg, FLG_NAMECHECKS,
+            message
+            ("Name %s is reserved for future library extensions.  "
+             "Functions beginning with \"is\" or \"to\" and a lowercase "
+             "letter may be added to <ctype.h>. (ISO99:7.26.2)",
+             name),
+            uentry_whereLast (ue));
+
+         DPRINTF (("Externally visible: %s / %s",
+                   uentry_unparseFull (ue),
+                   bool_unparse (uentry_isVisibleExternally (ue))));
+       }
+      
+      
+      /*
+      ** 4.13.4 Mathematics <math.h>
+      **
+      ** The names of all existing functions declared in the <math.h> header, 
+      ** suffixed with f or l...
+      */
+
+      DPRINTF (("Check name: %s", name));
+
+      if ((cstring_lastChar (name) == 'f' || cstring_lastChar (name) == 'l')
+         && 
+         (((length == 4)
+           && ((cstring_equalPrefixLit (name, "cos") ||
+                cstring_equalPrefixLit (name, "sin") ||
+                cstring_equalPrefixLit (name, "tan") ||
+                cstring_equalPrefixLit (name, "exp") ||
+                cstring_equalPrefixLit (name, "log") ||
+                cstring_equalPrefixLit (name, "pow"))))
+          || ((length == 5)
+              && ((cstring_equalPrefixLit (name, "acos") ||
+                   cstring_equalPrefixLit (name, "asin") ||
+                   cstring_equalPrefixLit (name, "atan") ||
+                   cstring_equalPrefixLit (name, "cosh") ||
+                   cstring_equalPrefixLit (name, "sinh") ||
+                   cstring_equalPrefixLit (name, "sqrt") ||
+                   cstring_equalPrefixLit (name, "ceil") ||
+                   cstring_equalPrefixLit (name, "fabs") ||
+                   cstring_equalPrefixLit (name, "fmod") ||
+                   cstring_equalPrefixLit (name, "tanh") ||
+                   cstring_equalPrefixLit (name, "modf"))))
+          || ((length == 6)
+              && ((cstring_equalPrefixLit (name, "atan2") ||
+                   cstring_equalPrefixLit (name, "floor") ||
+                   cstring_equalPrefixLit (name, "frexp") ||
+                   cstring_equalPrefixLit (name, "ldexp") ||
+                   cstring_equalPrefixLit (name, "log10"))))))
+       {
+         hasError |= optgenerror2
+           (flg, FLG_NAMECHECKS,
+            message
+            ("Name %s is reserved for future library extensions.  "
+             "The names of all existing functions in <math.h> suffixed "
+             "with 'f' or 'l' may be added to <math.h>. (ISO:7.26.1)",
+             name),
+            uentry_whereLast (ue));
+       }
+      
+      /*
+      ** 4.13.6 Input/Output <stdio.h>
+      **
+      ** (nothing to check)
+      */
+      
+      /*
+      ** 4.13.7 General Utilities <stdlib.h>
+      **
+      ** Functions names that begin with str and a lowercase letter may be added to <stdlib.h>.
+      */
+      
+      if (fchar == 's' && schar == 't' && tchar == 'r' 
+         && (islower ((int) rchar)))
+       {
+         hasError |= optgenerror2
+           (flg, FLG_NAMECHECKS,
+            message
+            ("Name %s is reserved for future library extensions.  "
+             "Functions that begin with \"str\" and a lowercase letter "
+             "may be added to <stdlib.h> or <string.h>. (ISO99:7.26.9)",
+             name),
+            uentry_whereLast (ue));
+       }
+      
+      /*
+      ** 4.13.8 String Handling <string.h>
+      **
+      ** Function names that begin with str, mem, or wcs and a lowercase letter ...
+      **
+      ** (Note: already checked "str" above.)
+      */
+      
+      if (((fchar == 'm' && schar == 'e' && tchar == 'm')
+          || (fchar == 'w' && schar == 'c' && tchar == 's'))
+         && (islower ((int) rchar)))
+       {
+         hasError |= optgenerror2
+           (flg, FLG_NAMECHECKS,
+            message
+            ("Name %s is reserved for future library extensions.  "
+             "Functions that begin with \"mem\" or \"wcs\" and a "
+             "lowercase letter letter may be added to <string.h>. (ISO:7.26.11)",
+             name),
+            uentry_whereLast (ue));
+       }
     }
   else
     {
-      ;
+      DPRINTF (("Not checked: [%s] %s", bool_unparse (uentry_isVisibleExternally (ue)),
+               uentry_unparseFull (ue)));
     }
 
-  return hasError;
+  if (hasError)
+    {
+      uentry_setHasNameError (ue);
+    }
 }
 
 void checkParamNames (uentry ue)
@@ -1422,8 +1521,8 @@ void checkParamNames (uentry ue)
            {
              if (noformal && !cstring_isDefined (fpfx))
                {
-                 if (optgenerror
-                     (FLG_DECLPARAMNAME, 
+                 if (optgenerror2
+                     (FLG_DECLPARAMNAME, FLG_NAMECHECKS,
                       message ("Declaration parameter has name: %q",
                                uentry_getName (p)),
                       uentry_whereLast (p)))
@@ -1433,14 +1532,14 @@ void checkParamNames (uentry ue)
                }
              else
                {
-                 cstring pname = uentry_getName (p);
+                 cstring pname = uentry_observeRealName (p);
                  
-                 if (!cstring_equalPrefix (pname, cstring_toCharsSafe (fpfx)))
+                 if (!cstring_equalPrefix (pname, fpfx))
                    {
                      if (context_getFlag (FLG_NAMECHECKS))
                        {
-                         if (optgenerror
-                             (FLG_DECLPARAMPREFIX, 
+                         if (optgenerror2
+                             (FLG_DECLPARAMPREFIX, FLG_NAMECHECKS,
                               message ("Declaration parameter name %s does not begin "
                                        "with protoparamprefix (%s)",
                                        pname, fpfx),
@@ -1450,13 +1549,10 @@ void checkParamNames (uentry ue)
                            }
                        }
                    }
-                 cstring_free (pname);
                }
            }
        } end_uentryList_elements ;
     }
 }
 
-
-
-
+/* not yet checked: POSIX p. 527 - applications should not declare any symbols that end _MAX */
This page took 0.62311 seconds and 4 git commands to generate.