Fossil SCM

In file_tree_name, since the file name argument is converted to its canonical form prior to the memcmp, the local root must be as well. On Windows, normalize drive letters to uppercase when converting a file name to its canonical form and fix construction of temporary file names used with the gdiff command when the --from and --to options are present.

mistachkin 2012-03-19 04:48 UTC trunk
Commit 6be0898b2ce7a6c7f81c1ea229e806f4bb164b01
+3
--- src/blob.c
+++ src/blob.c
@@ -90,10 +90,13 @@
9090
int fossil_isupper(char c){ return c>='A' && c<='Z'; }
9191
int fossil_isdigit(char c){ return c>='0' && c<='9'; }
9292
int fossil_tolower(char c){
9393
return fossil_isupper(c) ? c - 'A' + 'a' : c;
9494
}
95
+int fossil_toupper(char c){
96
+ return fossil_islower(c) ? c - 'a' + 'A' : c;
97
+}
9598
int fossil_isalpha(char c){
9699
return (c>='a' && c<='z') || (c>='A' && c<='Z');
97100
}
98101
int fossil_isalnum(char c){
99102
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
100103
--- src/blob.c
+++ src/blob.c
@@ -90,10 +90,13 @@
90 int fossil_isupper(char c){ return c>='A' && c<='Z'; }
91 int fossil_isdigit(char c){ return c>='0' && c<='9'; }
92 int fossil_tolower(char c){
93 return fossil_isupper(c) ? c - 'A' + 'a' : c;
94 }
 
 
 
95 int fossil_isalpha(char c){
96 return (c>='a' && c<='z') || (c>='A' && c<='Z');
97 }
98 int fossil_isalnum(char c){
99 return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
100
--- src/blob.c
+++ src/blob.c
@@ -90,10 +90,13 @@
90 int fossil_isupper(char c){ return c>='A' && c<='Z'; }
91 int fossil_isdigit(char c){ return c>='0' && c<='9'; }
92 int fossil_tolower(char c){
93 return fossil_isupper(c) ? c - 'A' + 'a' : c;
94 }
95 int fossil_toupper(char c){
96 return fossil_islower(c) ? c - 'a' + 'A' : c;
97 }
98 int fossil_isalpha(char c){
99 return (c>='a' && c<='z') || (c>='A' && c<='Z');
100 }
101 int fossil_isalnum(char c){
102 return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
103
+4 -1
--- src/db.c
+++ src/db.c
@@ -1706,15 +1706,18 @@
17061706
"INSERT OR IGNORE INTO global_config(name,value)"
17071707
"VALUES('repo:%q',1)",
17081708
blob_str(&full)
17091709
);
17101710
if( g.localOpen && g.zLocalRoot && g.zLocalRoot[0] ){
1711
+ Blob localRoot;
1712
+ file_canonical_name(g.zLocalRoot, &localRoot);
17111713
db_multi_exec(
17121714
"REPLACE INTO global_config(name, value)"
17131715
"VALUES('ckout:%q','%q');",
1714
- g.zLocalRoot, blob_str(&full)
1716
+ blob_str(&localRoot), blob_str(&full)
17151717
);
1718
+ blob_reset(&localRoot);
17161719
}
17171720
db_swap_connections();
17181721
blob_reset(&full);
17191722
}
17201723
17211724
--- src/db.c
+++ src/db.c
@@ -1706,15 +1706,18 @@
1706 "INSERT OR IGNORE INTO global_config(name,value)"
1707 "VALUES('repo:%q',1)",
1708 blob_str(&full)
1709 );
1710 if( g.localOpen && g.zLocalRoot && g.zLocalRoot[0] ){
 
 
1711 db_multi_exec(
1712 "REPLACE INTO global_config(name, value)"
1713 "VALUES('ckout:%q','%q');",
1714 g.zLocalRoot, blob_str(&full)
1715 );
 
1716 }
1717 db_swap_connections();
1718 blob_reset(&full);
1719 }
1720
1721
--- src/db.c
+++ src/db.c
@@ -1706,15 +1706,18 @@
1706 "INSERT OR IGNORE INTO global_config(name,value)"
1707 "VALUES('repo:%q',1)",
1708 blob_str(&full)
1709 );
1710 if( g.localOpen && g.zLocalRoot && g.zLocalRoot[0] ){
1711 Blob localRoot;
1712 file_canonical_name(g.zLocalRoot, &localRoot);
1713 db_multi_exec(
1714 "REPLACE INTO global_config(name, value)"
1715 "VALUES('ckout:%q','%q');",
1716 blob_str(&localRoot), blob_str(&full)
1717 );
1718 blob_reset(&localRoot);
1719 }
1720 db_swap_connections();
1721 blob_reset(&full);
1722 }
1723
1724
+11 -2
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -19,10 +19,19 @@
1919
*/
2020
#include "config.h"
2121
#include "diffcmd.h"
2222
#include <assert.h>
2323
24
+/*
25
+** Use the right null device for the platform.
26
+*/
27
+#if defined(_WIN32)
28
+# define NULL_DEVICE "NUL"
29
+#else
30
+# define NULL_DEVICE "/dev/null"
31
+#endif
32
+
2433
/*
2534
** Print the "Index:" message that patches wants to see at the top of a diff.
2635
*/
2736
void diff_print_index(const char *zFile, int diffFlags){
2837
if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
@@ -76,11 +85,11 @@
7685
const char *zName2; /* Name of zFile2 for display */
7786
7887
/* Read content of zFile2 into memory */
7988
blob_zero(&file2);
8089
if( file_wd_size(zFile2)<0 ){
81
- zName2 = "/dev/null";
90
+ zName2 = NULL_DEVICE;
8291
}else{
8392
if( file_wd_islink(zFile2) ){
8493
blob_read_link(&file2, zFile2);
8594
}else{
8695
blob_read_from_file(&file2, zFile2);
@@ -283,11 +292,11 @@
283292
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
284293
char *zToFree = zFullName;
285294
int showDiff = 1;
286295
if( isDeleted ){
287296
fossil_print("DELETED %s\n", zPathname);
288
- if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
297
+ if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
289298
}else if( file_access(zFullName, 0) ){
290299
fossil_print("MISSING %s\n", zPathname);
291300
if( !asNewFile ){ showDiff = 0; }
292301
}else if( isNew ){
293302
fossil_print("ADDED %s\n", zPathname);
294303
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -19,10 +19,19 @@
19 */
20 #include "config.h"
21 #include "diffcmd.h"
22 #include <assert.h>
23
 
 
 
 
 
 
 
 
 
24 /*
25 ** Print the "Index:" message that patches wants to see at the top of a diff.
26 */
27 void diff_print_index(const char *zFile, int diffFlags){
28 if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
@@ -76,11 +85,11 @@
76 const char *zName2; /* Name of zFile2 for display */
77
78 /* Read content of zFile2 into memory */
79 blob_zero(&file2);
80 if( file_wd_size(zFile2)<0 ){
81 zName2 = "/dev/null";
82 }else{
83 if( file_wd_islink(zFile2) ){
84 blob_read_link(&file2, zFile2);
85 }else{
86 blob_read_from_file(&file2, zFile2);
@@ -283,11 +292,11 @@
283 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
284 char *zToFree = zFullName;
285 int showDiff = 1;
286 if( isDeleted ){
287 fossil_print("DELETED %s\n", zPathname);
288 if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
289 }else if( file_access(zFullName, 0) ){
290 fossil_print("MISSING %s\n", zPathname);
291 if( !asNewFile ){ showDiff = 0; }
292 }else if( isNew ){
293 fossil_print("ADDED %s\n", zPathname);
294
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -19,10 +19,19 @@
19 */
20 #include "config.h"
21 #include "diffcmd.h"
22 #include <assert.h>
23
24 /*
25 ** Use the right null device for the platform.
26 */
27 #if defined(_WIN32)
28 # define NULL_DEVICE "NUL"
29 #else
30 # define NULL_DEVICE "/dev/null"
31 #endif
32
33 /*
34 ** Print the "Index:" message that patches wants to see at the top of a diff.
35 */
36 void diff_print_index(const char *zFile, int diffFlags){
37 if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
@@ -76,11 +85,11 @@
85 const char *zName2; /* Name of zFile2 for display */
86
87 /* Read content of zFile2 into memory */
88 blob_zero(&file2);
89 if( file_wd_size(zFile2)<0 ){
90 zName2 = NULL_DEVICE;
91 }else{
92 if( file_wd_islink(zFile2) ){
93 blob_read_link(&file2, zFile2);
94 }else{
95 blob_read_from_file(&file2, zFile2);
@@ -283,11 +292,11 @@
292 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
293 char *zToFree = zFullName;
294 int showDiff = 1;
295 if( isDeleted ){
296 fossil_print("DELETED %s\n", zPathname);
297 if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
298 }else if( file_access(zFullName, 0) ){
299 fossil_print("MISSING %s\n", zPathname);
300 if( !asNewFile ){ showDiff = 0; }
301 }else if( isNew ){
302 fossil_print("ADDED %s\n", zPathname);
303
+71 -9
--- src/file.c
+++ src/file.c
@@ -28,10 +28,17 @@
2828
#include <unistd.h>
2929
#include <string.h>
3030
#include <errno.h>
3131
#include "file.h"
3232
33
+/*
34
+** On Windows, include the Platform SDK header file.
35
+*/
36
+#ifdef _WIN32
37
+# include <windows.h>
38
+#endif
39
+
3340
/*
3441
** The file status information from the most recent stat() call.
3542
**
3643
** Use _stati64 rather than stat on windows, in order to handle files
3744
** larger than 2GB.
@@ -609,15 +616,35 @@
609616
** Remove all /./ path elements.
610617
** Convert /A/../ to just /
611618
*/
612619
void file_canonical_name(const char *zOrigName, Blob *pOut){
613620
if( file_is_absolute_path(zOrigName) ){
621
+#if defined(_WIN32)
622
+ char *zOut;
623
+#endif
614624
blob_set(pOut, zOrigName);
615625
blob_materialize(pOut);
626
+#if defined(_WIN32)
627
+ /*
628
+ ** On Windows, normalize the drive letter to upper case.
629
+ */
630
+ zOut = blob_str(pOut);
631
+ if( fossil_isalpha(zOut[0]) && zOut[1]==':' ){
632
+ zOut[0] = fossil_toupper(zOut[0]);
633
+ }
634
+#endif
616635
}else{
617636
char zPwd[2000];
618637
file_getcwd(zPwd, sizeof(zPwd)-strlen(zOrigName));
638
+#if defined(_WIN32)
639
+ /*
640
+ ** On Windows, normalize the drive letter to upper case.
641
+ */
642
+ if( fossil_isalpha(zPwd[0]) && zPwd[1]==':' ){
643
+ zPwd[0] = fossil_toupper(zPwd[0]);
644
+ }
645
+#endif
619646
blob_zero(pOut);
620647
blob_appendf(pOut, "%//%/", zPwd, zOrigName);
621648
}
622649
blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
623650
}
@@ -768,37 +795,51 @@
768795
** false, then simply return 0.
769796
**
770797
** The root of the tree is defined by the g.zLocalRoot variable.
771798
*/
772799
int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
773
- int n;
800
+ Blob localRoot;
801
+ int nLocalRoot;
802
+ char *zLocalRoot;
774803
Blob full;
775804
int nFull;
776805
char *zFull;
777806
778807
blob_zero(pOut);
779808
db_must_be_within_tree();
809
+ file_canonical_name(g.zLocalRoot, &localRoot);
810
+ nLocalRoot = blob_size(&localRoot);
811
+ zLocalRoot = blob_buffer(&localRoot);
812
+ if ( zLocalRoot[nLocalRoot-1]!='/' ){
813
+ blob_append(&localRoot, "/", 1);
814
+ nLocalRoot = blob_size(&localRoot);
815
+ zLocalRoot = blob_buffer(&localRoot);
816
+ }
817
+ assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' );
780818
file_canonical_name(zOrigName, &full);
781
- n = strlen(g.zLocalRoot);
782
- assert( n>0 && g.zLocalRoot[n-1]=='/' );
783819
nFull = blob_size(&full);
784820
zFull = blob_buffer(&full);
785821
786822
/* Special case. zOrigName refers to g.zLocalRoot directory. */
787
- if( nFull==n-1 && memcmp(g.zLocalRoot, zFull, nFull)==0 ){
823
+ if( nFull==nLocalRoot-1 && memcmp(zLocalRoot, zFull, nFull)==0 ){
788824
blob_append(pOut, ".", 1);
825
+ blob_reset(&localRoot);
826
+ blob_reset(&full);
789827
return 1;
790828
}
791829
792
- if( nFull<=n || memcmp(g.zLocalRoot, zFull, n) ){
830
+ if( nFull<=nLocalRoot || memcmp(zLocalRoot, zFull, nLocalRoot) ){
831
+ blob_reset(&localRoot);
793832
blob_reset(&full);
794833
if( errFatal ){
795834
fossil_fatal("file outside of checkout tree: %s", zOrigName);
796835
}
797836
return 0;
798837
}
799
- blob_append(pOut, &zFull[n], nFull-n);
838
+ blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot);
839
+ blob_reset(&localRoot);
840
+ blob_reset(&full);
800841
return 1;
801842
}
802843
803844
/*
804845
** COMMAND: test-tree-name
@@ -861,25 +902,44 @@
861902
/*
862903
** Construct a random temporary filename into zBuf[].
863904
*/
864905
void file_tempname(int nBuf, char *zBuf){
865906
static const char *azDirs[] = {
907
+#if defined(_WIN32)
908
+ 0, /* GetTempPath */
909
+ 0, /* TEMP */
910
+ 0, /* TMP */
911
+#else
866912
"/var/tmp",
867913
"/usr/tmp",
868914
"/tmp",
869915
"/temp",
916
+#endif
870917
".",
871918
};
872919
static const unsigned char zChars[] =
873920
"abcdefghijklmnopqrstuvwxyz"
874921
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
875922
"0123456789";
876923
unsigned int i, j;
877924
const char *zDir = ".";
878925
int cnt = 0;
926
+
927
+#if defined(_WIN32)
928
+ char zTmpPath[MAX_PATH];
929
+
930
+ if( GetTempPath(sizeof(zTmpPath), zTmpPath) ){
931
+ azDirs[0] = zTmpPath;
932
+ }
933
+
934
+ azDirs[1] = fossil_getenv("TEMP");
935
+ azDirs[2] = fossil_getenv("TMP");
936
+#endif
937
+
879938
880939
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
940
+ if( azDirs[i]==0 ) continue;
881941
if( !file_isdir(azDirs[i]) ) continue;
882942
zDir = azDirs[i];
883943
break;
884944
}
885945
@@ -898,10 +958,15 @@
898958
for(i=0; i<15; i++, j++){
899959
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
900960
}
901961
zBuf[j] = 0;
902962
}while( file_size(zBuf)>=0 );
963
+
964
+#if defined(_WIN32)
965
+ fossil_mbcs_free((char *)azDirs[1]);
966
+ fossil_mbcs_free((char *)azDirs[2]);
967
+#endif
903968
}
904969
905970
906971
/*
907972
** Return true if a file named zName exists and has identical content
@@ -930,13 +995,10 @@
930995
/**************************************************************************
931996
** The following routines translate between MBCS and UTF8 on windows.
932997
** Since everything is always UTF8 on unix, these routines are no-ops
933998
** there.
934999
*/
935
-#ifdef _WIN32
936
-# include <windows.h>
937
-#endif
9381000
9391001
/*
9401002
** Translate MBCS to UTF8. Return a pointer to the translated text.
9411003
** Call fossil_mbcs_free() to deallocate any memory used to store the
9421004
** returned pointer when done.
9431005
--- src/file.c
+++ src/file.c
@@ -28,10 +28,17 @@
28 #include <unistd.h>
29 #include <string.h>
30 #include <errno.h>
31 #include "file.h"
32
 
 
 
 
 
 
 
33 /*
34 ** The file status information from the most recent stat() call.
35 **
36 ** Use _stati64 rather than stat on windows, in order to handle files
37 ** larger than 2GB.
@@ -609,15 +616,35 @@
609 ** Remove all /./ path elements.
610 ** Convert /A/../ to just /
611 */
612 void file_canonical_name(const char *zOrigName, Blob *pOut){
613 if( file_is_absolute_path(zOrigName) ){
 
 
 
614 blob_set(pOut, zOrigName);
615 blob_materialize(pOut);
 
 
 
 
 
 
 
 
 
616 }else{
617 char zPwd[2000];
618 file_getcwd(zPwd, sizeof(zPwd)-strlen(zOrigName));
 
 
 
 
 
 
 
 
619 blob_zero(pOut);
620 blob_appendf(pOut, "%//%/", zPwd, zOrigName);
621 }
622 blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
623 }
@@ -768,37 +795,51 @@
768 ** false, then simply return 0.
769 **
770 ** The root of the tree is defined by the g.zLocalRoot variable.
771 */
772 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
773 int n;
 
 
774 Blob full;
775 int nFull;
776 char *zFull;
777
778 blob_zero(pOut);
779 db_must_be_within_tree();
 
 
 
 
 
 
 
 
 
780 file_canonical_name(zOrigName, &full);
781 n = strlen(g.zLocalRoot);
782 assert( n>0 && g.zLocalRoot[n-1]=='/' );
783 nFull = blob_size(&full);
784 zFull = blob_buffer(&full);
785
786 /* Special case. zOrigName refers to g.zLocalRoot directory. */
787 if( nFull==n-1 && memcmp(g.zLocalRoot, zFull, nFull)==0 ){
788 blob_append(pOut, ".", 1);
 
 
789 return 1;
790 }
791
792 if( nFull<=n || memcmp(g.zLocalRoot, zFull, n) ){
 
793 blob_reset(&full);
794 if( errFatal ){
795 fossil_fatal("file outside of checkout tree: %s", zOrigName);
796 }
797 return 0;
798 }
799 blob_append(pOut, &zFull[n], nFull-n);
 
 
800 return 1;
801 }
802
803 /*
804 ** COMMAND: test-tree-name
@@ -861,25 +902,44 @@
861 /*
862 ** Construct a random temporary filename into zBuf[].
863 */
864 void file_tempname(int nBuf, char *zBuf){
865 static const char *azDirs[] = {
 
 
 
 
 
866 "/var/tmp",
867 "/usr/tmp",
868 "/tmp",
869 "/temp",
 
870 ".",
871 };
872 static const unsigned char zChars[] =
873 "abcdefghijklmnopqrstuvwxyz"
874 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
875 "0123456789";
876 unsigned int i, j;
877 const char *zDir = ".";
878 int cnt = 0;
 
 
 
 
 
 
 
 
 
 
 
 
879
880 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
 
881 if( !file_isdir(azDirs[i]) ) continue;
882 zDir = azDirs[i];
883 break;
884 }
885
@@ -898,10 +958,15 @@
898 for(i=0; i<15; i++, j++){
899 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
900 }
901 zBuf[j] = 0;
902 }while( file_size(zBuf)>=0 );
 
 
 
 
 
903 }
904
905
906 /*
907 ** Return true if a file named zName exists and has identical content
@@ -930,13 +995,10 @@
930 /**************************************************************************
931 ** The following routines translate between MBCS and UTF8 on windows.
932 ** Since everything is always UTF8 on unix, these routines are no-ops
933 ** there.
934 */
935 #ifdef _WIN32
936 # include <windows.h>
937 #endif
938
939 /*
940 ** Translate MBCS to UTF8. Return a pointer to the translated text.
941 ** Call fossil_mbcs_free() to deallocate any memory used to store the
942 ** returned pointer when done.
943
--- src/file.c
+++ src/file.c
@@ -28,10 +28,17 @@
28 #include <unistd.h>
29 #include <string.h>
30 #include <errno.h>
31 #include "file.h"
32
33 /*
34 ** On Windows, include the Platform SDK header file.
35 */
36 #ifdef _WIN32
37 # include <windows.h>
38 #endif
39
40 /*
41 ** The file status information from the most recent stat() call.
42 **
43 ** Use _stati64 rather than stat on windows, in order to handle files
44 ** larger than 2GB.
@@ -609,15 +616,35 @@
616 ** Remove all /./ path elements.
617 ** Convert /A/../ to just /
618 */
619 void file_canonical_name(const char *zOrigName, Blob *pOut){
620 if( file_is_absolute_path(zOrigName) ){
621 #if defined(_WIN32)
622 char *zOut;
623 #endif
624 blob_set(pOut, zOrigName);
625 blob_materialize(pOut);
626 #if defined(_WIN32)
627 /*
628 ** On Windows, normalize the drive letter to upper case.
629 */
630 zOut = blob_str(pOut);
631 if( fossil_isalpha(zOut[0]) && zOut[1]==':' ){
632 zOut[0] = fossil_toupper(zOut[0]);
633 }
634 #endif
635 }else{
636 char zPwd[2000];
637 file_getcwd(zPwd, sizeof(zPwd)-strlen(zOrigName));
638 #if defined(_WIN32)
639 /*
640 ** On Windows, normalize the drive letter to upper case.
641 */
642 if( fossil_isalpha(zPwd[0]) && zPwd[1]==':' ){
643 zPwd[0] = fossil_toupper(zPwd[0]);
644 }
645 #endif
646 blob_zero(pOut);
647 blob_appendf(pOut, "%//%/", zPwd, zOrigName);
648 }
649 blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
650 }
@@ -768,37 +795,51 @@
795 ** false, then simply return 0.
796 **
797 ** The root of the tree is defined by the g.zLocalRoot variable.
798 */
799 int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){
800 Blob localRoot;
801 int nLocalRoot;
802 char *zLocalRoot;
803 Blob full;
804 int nFull;
805 char *zFull;
806
807 blob_zero(pOut);
808 db_must_be_within_tree();
809 file_canonical_name(g.zLocalRoot, &localRoot);
810 nLocalRoot = blob_size(&localRoot);
811 zLocalRoot = blob_buffer(&localRoot);
812 if ( zLocalRoot[nLocalRoot-1]!='/' ){
813 blob_append(&localRoot, "/", 1);
814 nLocalRoot = blob_size(&localRoot);
815 zLocalRoot = blob_buffer(&localRoot);
816 }
817 assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' );
818 file_canonical_name(zOrigName, &full);
 
 
819 nFull = blob_size(&full);
820 zFull = blob_buffer(&full);
821
822 /* Special case. zOrigName refers to g.zLocalRoot directory. */
823 if( nFull==nLocalRoot-1 && memcmp(zLocalRoot, zFull, nFull)==0 ){
824 blob_append(pOut, ".", 1);
825 blob_reset(&localRoot);
826 blob_reset(&full);
827 return 1;
828 }
829
830 if( nFull<=nLocalRoot || memcmp(zLocalRoot, zFull, nLocalRoot) ){
831 blob_reset(&localRoot);
832 blob_reset(&full);
833 if( errFatal ){
834 fossil_fatal("file outside of checkout tree: %s", zOrigName);
835 }
836 return 0;
837 }
838 blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot);
839 blob_reset(&localRoot);
840 blob_reset(&full);
841 return 1;
842 }
843
844 /*
845 ** COMMAND: test-tree-name
@@ -861,25 +902,44 @@
902 /*
903 ** Construct a random temporary filename into zBuf[].
904 */
905 void file_tempname(int nBuf, char *zBuf){
906 static const char *azDirs[] = {
907 #if defined(_WIN32)
908 0, /* GetTempPath */
909 0, /* TEMP */
910 0, /* TMP */
911 #else
912 "/var/tmp",
913 "/usr/tmp",
914 "/tmp",
915 "/temp",
916 #endif
917 ".",
918 };
919 static const unsigned char zChars[] =
920 "abcdefghijklmnopqrstuvwxyz"
921 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
922 "0123456789";
923 unsigned int i, j;
924 const char *zDir = ".";
925 int cnt = 0;
926
927 #if defined(_WIN32)
928 char zTmpPath[MAX_PATH];
929
930 if( GetTempPath(sizeof(zTmpPath), zTmpPath) ){
931 azDirs[0] = zTmpPath;
932 }
933
934 azDirs[1] = fossil_getenv("TEMP");
935 azDirs[2] = fossil_getenv("TMP");
936 #endif
937
938
939 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
940 if( azDirs[i]==0 ) continue;
941 if( !file_isdir(azDirs[i]) ) continue;
942 zDir = azDirs[i];
943 break;
944 }
945
@@ -898,10 +958,15 @@
958 for(i=0; i<15; i++, j++){
959 zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
960 }
961 zBuf[j] = 0;
962 }while( file_size(zBuf)>=0 );
963
964 #if defined(_WIN32)
965 fossil_mbcs_free((char *)azDirs[1]);
966 fossil_mbcs_free((char *)azDirs[2]);
967 #endif
968 }
969
970
971 /*
972 ** Return true if a file named zName exists and has identical content
@@ -930,13 +995,10 @@
995 /**************************************************************************
996 ** The following routines translate between MBCS and UTF8 on windows.
997 ** Since everything is always UTF8 on unix, these routines are no-ops
998 ** there.
999 */
 
 
 
1000
1001 /*
1002 ** Translate MBCS to UTF8. Return a pointer to the translated text.
1003 ** Call fossil_mbcs_free() to deallocate any memory used to store the
1004 ** returned pointer when done.
1005
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -469,11 +469,11 @@
469469
# or linking with it will not work (exact reason unknown).
470470
#
471471
ifdef FOSSIL_ENABLE_TCL
472472
LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
473473
else
474
-LIB += -lws2_32
474
+LIB += -lkernel32 -lws2_32
475475
endif
476476
477477
#### Tcl shell for use in running the fossil test suite. This is only
478478
# used for testing.
479479
#
480480
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -469,11 +469,11 @@
469 # or linking with it will not work (exact reason unknown).
470 #
471 ifdef FOSSIL_ENABLE_TCL
472 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
473 else
474 LIB += -lws2_32
475 endif
476
477 #### Tcl shell for use in running the fossil test suite. This is only
478 # used for testing.
479 #
480
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -469,11 +469,11 @@
469 # or linking with it will not work (exact reason unknown).
470 #
471 ifdef FOSSIL_ENABLE_TCL
472 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
473 else
474 LIB += -lkernel32 -lws2_32
475 endif
476
477 #### Tcl shell for use in running the fossil test suite. This is only
478 # used for testing.
479 #
480
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -150,11 +150,11 @@
150150
# or linking with it will not work (exact reason unknown).
151151
#
152152
ifdef FOSSIL_ENABLE_TCL
153153
LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
154154
else
155
-LIB += -lws2_32
155
+LIB += -lkernel32 -lws2_32
156156
endif
157157
158158
#### Tcl shell for use in running the fossil test suite. This is only
159159
# used for testing.
160160
#
161161
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -150,11 +150,11 @@
150 # or linking with it will not work (exact reason unknown).
151 #
152 ifdef FOSSIL_ENABLE_TCL
153 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
154 else
155 LIB += -lws2_32
156 endif
157
158 #### Tcl shell for use in running the fossil test suite. This is only
159 # used for testing.
160 #
161
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -150,11 +150,11 @@
150 # or linking with it will not work (exact reason unknown).
151 #
152 ifdef FOSSIL_ENABLE_TCL
153 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
154 else
155 LIB += -lkernel32 -lws2_32
156 endif
157
158 #### Tcl shell for use in running the fossil test suite. This is only
159 # used for testing.
160 #
161
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -150,11 +150,11 @@
150150
# or linking with it will not work (exact reason unknown).
151151
#
152152
ifdef FOSSIL_ENABLE_TCL
153153
LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
154154
else
155
-LIB += -lws2_32
155
+LIB += -lkernel32 -lws2_32
156156
endif
157157
158158
#### Tcl shell for use in running the fossil test suite. This is only
159159
# used for testing.
160160
#
161161
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -150,11 +150,11 @@
150 # or linking with it will not work (exact reason unknown).
151 #
152 ifdef FOSSIL_ENABLE_TCL
153 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
154 else
155 LIB += -lws2_32
156 endif
157
158 #### Tcl shell for use in running the fossil test suite. This is only
159 # used for testing.
160 #
161
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -150,11 +150,11 @@
150 # or linking with it will not work (exact reason unknown).
151 #
152 ifdef FOSSIL_ENABLE_TCL
153 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
154 else
155 LIB += -lkernel32 -lws2_32
156 endif
157
158 #### Tcl shell for use in running the fossil test suite. This is only
159 # used for testing.
160 #
161

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button