Fix unportable uses of <ctype.h> functions. Per Sergey Koposov.
authorTom Lane <[email protected]>
Thu, 1 Sep 2005 15:34:31 +0000 (15:34 +0000)
committerTom Lane <[email protected]>
Thu, 1 Sep 2005 15:34:31 +0000 (15:34 +0000)
src/backend/commands/copy.c

index 64bd4ba3cc621e8e72f9f80aa121445326a74e14..e3ed6c3be1c2c160fc13770e28c0cf1158d585d0 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include "postgres.h"
 
+#include <ctype.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
@@ -2657,10 +2658,10 @@ CopyReadLineCSV(CopyState cstate)
 static int
 GetDecimalFromHex(char hex)
 {
-       if (isdigit(hex))
+       if (isdigit((unsigned char) hex))
                return hex - '0';
        else
-               return tolower(hex) - 'a' + 10;
+               return tolower((unsigned char) hex) - 'a' + 10;
 }
 
 /*
@@ -2802,7 +2803,7 @@ CopyReadAttributesText(CopyState cstate, int maxfields, char **fieldvals)
                                                {
                                                        char hexchar = *cur_ptr;
 
-                                                       if (isxdigit(hexchar))
+                                                       if (isxdigit((unsigned char) hexchar))
                                                        {
                                                                int val = GetDecimalFromHex(hexchar);
 
@@ -2810,7 +2811,7 @@ CopyReadAttributesText(CopyState cstate, int maxfields, char **fieldvals)
                                                                if (cur_ptr < line_end_ptr)
                                                                {
                                                                        hexchar = *cur_ptr;
-                                                                       if (isxdigit(hexchar))
+                                                                       if (isxdigit((unsigned char) hexchar))
                                                                        {
                                                                                cur_ptr++;
                                                                                val = (val << 4) + GetDecimalFromHex(hexchar);