Fossil

Check-in [d8c32ebdff]
Login

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

Overview
Comment:Fix the file_fullexename() function (used by the "info" and "test-which" commands) so that it works correctly on Windows.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d8c32ebdffcef75b0a9e5831da1c18f92021b09d8072594134a8857dd0690068
User & Date: drh 2021-07-01 19:27:46.831
References
2022-02-28
20:49
Since checkin [d8c32ebdff], file_fullexename() function is supported windows, remove comment saying otherwize. (no code change) check-in: 491b986d0d user: mgagnon tags: trunk
Context
2021-07-01
20:32
Add a note to the changelog about DROP support within tickets schema definition. check-in: f5b5991ee5 user: george tags: trunk
19:27
Fix the file_fullexename() function (used by the "info" and "test-which" commands) so that it works correctly on Windows. check-in: d8c32ebdff user: drh tags: trunk
18:54
Improvements to the on-line help for the "fossil all" command, and improvements to the change log. No changes to code. check-in: e39854ae51 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/file.c.
1296
1297
1298
1299
1300
1301
1302












































1303
1304
1305
1306
1307
1308
1309
** and should be freed by the caller.
**
** This routine only works on unix.  On Windows, simply return
** a copy of the input.
*/
char *file_fullexename(const char *zCmd){
#ifdef _WIN32












































  return fossil_strdup(zCmd);
#else
  char *zPath;
  char *z;
  if( zCmd[0]=='/' ){
    return fossil_strdup(zCmd);
  }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
** and should be freed by the caller.
**
** This routine only works on unix.  On Windows, simply return
** a copy of the input.
*/
char *file_fullexename(const char *zCmd){
#ifdef _WIN32
  char *zPath;
  char *z = 0;
  const char *zExe = "";
  if( sqlite3_strlike("%.exe",zCmd,0)!=0 ) zExe = ".exe";
  if( file_is_absolute_path(zCmd) ){
    return mprintf("%s%s", zCmd, zExe);
  }
  if( strchr(zCmd,'\\')!=0 && strchr(zCmd,'/')!=0 ){
    int i;
    Blob out = BLOB_INITIALIZER;
    file_canonical_name(zCmd, &out, 0);
    blob_append(&out, zExe, -1);
    z = fossil_strdup(blob_str(&out));
    blob_reset(&out);
    for(i=0; z[i]; i++){ if( z[i]=='/' ) z[i] = '\\'; }
    return z;
  }
  z = mprintf(".\\%s%s", zCmd, zExe);
  if( file_isfile(z, ExtFILE) ){
    int i;
    Blob out = BLOB_INITIALIZER;
    file_canonical_name(zCmd, &out, 0);
    blob_append(&out, zExe, -1);
    z = fossil_strdup(blob_str(&out));
    blob_reset(&out);
    for(i=0; z[i]; i++){ if( z[i]=='/' ) z[i] = '\\'; }
    return z;
  }
  fossil_free(z);
  zPath = fossil_getenv("PATH");
  while( zPath && zPath[0] ){
    int n;
    char *zColon;
    zColon = strchr(zPath, ';');
    n = zColon ? (int)(zColon-zPath) : (int)strlen(zPath);
    while( n>0 && zPath[n-1]=='\\' ){ n--; }
    z = mprintf("%.*s\\%s%s", n, zPath, zCmd, zExe);
    if( file_isfile(z, ExtFILE) ){
      return z;
    }
    fossil_free(z);
    if( zColon==0 ) break;
    zPath = zColon+1;
  }
  return fossil_strdup(zCmd);
#else
  char *zPath;
  char *z;
  if( zCmd[0]=='/' ){
    return fossil_strdup(zCmd);
  }