Changeset: 839a24349c2b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=839a24349c2b
Modified Files:
MonetDB.spec
buildtools/autogen/autogen/msc.py
buildtools/doc/windowsbuild.rst
clients/mapilib/mapi.c
clients/odbc/driver/ODBCConvert.c
clients/odbc/driver/ODBCUtil.c
clients/odbc/driver/ODBCUtil.h
clients/odbc/driver/SQLError.c
clients/odbc/driver/SQLGetDescRec.c
clients/odbc/driver/SQLGetDiagField.c
clients/odbc/driver/SQLGetDiagRec.c
common/stream/stream.c
common/utils/msabaoth.c
configure.ag
gdk/gdk_atoms.c
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_exception.c
monetdb5/mal/mal_parser.c
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/color.c
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/url.c
monetdb5/modules/atoms/uuid.c
monetdb5/modules/mal/pcre.c
monetdb5/modules/mal/txtsim.c
sql/backends/monet5/sql_assert.c
sql/backends/monet5/sql_result.c
sql/server/sql_decimal.c
sql/server/sql_parser.y
tools/merovingian/daemon/config/monetdbd.in
tools/merovingian/utils/database.c
tools/merovingian/utils/properties.c
tools/merovingian/utils/utils.c
Branch: analytics
Log Message:
Merge with default.
diffs (truncated from 2040 to 300 lines):
diff --git a/buildtools/autogen/autogen/msc.py
b/buildtools/autogen/autogen/msc.py
--- a/buildtools/autogen/autogen/msc.py
+++ b/buildtools/autogen/autogen/msc.py
@@ -326,18 +326,16 @@ def msc_dep(fd, tar, deplist, msc):
fd.write(getsrc)
x, de = split_filename(deplist[0])
of = b + '.' + de
- of = msc_translate_file(of, msc)
fd.write('\t$(YACC) $(YFLAGS) $(AM_YFLAGS) "%s"\n' % of)
- if ext == "tab.c":
+ elif ext == "tab.c":
fd.write(getsrc)
x, de = split_filename(deplist[0])
of = b + '.' + de
- of = msc_translate_file(of, msc)
fd.write('\t$(YACC) $(YFLAGS) $(AM_YFLAGS) "%s"\n' % of)
- if ext == "yy.c":
+ elif ext == "yy.c":
fd.write(getsrc)
fd.write('\t$(LEX) $(LFLAGS) $(AM_LFLAGS) "%s.l"\n' % b)
- if ext in ("obj", "tab.obj", "yy.obj"):
+ elif ext in ("obj", "tab.obj", "yy.obj"):
target, name = msc_find_target(tar, msc)
if name[0] == '_':
name = name[1:]
@@ -346,7 +344,7 @@ def msc_dep(fd, tar, deplist, msc):
if dext in ("c", "cpp", "yy.c", "tab.c"):
fd.write('\t$(CC) /EHsc $(CFLAGS) $(%s_CFLAGS) $(GENDLL)
-D_CRT_SECURE_NO_WARNINGS -DLIB%s "-Fo%s" -c "%s"\n' %
(split_filename(msc_basename(src))[0], name, t, src))
- if ext == 'res':
+ elif ext == 'res':
fd.write("\t$(RC) -fo%s %s\n" % (t, src))
def msc_deps(fd, deps, objext, msc):
diff --git a/buildtools/doc/windowsbuild.rst b/buildtools/doc/windowsbuild.rst
--- a/buildtools/doc/windowsbuild.rst
+++ b/buildtools/doc/windowsbuild.rst
@@ -805,7 +805,7 @@ The contents of the file referred to wit
parameter may contain something like::
bits=32
- LIBPCRE=C:\Program Files\PCRE
+ LIBPCRE=C:\Program Files\PCRE
LIBICONV=C:\Libraries\iconv-1.11.win32
LIBZLIB=C:\Libraries\zlib-1.2.8.win32
LIBXML2=C:\Libraries\libxml2-2.9.2.win32
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1598,15 +1598,15 @@ add_error(struct MapiResultSet *result,
size_t size = result->errorstr ? strlen(result->errorstr) : 0;
if (strlen(error) > 6 && error[5] == '!' &&
- ((error[0] >= '0' && error[0] <= '9') ||
+ (isdigit((unsigned char) error[0]) ||
(error[0] >= 'A' && error[0] <= 'Z')) &&
- ((error[1] >= '0' && error[1] <= '9') ||
+ (isdigit((unsigned char) error[1]) ||
(error[1] >= 'A' && error[1] <= 'Z')) &&
- ((error[2] >= '0' && error[2] <= '9') ||
+ (isdigit((unsigned char) error[2]) ||
(error[2] >= 'A' && error[2] <= 'Z')) &&
- ((error[3] >= '0' && error[3] <= '9') ||
+ (isdigit((unsigned char) error[3]) ||
(error[3] >= 'A' && error[3] <= 'Z')) &&
- ((error[4] >= '0' && error[4] <= '9') ||
+ (isdigit((unsigned char) error[4]) ||
(error[4] >= 'A' && error[4] <= 'Z'))) {
if (result->errorstr == NULL) {
/* remeber SQLSTATE for first error */
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -88,7 +88,7 @@ parseint(const char *data, bignum_t *nva
while (*data && *data != 'e' && *data != 'E' && !space(*data)) {
if (*data == '.')
fraction = 1;
- else if ('0' <= *data && *data <= '9') {
+ else if (isdigit((unsigned char) *data)) {
if (overflow ||
nval->val > MAXBIGNUM10 ||
(nval->val == MAXBIGNUM10 &&
@@ -273,7 +273,7 @@ parsetime(const char *data, TIME_STRUCT
data += n;
n = 1; /* tentative return value */
if (*data == '.') {
- while (*++data && '0' <= *data && *data <= '9')
+ while (*++data && isdigit((unsigned char) *data))
;
n = 2; /* indicate loss of precision */
}
@@ -324,7 +324,7 @@ parsetimestamp(const char *data, TIMESTA
data += n;
n = 1000000000;
if (*data == '.') {
- while (*++data && '0' <= *data && *data <= '9') {
+ while (*++data && isdigit((unsigned char) *data)) {
n /= 10;
tsval->fraction += (*data - '0') * n;
}
@@ -800,7 +800,7 @@ parsesecondintervalstring(char **svalp,
sval++;
slen--;
secondprecision = 0;
- while ('0' <= *sval && *sval <= '9') {
+ while (isdigit((unsigned char) *sval)) {
if (secondprecision < 9) {
secondprecision++;
ival->intval.day_second.fraction *= 10;
@@ -1309,7 +1309,7 @@ ODBCFetch(ODBCStmt *stmt,
return SQL_NO_DATA;
}
for (k = 0; k < datalen; k++) {
- if ('0' <= data[k] && data[k] <= '9')
+ if (isdigit((unsigned char) data[k]))
n = data[k] - '0';
else if ('A' <= data[k] && data[k] <= 'F')
n = data[k] - 'A' + 10;
@@ -1873,7 +1873,8 @@ ODBCFetch(ODBCStmt *stmt,
if (type == SQL_C_WCHAR) {
SQLSMALLINT n;
- ODBCutf82wchar((SQLCHAR *) ptr, SQL_NTS, (SQLWCHAR *)
origptr, origbuflen, &n);
+ ODBCutf82wchar((SQLCHAR *) ptr, SQL_NTS,
+ (SQLWCHAR *) origptr, origbuflen, &n);
#ifdef ODBCDEBUG
ODBCLOG("Writing %d bytes to %p\n",
(int) (n * sizeof(SQLWCHAR)),
@@ -2765,7 +2766,7 @@ ODBCFetch(ODBCStmt *stmt,
}
data++;
}
- if ('0' <= *data && *data <= '9')
+ if (isdigit((unsigned char) *data))
((unsigned char *) ptr)[i] = *data - '0';
else if ('a' <= *data && *data <= 'f')
((unsigned char *) ptr)[i] = *data - 'a' + 10;
@@ -2779,7 +2780,7 @@ ODBCFetch(ODBCStmt *stmt,
}
((unsigned char *) ptr)[i] <<= 4;
data++;
- if ('0' <= *data && *data <= '9')
+ if (isdigit((unsigned char) *data))
((unsigned char *) ptr)[i] |= *data - '0';
else if ('a' <= *data && *data <= 'f')
((unsigned char *) ptr)[i] |= *data - 'a' + 10;
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -69,16 +69,6 @@ dupODBCstring(const SQLCHAR *inStr, size
return tmp;
}
-/* Conversion to and from SQLWCHAR */
-static int utf8chkmsk[] = {
- 0x0000007f,
- 0x00000780,
- 0x0000f800,
- 0x001f0000,
- 0x03e00000,
- 0x7c000000
-};
-
/* Convert a SQLWCHAR (UTF-16 encoded string) to UTF-8. On success,
clears the location pointed to by errmsg and returns NULL or a
newly allocated buffer. On error, assigns a string with an error
@@ -87,161 +77,225 @@ static int utf8chkmsk[] = {
ODBC fashion.
*/
SQLCHAR *
-ODBCwchar2utf8(const SQLWCHAR *s, SQLLEN length, char **errmsg)
+ODBCwchar2utf8(const SQLWCHAR *src, SQLLEN length, const char **errmsg)
{
- const SQLWCHAR *s1, *e;
- unsigned long c;
- SQLCHAR *buf, *p;
- int l, n;
+ size_t i = 0;
+ SQLLEN j = 0;
+ uint32_t c;
+ SQLCHAR *dest;
if (errmsg)
*errmsg = NULL;
- if (s == NULL)
+ if (src == NULL || length == SQL_NULL_DATA)
return NULL;
- if (length == SQL_NTS)
- for (s1 = s, length = 0; *s1; s1++)
- length++;
- else if (length == SQL_NULL_DATA)
- return NULL;
- else if (length < 0) {
+ if (length == SQL_NTS) {
+ /* a very large (positive) number that fits in SQLLEN */
+ length = (SQLLEN) (~(SQLULEN)0 >> 1);
+ } else if (length < 0) {
if (errmsg)
*errmsg = "Invalid length parameter";
return NULL;
}
- e = s + length;
- /* count necessary length */
- l = 1; /* space for NULL byte */
- for (s1 = s; s1 < e && *s1; s1++) {
- c = *s1;
- if (0xD800 <= c && c <= 0xDBFF) {
- /* high surrogate, must be followed by low surrogate */
- s1++;
- if (s1 >= e || *s1 < 0xDC00 || *s1 > 0xDFFF) {
+ while (j < length && src[j]) {
+ if (src[j] <= 0x7F) {
+ i += 1;
+ } else if (src[j] <= 0x7FF) {
+ i += 2;
+ } else if (
+#if SIZEOF_SQLWCHAR == 2
+ (src[j] & 0xFC00) != 0xD800
+#else
+ src[j] <= 0xFFFF
+#endif
+ ) {
+ if ((src[j] & 0xF800) == 0xD800) {
if (errmsg)
- *errmsg = "High surrogate not followed
by low surrogate";
+ *errmsg = "Illegal surrogate";
+ return NULL;
+ }
+ i += 3;
+ } else {
+#if SIZEOF_SQLWCHAR == 2
+ /* (src[j] & 0xFC00) == 0xD800, i.e. high surrogate */
+ if ((src[j+1] & 0xFC00) != 0xDC00) {
+ if (errmsg)
+ *errmsg = "Illegal surrogate";
+ return NULL;
+ }
+ j++;
+#else
+ c = src[j+0];
+ if (c > 0x10FFFF || (c & 0x1FF800) == 0xD800) {
+ if (errmsg)
+ *errmsg = "Illegal wide character
value";
return NULL;
}
- c = (((c & 0x03FF) << 10) | (*s1 & 0x3FF)) + 0x10000;
- } else if (0xDC00 <= c && c <= 0xDFFF) {
- /* low surrogate--illegal */
- if (errmsg)
- *errmsg = "Low surrogate not preceded by high
surrogate";
- return NULL;
+#endif
+ i += 4;
}
- for (n = 5; n > 0; n--)
- if (c & utf8chkmsk[n])
- break;
- l += n + 1;
- }
- /* convert */
- buf = (SQLCHAR *) malloc(l);
- if (buf == NULL) {
- if (errmsg)
- *errmsg = "Memory allocation error";
- return NULL;
+ j++;
}
- for (s1 = s, p = buf; s1 < e && *s1; s1++) {
- c = *s1;
- if (0xD800 <= c && c <= 0xDBFF) {
- /* high surrogate followed by low surrogate */
- s1++;
- c = (((c & 0x03FF) << 10) | (*s1 & 0x3FF)) + 0x10000;
+ length = j; /* figured out the real length (might not change) */
+ dest = malloc((i + 1) * sizeof(SQLCHAR));
+ if (dest == NULL)
+ return NULL;
+ i = 0;
+ j = 0;
+ while (j < length) {
+ if (src[j] <= 0x7F) {
+ dest[i++] = (SQLCHAR) src[j];
+ } else if (src[j] <= 0x7FF) {
+ dest[i++] = 0xC0 | (src[j] >> 6);
+ dest[i++] = 0x80 | (src[j] & 0x3F);
+ } else if (
+#if SIZEOF_SQLWCHAR == 2
+ (src[j] & 0xFC00) != 0xD800
+#else
+ src[j] <= 0xFFFF
+#endif
+ ) {
+ dest[i++] = 0xE0 | (src[j] >> 12);
+ dest[i++] = 0x80 | ((src[j] >> 6) & 0x3F);
+ dest[i++] = 0x80 | (src[j] & 0x3F);
+ } else {
+#if SIZEOF_SQLWCHAR == 2
+ c = ((src[j+0] & 0x03FF) + 0x40) << 10
+ | (src[j+1] & 0x03FF);
+ j++;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list