1 |
ssuominen 10/02/24 12:49:01 |
2 |
|
3 |
Added: log4cxx-0.10.0-unixODBC.patch |
4 |
Log: |
5 |
Fix building with unixODBC wrt #254920, thanks to David Klempner for reporting. |
6 |
(Portage version: 2.2_rc63/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 dev-libs/log4cxx/files/log4cxx-0.10.0-unixODBC.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-libs/log4cxx/files/log4cxx-0.10.0-unixODBC.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-libs/log4cxx/files/log4cxx-0.10.0-unixODBC.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: log4cxx-0.10.0-unixODBC.patch |
15 |
=================================================================== |
16 |
http://issues.apache.org/jira/browse/LOGCXX-299 |
17 |
http://bugs.gentoo.org/show_bug.cgi?id=254920 |
18 |
|
19 |
diff -ur apache-log4cxx-0.10.0.orig/src/main/cpp/odbcappender.cpp apache-log4cxx-0.10.0/src/main/cpp/odbcappender.cpp |
20 |
--- apache-log4cxx-0.10.0.orig/src/main/cpp/odbcappender.cpp 2008-04-01 01:34:09.000000000 +0300 |
21 |
+++ apache-log4cxx-0.10.0/src/main/cpp/odbcappender.cpp 2010-02-24 14:39:37.000000000 +0200 |
22 |
@@ -167,7 +167,8 @@ |
23 |
throw SQLException( SQL_HANDLE_DBC, con, "Failed to allocate sql handle.", p); |
24 |
} |
25 |
|
26 |
- SQLWCHAR* wsql = Transcoder::wencode(sql, p); |
27 |
+ SQLWCHAR* wsql; |
28 |
+ encode(&wsql, sql, p); |
29 |
ret = SQLExecDirectW(stmt, wsql, SQL_NTS); |
30 |
|
31 |
if (ret < 0) |
32 |
@@ -237,9 +238,10 @@ |
33 |
} |
34 |
|
35 |
|
36 |
- SQLWCHAR* wURL = Transcoder::wencode(databaseURL, p); |
37 |
+ SQLWCHAR* wURL; |
38 |
+ encode(&wURL, databaseURL, p); |
39 |
|
40 |
- wchar_t szOutConnectionString[1024]; |
41 |
+ SQLWCHAR szOutConnectionString[1024]; |
42 |
SQLSMALLINT nOutConnctionLength = 0; |
43 |
|
44 |
ret = SQLDriverConnectW( connection, NULL, |
45 |
@@ -331,3 +333,31 @@ |
46 |
} |
47 |
} |
48 |
} |
49 |
+ |
50 |
+void ODBCAppender::encode(wchar_t** dest, const LogString& src, Pool& p) { |
51 |
+ *dest = Transcoder::wencode(src, p); |
52 |
+} |
53 |
+ |
54 |
+void ODBCAppender::encode(unsigned short** dest, |
55 |
+ const LogString& src, Pool& p) { |
56 |
+ // worst case double number of characters from UTF-8 or wchar_t |
57 |
+ *dest = (unsigned short*) |
58 |
+ p.palloc((src.size() + 1) * 2 * sizeof(unsigned short)); |
59 |
+ unsigned short* current = *dest; |
60 |
+ for(LogString::const_iterator i = src.begin(); |
61 |
+ i != src.end();) { |
62 |
+ unsigned int sv = Transcoder::decode(src, i); |
63 |
+ if (sv < 0x10000) { |
64 |
+ *current++ = (unsigned short) sv; |
65 |
+ } else { |
66 |
+ unsigned char u = (unsigned char) (sv >> 16); |
67 |
+ unsigned char w = (unsigned char) (u - 1); |
68 |
+ unsigned short hs = (0xD800 + ((w & 0xF) << 6) + ((sv & 0xFFFF) >> 10)); |
69 |
+ unsigned short ls = (0xDC00 + (sv && 0x3FF)); |
70 |
+ *current++ = (unsigned short) hs; |
71 |
+ *current++ = (unsigned short) ls; |
72 |
+ } |
73 |
+ } |
74 |
+ *current = 0; |
75 |
+} |
76 |
+ |
77 |
diff -ur apache-log4cxx-0.10.0.orig/src/main/include/log4cxx/db/odbcappender.h apache-log4cxx-0.10.0/src/main/include/log4cxx/db/odbcappender.h |
78 |
--- apache-log4cxx-0.10.0.orig/src/main/include/log4cxx/db/odbcappender.h 2008-04-01 01:34:09.000000000 +0300 |
79 |
+++ apache-log4cxx-0.10.0/src/main/include/log4cxx/db/odbcappender.h 2010-02-24 14:39:39.000000000 +0200 |
80 |
@@ -279,6 +279,10 @@ |
81 |
private: |
82 |
ODBCAppender(const ODBCAppender&); |
83 |
ODBCAppender& operator=(const ODBCAppender&); |
84 |
+ static void encode(wchar_t** dest, const LogString& src, |
85 |
+ log4cxx::helpers::Pool& p); |
86 |
+ static void encode(unsigned short** dest, const LogString& src, |
87 |
+ log4cxx::helpers::Pool& p); |
88 |
}; // class ODBCAppender |
89 |
LOG4CXX_PTR_DEF(ODBCAppender); |