[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Is --enable-utf8 working everywhere?

From: Branko Čibej <brane_at_xbc.nu>
Date: 2002-07-17 03:50:01 CEST

Right. Here's the patch that adds support for apr_xlate_* on Win32. I'd
like to get some feedback and independent testing before I check this in.
For APR:

    * cd to the top of the APR sources
    * unzip apr-winiconv.zip (new dirs and files there)
    * apply apr-winiconv.patch

For Apache:

    * cd to the top of the httpd-2.0 sources
    * apply httpd-winiconv.patch to Makefile.win (this is just so that
      iconv.dll gets installed in Apache's bin directory).

To enable the apr_xlate_* stuff, drop the libiconv sources into
i18n/win32/libiconv (I'm testing this with libiconv-1.8), and rebuild
APR/httpd/whatever.

Karl, about the file name conversions in Subversion: remember what I
said about APR using UTF-8 file names directly on some platforms? Well,
the conversions in SVN should probably be coded like this:

    char *utf8_filename = (something);
    char *native_filename;
  #ifdef WIN32
  # if APR_HAS_UNICODE_FS
    IF_WIN_OS_IS_UNICODE
    {
      native_filename = utf8_filename;
    }
  # endif
  # if APR_HAS_ANSI_FS
    ELSE_WIN_OS_IS_ANSI
    {
      native_filename = convert_utf8_to_locale_charset(utf8_filename);
    }
  # endif
  #else /* !WIN32 */
    native_filename = convert_utf8_to_locale_charset(utf8_filename);
  #endif /* !WIN32 */

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/

Index: apr.dsp
===================================================================
RCS file: /home/cvs/apr/apr.dsp,v
retrieving revision 1.107
diff -u -p -r1.107 apr.dsp
--- apr.dsp 11 Jul 2002 15:32:17 -0000 1.107
+++ apr.dsp 17 Jul 2002 00:46:12 -0000
@@ -41,7 +41,7 @@ RSC=rc.exe
 # PROP Intermediate_Dir "LibR"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibR\apr" /FD /c
+# ADD CPP /nologo /MD /W3 /O2 /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /I "./i18n/win32/libiconv/include" /D "NDEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibR\apr" /FD /c
 # ADD BASE RSC /l 0x409
 # ADD RSC /l 0x409
 BSC32=bscmake.exe
@@ -65,7 +65,7 @@ LIB32=link.exe -lib
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MDd /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibD\apr" /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /I "./i18n/win32/libiconv/include" /D "_DEBUG" /D "APR_DECLARE_STATIC" /D "WIN32" /D "_WINDOWS" /Fd"LibD\apr" /FD /c
 # ADD BASE RSC /l 0x409
 # ADD RSC /l 0x409
 BSC32=bscmake.exe
@@ -157,6 +157,35 @@ SOURCE=.\file_io\win32\seek.c
 # PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=.\i18n\win32\libiconv.c
+
+!IF "$(CFG)" == "apr - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Building iconv.lib
+InputPath=.\i18n\win32\libiconv.c
+
+".\LibR\iconv.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genlib librel
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "apr - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Building iconv.lib
+InputPath=.\i18n\win32\libiconv.c
+
+".\LibD\iconv.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genlib libdbg
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
 SOURCE=.\i18n\unix\utf8_ucs2.c
 # End Source File
 # Begin Source File
@@ -470,6 +499,7 @@ SOURCE=.\include\apr.hw
 
 !IF "$(CFG)" == "apr - Win32 Release"
 
+USERDEP__APR_H=".\include\apr_config_iconv.h"
 # Begin Custom Build - Creating apr.h from apr.hw
 InputPath=.\include\apr.hw
 
@@ -480,6 +510,7 @@ InputPath=.\include\apr.hw
 
 !ELSEIF "$(CFG)" == "apr - Win32 Debug"
 
+USERDEP__APR_H=".\include\apr_config_iconv.h"
 # Begin Custom Build - Creating apr.h from apr.hw
 InputPath=.\include\apr.hw
 
@@ -494,6 +525,33 @@ InputPath=.\include\apr.hw
 # Begin Source File
 
 SOURCE=.\include\apr_compat.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\apr_config_iconv.hw
+
+!IF "$(CFG)" == "apr - Win32 Release"
+
+# Begin Custom Build - Creating apr_config_iconv.h from apr_config_iconv.hw
+InputPath=.\include\apr_config_iconv.hw
+
+".\include\apr_config_iconv.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genhdr
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "apr - Win32 Debug"
+
+# Begin Custom Build - Creating apr_config_iconv.h from apr_config_iconv.hw
+InputPath=.\include\apr_config_iconv.hw
+
+".\include\apr_config_iconv.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genhdr
+
+# End Custom Build
+
+!ENDIF
+
 # End Source File
 # Begin Source File
 
Index: libapr.dsp
===================================================================
RCS file: /home/cvs/apr/libapr.dsp,v
retrieving revision 1.68
diff -u -p -r1.68 libapr.dsp
--- libapr.dsp 11 Jul 2002 15:32:17 -0000 1.68
+++ libapr.dsp 17 Jul 2002 00:46:12 -0000
@@ -43,7 +43,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Release\apr" /FD /c
+# ADD CPP /nologo /MD /W3 /O2 /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /I "./i18n/win32/libiconv/include" /D "NDEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Release\apr" /FD /c
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -69,7 +69,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MDd /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Debug\apr" /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "./include" /I "./include/arch" /I "./include/arch/win32" /I "./include/arch/unix" /I "./i18n/win32/libiconv/include" /D "_DEBUG" /D "APR_DECLARE_EXPORT" /D "WIN32" /D "_WINDOWS" /Fd"Debug\apr" /FD /c
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -163,6 +163,35 @@ SOURCE=.\file_io\win32\seek.c
 # PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=.\i18n\win32\libiconv.c
+
+!IF "$(CFG)" == "libapr - Win32 Release"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Building iconv.lib and iconv.dll
+InputPath=.\i18n\win32\libiconv.c
+
+".\Release\iconv.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genlib dllrel
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "libapr - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+# Begin Custom Build - Building iconv.lib and iconv.dll
+InputPath=.\i18n\win32\libiconv.c
+
+".\Debug\iconv.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genlib dlldbg
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
 SOURCE=.\i18n\unix\utf8_ucs2.c
 # End Source File
 # Begin Source File
@@ -476,6 +505,7 @@ SOURCE=.\include\apr.hw
 
 !IF "$(CFG)" == "libapr - Win32 Release"
 
+USERDEP__APR_H=".\include\apr_config_iconv.h"
 # Begin Custom Build - Creating apr.h from apr.hw
 InputPath=.\include\apr.hw
 
@@ -486,6 +516,7 @@ InputPath=.\include\apr.hw
 
 !ELSEIF "$(CFG)" == "libapr - Win32 Debug"
 
+USERDEP__APR_H=".\include\apr_config_iconv.h"
 # Begin Custom Build - Creating apr.h from apr.hw
 InputPath=.\include\apr.hw
 
@@ -500,6 +531,33 @@ InputPath=.\include\apr.hw
 # Begin Source File
 
 SOURCE=.\include\apr_compat.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\apr_config_iconv.hw
+
+!IF "$(CFG)" == "libapr - Win32 Release"
+
+# Begin Custom Build - Creating apr_config_iconv.h from apr_config_iconv.hw
+InputPath=.\include\apr_config_iconv.hw
+
+".\include\apr_config_iconv.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genhdr
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "libapr - Win32 Debug"
+
+# Begin Custom Build - Creating apr_config_iconv.h from apr_config_iconv.hw
+InputPath=.\include\arch\win32\apr_config_iconv.hw
+
+".\include\apr_config_iconv.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ call .\build\win32iconv.bat genhdr
+
+# End Custom Build
+
+!ENDIF
+
 # End Source File
 # Begin Source File
 
Index: i18n/unix/xlate.c
===================================================================
RCS file: /home/cvs/apr/i18n/unix/xlate.c,v
retrieving revision 1.28
diff -u -p -r1.28 xlate.c
--- i18n/unix/xlate.c 15 Jul 2002 19:21:01 -0000 1.28
+++ i18n/unix/xlate.c 17 Jul 2002 00:46:12 -0000
@@ -146,9 +146,21 @@ static const char *get_default_charset(v
  * defer to get_default_charset().
  */
 
-static const char *get_locale_charset(void)
+static const char *get_locale_charset(apr_pool_t *pool)
 {
-#if defined(HAVE_NL_LANGINFO) && defined(HAVE_CODESET)
+#ifdef WIN32
+ /* ### Yes, this is a hack and doesn't belong in this file.
+ Will fix soonest. --brane */
+ LCID locale = GetThreadLocale();
+ int len = GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0);
+ char *cp = apr_palloc(pool, len + 2);
+ if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, cp + 2, len))
+ {
+ cp[0] = 'C';
+ cp[1] = 'P';
+ return cp;
+ }
+#elif defined(HAVE_NL_LANGINFO) && defined(HAVE_CODESET)
     const char *charset;
     charset = nl_langinfo(CODESET);
     if (charset) {
@@ -158,13 +170,13 @@ static const char *get_locale_charset(vo
     return get_default_charset();
 }
 
-static const char *handle_special_names(const char *page)
+static const char *handle_special_names(const char *page, apr_pool_t *pool)
 {
     if (page == APR_DEFAULT_CHARSET) {
         return get_default_charset();
     }
     else if (page == APR_LOCALE_CHARSET) {
- return get_locale_charset();
+ return get_locale_charset(pool);
     }
     else {
         return page;
@@ -227,8 +239,10 @@ static void make_identity_table(apr_xlat
       convset->sbcs_table[i] = i;
 }
 
-apr_status_t apr_xlate_open(apr_xlate_t **convset, const char *topage,
- const char *frompage, apr_pool_t *pool)
+APR_DECLARE(apr_status_t) apr_xlate_open(apr_xlate_t **convset,
+ const char *topage,
+ const char *frompage,
+ apr_pool_t *pool)
 {
     apr_status_t status;
     apr_xlate_t *new;
@@ -236,8 +250,8 @@ apr_status_t apr_xlate_open(apr_xlate_t
 
     *convset = NULL;
 
- topage = handle_special_names(topage);
- frompage = handle_special_names(frompage);
+ topage = handle_special_names(topage, pool);
+ frompage = handle_special_names(frompage, pool);
     
     new = (apr_xlate_t *)apr_pcalloc(pool, sizeof(apr_xlate_t));
     if (!new) {
@@ -291,15 +305,17 @@ apr_status_t apr_xlate_open(apr_xlate_t
     return status;
 }
 
-apr_status_t apr_xlate_sb_get(apr_xlate_t *convset, int *onoff)
+APR_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff)
 {
     *onoff = convset->sbcs_table != NULL;
     return APR_SUCCESS;
 }
 
-apr_status_t apr_xlate_conv_buffer(apr_xlate_t *convset, const char *inbuf,
- apr_size_t *inbytes_left, char *outbuf,
- apr_size_t *outbytes_left)
+APR_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset,
+ const char *inbuf,
+ apr_size_t *inbytes_left,
+ char *outbuf,
+ apr_size_t *outbytes_left)
 {
     apr_status_t status = APR_SUCCESS;
 #ifdef HAVE_ICONV
@@ -360,7 +376,8 @@ apr_status_t apr_xlate_conv_buffer(apr_x
     return status;
 }
 
-apr_int32_t apr_xlate_conv_byte(apr_xlate_t *convset, unsigned char inchar)
+APR_DECLARE(apr_int32_t) apr_xlate_conv_byte(apr_xlate_t *convset,
+ unsigned char inchar)
 {
     if (convset->sbcs_table) {
         return convset->sbcs_table[inchar];
@@ -370,7 +387,7 @@ apr_int32_t apr_xlate_conv_byte(apr_xlat
     }
 }
 
-apr_status_t apr_xlate_close(apr_xlate_t *convset)
+APR_DECLARE(apr_status_t) apr_xlate_close(apr_xlate_t *convset)
 {
     return apr_pool_cleanup_run(convset->pool, convset, apr_xlate_cleanup);
 }
Index: include/apr.hw
===================================================================
RCS file: /home/cvs/apr/include/apr.hw,v
retrieving revision 1.95
diff -u -p -r1.95 apr.hw
--- include/apr.hw 8 Jul 2002 17:30:56 -0000 1.95
+++ include/apr.hw 17 Jul 2002 00:46:14 -0000
@@ -280,7 +280,6 @@ extern "C" {
 #define APR_HAS_MMAP 1
 #define APR_HAS_FORK 0
 #define APR_HAS_RANDOM 1
-#define APR_HAS_XLATE 0
 #define APR_HAS_OTHER_CHILD 1
 #define APR_HAS_DSO 1
 #define APR_HAS_SO_ACCEPTFILTER 0
@@ -444,6 +443,9 @@ struct iovec {
 #if defined(_MSC_VER) && _MSC_VER >= 1200
 #pragma warning(pop)
 #endif
+
+/* libiconv/apr_xlate stuff */
+#include "apr_config_iconv.h"
 
 #endif /* APR_H */
 
Index: include/arch/win32/apr_private.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/apr_private.h,v
retrieving revision 1.31
diff -u -p -r1.31 apr_private.h
--- include/arch/win32/apr_private.h 13 Mar 2002 20:39:19 -0000 1.31
+++ include/arch/win32/apr_private.h 17 Jul 2002 00:46:14 -0000
@@ -177,5 +177,11 @@ APR_DECLARE_DATA int errno;
 #define ENOSPC 1
 #endif
 
+
+#define APR_WIN32_CONFIG_ICONV_PRIVATE
+#include "apr_config_iconv.h"
+#undef APR_WIN32_CONFIG_ICONV_PRIVATE
+
+
 #endif /*APR_PRIVATE_H*/
 #endif /*WIN32*/

Index: Makefile.win
===================================================================
RCS file: /home/cvspublic/httpd-2.0/Makefile.win,v
retrieving revision 1.108
diff -u -p -r1.108 Makefile.win
--- Makefile.win 13 Jul 2002 06:01:10 -0000 1.108
+++ Makefile.win 17 Jul 2002 00:49:26 -0000
@@ -351,6 +351,7 @@ _install:
         copy $(LONG)\Apache.exe "$(INSTDIR)\bin" <.y
         copy $(LONG)\libhttpd.dll "$(INSTDIR)\bin" <.y
         copy srclib\apr\$(LONG)\libapr.dll "$(INSTDIR)\bin" <.y
+ copy srclib\apr\$(LONG)\iconv.dll "$(INSTDIR)\bin" <.y
         copy srclib\apr-util\$(LONG)\libaprutil.dll "$(INSTDIR)\bin" <.y
         copy modules\aaa\$(LONG)\mod_access.so "$(INSTDIR)\modules" <.y
         copy modules\aaa\$(LONG)\mod_auth.so "$(INSTDIR)\modules" <.y

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Wed Jul 17 03:50:48 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.