Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Translate decomposed-UTF8 filenames on MacOS into precomposed-UTF8. Fix for ticket [e399bc1edfe45b] |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | ticket-e399bc |
| Files: | files | file ages | folders |
| SHA1: |
1002e7238c5b94e60babfa87f2bc0605 |
| User & Date: | drh 2012-11-29 13:12:25.378 |
Context
|
2012-11-29
| ||
| 13:15 | Translate decomposed-UTF8 filenames on MacOS into precomposed-UTF8. Fix for ticket [e399bc1edfe45b] ... (check-in: ca728447a6 user: drh tags: trunk) | |
| 13:12 | Translate decomposed-UTF8 filenames on MacOS into precomposed-UTF8. Fix for ticket [e399bc1edfe45b] ... (Closed-Leaf check-in: 1002e7238c user: drh tags: ticket-e399bc) | |
| 09:59 | One more thing I spotted (but cannot test!): UTF8-mac encoded values could enter fossil through environment variables as well... ... (check-in: 42951c59ae user: jan.nijtmans tags: ticket-e399bc) | |
Changes
Changes to auto.def.
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
}
if {[opt-bool static]} {
# XXX: This will not work on all systems.
define-append EXTRA_LDFLAGS -static
}
| < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
}
if {[opt-bool static]} {
# XXX: This will not work on all systems.
define-append EXTRA_LDFLAGS -static
}
# Check for zlib, using the given location if specified
set zlibpath [opt-val with-zlib]
if {$zlibpath ne ""} {
cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
define-append EXTRA_CFLAGS -I$zlibpath
define-append EXTRA_LDFLAGS -L$zlibpath
}
|
| ︙ | ︙ | |||
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
cc-check-function-in-lib gethostbyname nsl
if {![cc-check-function-in-lib socket {socket network}]} {
# Last resort, may be Windows
if {[string match *mingw* [get-define host]]} {
define-append LIBS -lwsock32
}
}
# Check for getpassphrase() for Solaris 10 where getpass() truncates to 10 chars
if {![cc-check-functions getpassphrase]} {
# Haiku needs this
cc-check-function-in-lib getpass bsd
}
make-template Makefile.in
make-config-header autoconfig.h -auto {USE_* FOSSIL_*}
| > | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
cc-check-function-in-lib gethostbyname nsl
if {![cc-check-function-in-lib socket {socket network}]} {
# Last resort, may be Windows
if {[string match *mingw* [get-define host]]} {
define-append LIBS -lwsock32
}
}
cc-check-function-in-lib iconv iconv
# Check for getpassphrase() for Solaris 10 where getpass() truncates to 10 chars
if {![cc-check-functions getpassphrase]} {
# Haiku needs this
cc-check-function-in-lib getpass bsd
}
make-template Makefile.in
make-config-header autoconfig.h -auto {USE_* FOSSIL_*}
|
Changes to src/main.c.
| ︙ | ︙ | |||
2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 |
zStopperFile, zNotFound, flags);
}
#endif
}
/*
** COMMAND: test-echo
**
** Echo all command-line arguments (enclosed in [...]) to the screen so that
** wildcard expansion behavior of the host shell can be investigated.
*/
void test_echo_cmd(void){
| > > > > > | > | | > > > > > > > > > > > | 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 |
zStopperFile, zNotFound, flags);
}
#endif
}
/*
** COMMAND: test-echo
**
** Usage: %fossil test-echo [--hex] ARGS...
**
** Echo all command-line arguments (enclosed in [...]) to the screen so that
** wildcard expansion behavior of the host shell can be investigated.
**
** With the --hex option, show the output as hexadecimal. This can be used
** to verify the fossil_filename_to_utf8() routine on Windows and Mac.
*/
void test_echo_cmd(void){
int i, j;
if( find_option("hex",0,0)==0 ){
for(i=0; i<g.argc; i++){
fossil_print("argv[%d] = [%s]\n", i, g.argv[i]);
}
}else{
unsigned char *z, c;
for(i=0; i<g.argc; i++){
fossil_print("argv[%d] = [", i);
z = (unsigned char*)g.argv[i];
for(j=0; (c = z[j])!=0; j++){
fossil_print("%02x", c);
}
fossil_print("]\n");
}
}
}
|
Changes to src/utf8.c.
| ︙ | ︙ | |||
40 41 42 43 44 45 46 | #endif } /* ** After translating from UTF8 to MBCS, invoke this routine to deallocate ** any memory used to hold the translation */ | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
#endif
}
/*
** After translating from UTF8 to MBCS, invoke this routine to deallocate
** any memory used to hold the translation
*/
void fossil_mbcs_free(char *zOld){
#ifdef _WIN32
sqlite3_free(zOld);
#else
/* No-op on unix */
#endif
}
/*
** Translate Unicode text into UTF8.
** Return a pointer to the translated text.
** Call fossil_unicode_free() to deallocate any memory used to store the
** returned pointer when done.
*/
char *fossil_unicode_to_utf8(const char *zUnicode){
#ifdef _WIN32
int nByte = WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, 0, 0, 0, 0);
char *zUtf = sqlite3_malloc( nByte );
if( zUtf==0 ){
return 0;
}
WideCharToMultiByte(CP_UTF8, 0, zUnicode, -1, zUtf, nByte, 0, 0);
|
| ︙ | ︙ | |||
109 110 111 112 113 114 115 | /* ** Translate text from the filename character set into ** to precomposed UTF8. Return a pointer to the translated text. ** Call fossil_filename_free() to deallocate any memory used to store the ** returned pointer when done. */ | | > > > | > | | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
/*
** Translate text from the filename character set into
** to precomposed UTF8. Return a pointer to the translated text.
** Call fossil_filename_free() to deallocate any memory used to store the
** returned pointer when done.
*/
char *fossil_filename_to_utf8(const char *zFilename){
#if defined(_WIN32)
int nByte = WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, 0, 0, 0, 0);
char *zUtf = sqlite3_malloc( nByte );
if( zUtf==0 ){
return 0;
}
WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0);
return zUtf;
#elif defined(__APPLE__)
char *zOut;
iconv_t cd;
size_t n, x;
for(n=0; zFilename[n]>0 && zFilename[n]<=0x7f; n++){}
if( zFilename[n]!=0 && (cd = iconv_open("UTF-8", "UTF-8-MAC"))!=(iconv_t)-1 ){
char *zIn = (char*)zFilename;
char *zOutx;
size_t nIn, nOutx;
nIn = n = strlen(zFilename);
nOutx = nIn+100;
zOutx = zOut = fossil_malloc( nOutx+1 );
x = iconv(cd, &zIn, &nIn, &zOutx, &nOutx);
if( x==(size_t)-1 ){
fossil_free(zOut);
zOut = fossil_strdup(zFilename);
}else{
zOut[n+100-nOutx] = 0;
}
iconv_close(cd);
}else{
zOut = fossil_strdup(zFilename);
}
return zOut;
#else
|
| ︙ | ︙ |