aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-07 00:24:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-07 00:24:59 +0000
commit0bd61548ab8d1ac5fee63f48ee9b384502a51ad6 (patch)
treeb0c63b75585d0c396e67a3acd204e226b13eae4b /src/include
parent4d46274b33db52618ccf49550213b4d5ce4a7981 (diff)
downloadpostgresql-0bd61548ab8d1ac5fee63f48ee9b384502a51ad6.tar.gz
postgresql-0bd61548ab8d1ac5fee63f48ee9b384502a51ad6.zip
Solve the 'Turkish problem' with undesirable locale behavior for case
conversion of basic ASCII letters. Remove all uses of strcasecmp and strncasecmp in favor of new functions pg_strcasecmp and pg_strncasecmp; remove most but not all direct uses of toupper and tolower in favor of pg_toupper and pg_tolower. These functions use the same notions of case folding already developed for identifier case conversion. I left the straight locale-based folding in place for situations where we are just manipulating user data and not trying to match it to built-in strings --- for example, the SQL upper() function is still locale dependent. Perhaps this will prove not to be what's wanted, but at the moment we can initdb and pass regression tests in Turkish locale.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/c.h6
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/port.h16
-rw-r--r--src/include/port/qnx4.h2
-rw-r--r--src/include/port/ultrix4.h3
-rw-r--r--src/include/regex/regcustom.h10
6 files changed, 17 insertions, 23 deletions
diff --git a/src/include/c.h b/src/include/c.h
index b3ee88968d0..d607677aa3f 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/c.h,v 1.163 2004/05/05 21:18:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.164 2004/05/07 00:24:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -720,10 +720,6 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#define memmove(d, s, c) bcopy(s, d, c)
#endif
-#ifndef HAVE_UNSETENV
-extern void unsetenv(const char *name);
-#endif
-
#ifndef DLLIMPORT
#define DLLIMPORT /* no special DLL markers on most ports */
#endif
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index aea533ad83f..e8158a678a3 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -385,9 +385,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
diff --git a/src/include/port.h b/src/include/port.h
index 4fb42bf74dd..2f5123483bf 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/port.h,v 1.27 2004/04/30 17:52:07 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.28 2004/05/07 00:24:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,6 +30,12 @@ extern char *get_progname(char *argv0);
/* Portable delay handling */
extern void pg_usleep(long microsec);
+/* Portable SQL-like case-independent comparisons and conversions */
+extern int pg_strcasecmp(const char *s1, const char *s2);
+extern int pg_strncasecmp(const char *s1, const char *s2, size_t n);
+extern unsigned char pg_toupper(unsigned char ch);
+extern unsigned char pg_tolower(unsigned char ch);
+
/* Portable prompt handling */
extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
@@ -130,10 +136,6 @@ extern double rint(double x);
extern int inet_aton(const char *cp, struct in_addr * addr);
#endif
-#ifndef HAVE_STRCASECMP
-extern int strcasecmp(char *s1, char *s2);
-#endif
-
#ifndef HAVE_STRDUP
extern char *strdup(char const *);
#endif
@@ -142,6 +144,10 @@ extern char *strdup(char const *);
extern long random(void);
#endif
+#ifndef HAVE_UNSETENV
+extern void unsetenv(const char *name);
+#endif
+
#ifndef HAVE_SRANDOM
extern void srandom(unsigned int seed);
#endif
diff --git a/src/include/port/qnx4.h b/src/include/port/qnx4.h
index 68deca4a1c3..94ae9a87c17 100644
--- a/src/include/port/qnx4.h
+++ b/src/include/port/qnx4.h
@@ -7,8 +7,6 @@
#undef HAVE_GETRUSAGE
-#define strncasecmp strnicmp
-
typedef u_short ushort;
extern int isnan(double dsrc);
diff --git a/src/include/port/ultrix4.h b/src/include/port/ultrix4.h
index 2dbbe6ceecd..4600dd36bd2 100644
--- a/src/include/port/ultrix4.h
+++ b/src/include/port/ultrix4.h
@@ -26,9 +26,6 @@
#include <sys/types.h> /* Declare various types, e.g. size_t,
* fd_set */
-extern int strcasecmp(const char *, const char *);
-extern void bzero(void *, size_t);
-
extern int fp_class_d(double);
extern long random(void);
diff --git a/src/include/regex/regcustom.h b/src/include/regex/regcustom.h
index 2d111f796be..9b0c691de03 100644
--- a/src/include/regex/regcustom.h
+++ b/src/include/regex/regcustom.h
@@ -25,7 +25,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/src/include/regex/regcustom.h,v 1.3 2003/11/29 22:41:10 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/regex/regcustom.h,v 1.4 2004/05/07 00:24:58 tgl Exp $
*/
/* headers if any */
@@ -59,10 +59,10 @@ typedef int celt; /* type to hold chr, MCCE number, or
#define CHR_MAX 0xfffffffe /* CHR_MAX-CHR_MIN+1 should fit in uchr */
/* functions operating on chr */
-#define iscalnum(x) pg_isalnum(x)
-#define iscalpha(x) pg_isalpha(x)
-#define iscdigit(x) pg_isdigit(x)
-#define iscspace(x) pg_isspace(x)
+#define iscalnum(x) pg_wc_isalnum(x)
+#define iscalpha(x) pg_wc_isalpha(x)
+#define iscdigit(x) pg_wc_isdigit(x)
+#define iscspace(x) pg_wc_isspace(x)
/* and pick up the standard header */
#include "regex.h"