You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2010/01/05 09:16:17 UTC
svn commit: r895934 - in /commons/sandbox/runtime/trunk/src/main/native:
Makefile.in Makefile.msc.in configure include/acr_port.h port/wcscasecmp.c
shared/string.c
Author: mturk
Date: Tue Jan 5 08:16:09 2010
New Revision: 895934
URL: http://svn.apache.org/viewvc?rev=895934&view=rev
Log:
Add wcs(n)casecmp to the port
Added:
commons/sandbox/runtime/trunk/src/main/native/port/wcscasecmp.c (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
commons/sandbox/runtime/trunk/src/main/native/configure
commons/sandbox/runtime/trunk/src/main/native/include/acr_port.h
commons/sandbox/runtime/trunk/src/main/native/shared/string.c
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=895934&r1=895933&r2=895934&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Tue Jan 5 08:16:09 2010
@@ -298,6 +298,7 @@
$(SRCDIR)/port/strlcpy.$(OBJ) \
$(SRCDIR)/port/wcslcat.$(OBJ) \
$(SRCDIR)/port/wcslcpy.$(OBJ) \
+ $(SRCDIR)/port/wcscasecmp.$(OBJ) \
$(SRCDIR)/port/strsignal.$(OBJ)
BZIP2_OBJS=\
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=895934&r1=895933&r2=895934&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Tue Jan 5 08:16:09 2010
@@ -177,6 +177,7 @@
$(SRCDIR)/port/strlcpy.$(OBJ) \
$(SRCDIR)/port/wcslcat.$(OBJ) \
$(SRCDIR)/port/wcslcpy.$(OBJ) \
+ $(SRCDIR)/port/wcscasecmp.$(OBJ) \
$(SRCDIR)/port/strsignal.$(OBJ)
BZIP2_OBJS=\
Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=895934&r1=895933&r2=895934&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Tue Jan 5 08:16:09 2010
@@ -851,9 +851,14 @@
have_function()
{
printf "Checking for %-32s" "$2" 1>&2
- if [ .$host = .windows -a .$1 != .w ]; then
- echo "not supported" 1>&2
- rc=0
+ if [ .$host = .windows ]; then
+ if [ .$1 = .w ]; then
+ echo ok 1>&2
+ rc=1
+ else
+ echo "not supported" 1>&2
+ rc=0
+ fi
elif [ .$1 = .c -a .$has_legacy_code = .yes ]; then
echo "not supported by legacy code" 1>&2
rc=0
@@ -1187,6 +1192,7 @@
#define HAVE_RESOLV_H `have_include x resolv`
#define HAVE_SYS_UN_H `have_include x sys/un`
#define HAVE_UCONTEXT_H `have_include x ucontext`
+#define HAVE_WCSCASECMP `have_function w wcscasecmp`
#define HAVE_STRERROR_R `have_function x strerror_r`
#define HAVE_MMAP64 `have_function x mmap64`
#define HAVE_POSIX_MEMALIGN `have_function x posix_memalign`
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_port.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_port.h?rev=895934&r1=895933&r2=895934&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_port.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_port.h Tue Jan 5 08:16:09 2010
@@ -140,5 +140,10 @@
int fdwalk(int (*func)(void *, int), void *);
#endif
+#if !HAVE_WCSCASECMP
+int wcscasecmp(const wchar_t *, const wchar_t *);
+int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
+#endif
+
#endif /* _ACR_PORT_H */
Added: commons/sandbox/runtime/trunk/src/main/native/port/wcscasecmp.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/port/wcscasecmp.c?rev=895934&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/port/wcscasecmp.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/port/wcscasecmp.c Tue Jan 5 08:16:09 2010
@@ -0,0 +1,75 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_port.h"
+
+#if defined(HAVE_WCSCASECMP)
+
+UNUSED_SOURCE_FILE(wcscasecmp);
+
+#else
+
+int wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+ int lc1 = 0;
+ int lc2 = 0;
+ int diff = 0;
+
+ while (n--) {
+ lc1 = towlower (*s1);
+ lc2 = towlower (*s2);
+
+ diff = lc1 - lc2;
+ if (diff)
+ return diff;
+
+ if (!lc1)
+ return 0;
+
+ ++s1;
+ ++s2;
+ }
+
+ return 0;
+}
+
+int wcscasecmp(const wchar_t *s1, const wchar_t *s2)
+{
+ int lc1 = 0;
+ int lc2 = 0;
+ int diff = 0;
+
+ for (;;) {
+ lc1 = towlower(*s1);
+ lc2 = towlower(*s2);
+
+ diff = lc1 - lc2;
+ if (diff)
+ return diff;
+
+ if (!lc1)
+ return 0;
+
+ ++s1;
+ ++s2;
+ }
+}
+
+#endif /* HAVE_WCSCASECMP */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/port/wcscasecmp.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=895934&r1=895933&r2=895934&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Tue Jan 5 08:16:09 2010
@@ -22,6 +22,7 @@
#include "acr_error.h"
#include "acr_types.h"
#include "acr_clazz.h"
+#include "acr_port.h"
#include "acr_vm.h"
extern int acr_native_codepage;
@@ -1988,14 +1989,8 @@
static int _wcscompare(const void *arg1, const void *arg2)
{
-#if defined(SOLARIS2)
- /* TODO: Implement wcsecasecmp
- */
- return wcscmp(*(wchar_t **)arg1, *(wchar_t **)arg2);
-#else
/* Compare all of both strings: */
return wcscasecmp(*(wchar_t **)arg1, *(wchar_t **)arg2);
-#endif
}
ACR_DECLARE(void) ACR_StrArraySortA(char ***args)