Fossil

Check-in [7d5c1bbd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix bug in utf8.c (don't translate first ':' in extended path). Add test-case (win32-longpath.test). Some formatting (don't use tabs).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | win32-longpath
Files: files | file ages | folders
SHA1:7d5c1bbd9c101347953a2b5f43f9a426d1b61027
User & Date: jan.nijtmans 2013-12-16 13:37:39
Context
2013-12-16
14:25
Better clean-up after win32-longpath test. Revert accidental change in Makefile.mingw. check-in: 698a2d59 user: jan.nijtmans tags: win32-longpath
13:37
Fix bug in utf8.c (don't translate first ':' in extended path). Add test-case (win32-longpath.test). Some formatting (don't use tabs). check-in: 7d5c1bbd user: jan.nijtmans tags: win32-longpath
10:57
Merge trunk. Eliminate need for special Makefile.Cygwin. Simplify handling of '\\?\' prefix: Only add it when necessary (calculated path>=260 chars). check-in: 23b849cc user: jan.nijtmans tags: win32-longpath
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqlite3.c.

35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
    }
    if( nChar>=SQLITE_WIN32_MAX_PATH_CHARS ){
      /* No Win32 API functions can handle such long paths. Let's see if
       * we can do something about it. If not, just leave it as is. */
      if( winIsDirSep(zFilename[0]) && winIsDirSep(zFilename[1])
          && zFilename[2]!='?' ){
        /* It's an UNC path, convert it to an extended UNC path. */
   	    zWideFilename = sqlite3MallocZero( (nChar+6)*sizeof(WCHAR) );
   	    if( !zWideFilename ){
          memcpy(zWideFilename, L"\\\\?\\UNC\\", 16);
          nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename+2, -1,
                                        zWideFilename+8, nChar);
   	    }
        return zWideFilename;
      }else if( winIsDriveLetterAndColon(zFilename)
          && winIsDirSep(zFilename[2]) ){
        /* It has a correct drive prefix, convert to extended form. */
   	    zWideFilename = sqlite3MallocZero( (nChar+4)*sizeof(WCHAR) );
   	    if( !zWideFilename ){
          memcpy(zWideFilename, L"\\\\?\\", 8);
          nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1,
                                        zWideFilename+4, nChar);
          zWideFilename[6] = '\\';
   	    }
        return zWideFilename;
      }
      /* Another form, e.g. relative path or maybe it already
       * has the '\\?\' prefix. Just leave it as-is. */
    }
    zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR) );
    if( zWideFilename==0 ){







|
|



|




|
|




|







35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
    }
    if( nChar>=SQLITE_WIN32_MAX_PATH_CHARS ){
      /* No Win32 API functions can handle such long paths. Let's see if
       * we can do something about it. If not, just leave it as is. */
      if( winIsDirSep(zFilename[0]) && winIsDirSep(zFilename[1])
          && zFilename[2]!='?' ){
        /* It's an UNC path, convert it to an extended UNC path. */
        zWideFilename = sqlite3MallocZero( (nChar+6)*sizeof(WCHAR) );
        if( zWideFilename ){
          memcpy(zWideFilename, L"\\\\?\\UNC\\", 16);
          nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename+2, -1,
                                        zWideFilename+8, nChar);
        }
        return zWideFilename;
      }else if( winIsDriveLetterAndColon(zFilename)
          && winIsDirSep(zFilename[2]) ){
        /* It has a correct drive prefix, convert to extended form. */
        zWideFilename = sqlite3MallocZero( (nChar+4)*sizeof(WCHAR) );
        if( zWideFilename ){
          memcpy(zWideFilename, L"\\\\?\\", 8);
          nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1,
                                        zWideFilename+4, nChar);
          zWideFilename[6] = '\\';
        }
        return zWideFilename;
      }
      /* Another form, e.g. relative path or maybe it already
       * has the '\\?\' prefix. Just leave it as-is. */
    }
    zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR) );
    if( zWideFilename==0 ){

Changes to src/utf8.c.

204
205
206
207
208
209
210
211




212
213
214
215

216
217
218
219
220
221
222
    /* Convert to extended path. */
    memcpy(zUnicode, L"\\\\?\\", 8);
    wUnicode += 4;
    MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar);
    wUnicode[2] = '\\';
    wUnicode += 3;
  }else if( (zUtf8[0]=='\\' || zUtf8[0]=='/') &&
      (zUtf8[1]=='\\' || zUtf8[1]=='/') && zUtf8[2]!='?' ) {




    /* Convert to extended UNC path. */
    memcpy(zUnicode, L"\\\\?\\UNC\\", 16);
    wUnicode += 8;
    MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, wUnicode, nChar);

  }else{
    MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar);
  }
  while( *wUnicode != '\0' ){
    if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){
      *wUnicode |= 0xF000;
    }else if( *wUnicode == '/' ){







|
>
>
>
>
|
|
|
|
>







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
    /* Convert to extended path. */
    memcpy(zUnicode, L"\\\\?\\", 8);
    wUnicode += 4;
    MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar);
    wUnicode[2] = '\\';
    wUnicode += 3;
  }else if( (zUtf8[0]=='\\' || zUtf8[0]=='/') &&
      (zUtf8[1]=='\\' || zUtf8[1]=='/') ) {
    if (zUtf8[2]=='?'){
      MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar);
      wUnicode+=6;
    }else{
      /* Convert to extended UNC path. */
      memcpy(zUnicode, L"\\\\?\\UNC\\", 16);
      wUnicode += 8;
      MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, wUnicode, nChar);
    }
  }else{
    MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar);
  }
  while( *wUnicode != '\0' ){
    if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){
      *wUnicode |= 0xF000;
    }else if( *wUnicode == '/' ){

Added test/win32-longpath.test.



































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# Tests for 'win32-longpath' VFS, using a repo path >260 chars.
#
# Actually, this test should pass on any platform.
#

# Fossil will write data on $HOME, running 'fossil new' here.
# We need not to clutter the $HOME of the test caller.
#
set env(HOME) [pwd]

# Create the repo
#
set x [string repeat x 132]
set longpath [pwd]/$x
file mkdir $longpath
catch {
  # Use "cygpath" for converting it to win32 path. If not
  # in Msys or Cygwin shell, nothing needs to be done.
  set longpath [exec cygpath -w $longpath]
}

test longpath-test.1 {
  ![catch {
    fossil new $longpath/$x.fossil
  }]
}

catch {
    # If file deletion fails because your shell cannot
    # handle that, you need to clean it up manually
    exec "rm -rf [pwd]/$x"
}