Fossil SCM

Enable fossil to distinguish correctly CR/CRNL/mixed line endings.

jan.nijtmans 2013-03-26 11:12 trunk
Commit f89e2eccbb9e2861c2c7c0a90045fefaf6703d13
2 files changed +12 -8 +1
+12 -8
--- src/checkin.c
+++ src/checkin.c
@@ -919,11 +919,11 @@
919919
if( fUnicode ){
920920
lookFlags = looks_like_utf16(p, bReverse);
921921
}else{
922922
lookFlags = looks_like_utf8(p);
923923
}
924
- if( lookFlags&(LOOK_BINARY|LOOK_LONG|LOOK_LONE_CR|LOOK_CRLF) || fUnicode ){
924
+ if( lookFlags&(LOOK_BINARY|LOOK_LONG|LOOK_CR) || fUnicode ){
925925
const char *zWarning;
926926
const char *zDisable;
927927
const char *zConvert = "c=convert/";
928928
Blob ans;
929929
char cReply;
@@ -940,28 +940,32 @@
940940
}else{
941941
zWarning = "binary data";
942942
zConvert = ""; /* We cannot convert binary files. */
943943
}
944944
zDisable = "\"binary-glob\" setting";
945
- }else if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) && fUnicode ){
945
+ }else if( lookFlags&(LOOK_CR) && fUnicode ){
946946
if( crnlOk && encodingOk ){
947947
return 0; /* We don't want CR/NL and Unicode warnings for this file. */
948948
}
949
- if( lookFlags&LOOK_LONE_CR ){
949
+ if( (lookFlags&LOOK_EOL) == LOOK_LONE_CR ){
950950
zWarning = "CR line endings and Unicode";
951
- }else{
951
+ }else if( (lookFlags&LOOK_EOL) == LOOK_CRLF ){
952952
zWarning = "CR/NL line endings and Unicode";
953
+ }else{
954
+ zWarning = "mixed line endings and Unicode";
953955
}
954956
zDisable = "\"crnl-glob\" and \"encoding-glob\" settings";
955
- }else if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) ){
957
+ }else if( lookFlags&LOOK_CR ){
956958
if( crnlOk ){
957959
return 0; /* We don't want CR/NL warnings for this file. */
958960
}
959
- if( lookFlags&LOOK_LONE_CR ){
961
+ if( (lookFlags&LOOK_EOL) == LOOK_LONE_CR ){
960962
zWarning = "CR line endings";
961
- }else{
963
+ }else if( (lookFlags&LOOK_EOL) == LOOK_CRLF ){
962964
zWarning = "CR/NL line endings";
965
+ }else{
966
+ zWarning = "mixed line endings";
963967
}
964968
zDisable = "\"crnl-glob\" setting";
965969
}else{
966970
if( encodingOk ){
967971
return 0; /* We don't want encoding warnings for this file. */
@@ -993,11 +997,11 @@
993997
int bomSize;
994998
const unsigned char *bom = get_utf8_bom(&bomSize);
995999
fwrite(bom, 1, bomSize, f);
9961000
blob_to_utf8_no_bom(p, 0);
9971001
}
998
- if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) ){
1002
+ if( lookFlags&LOOK_CR ){
9991003
blob_to_lf_only(p);
10001004
}
10011005
fwrite(blob_buffer(p), 1, blob_size(p), f);
10021006
fclose(f);
10031007
return 1;
10041008
--- src/checkin.c
+++ src/checkin.c
@@ -919,11 +919,11 @@
919 if( fUnicode ){
920 lookFlags = looks_like_utf16(p, bReverse);
921 }else{
922 lookFlags = looks_like_utf8(p);
923 }
924 if( lookFlags&(LOOK_BINARY|LOOK_LONG|LOOK_LONE_CR|LOOK_CRLF) || fUnicode ){
925 const char *zWarning;
926 const char *zDisable;
927 const char *zConvert = "c=convert/";
928 Blob ans;
929 char cReply;
@@ -940,28 +940,32 @@
940 }else{
941 zWarning = "binary data";
942 zConvert = ""; /* We cannot convert binary files. */
943 }
944 zDisable = "\"binary-glob\" setting";
945 }else if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) && fUnicode ){
946 if( crnlOk && encodingOk ){
947 return 0; /* We don't want CR/NL and Unicode warnings for this file. */
948 }
949 if( lookFlags&LOOK_LONE_CR ){
950 zWarning = "CR line endings and Unicode";
951 }else{
952 zWarning = "CR/NL line endings and Unicode";
 
 
953 }
954 zDisable = "\"crnl-glob\" and \"encoding-glob\" settings";
955 }else if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) ){
956 if( crnlOk ){
957 return 0; /* We don't want CR/NL warnings for this file. */
958 }
959 if( lookFlags&LOOK_LONE_CR ){
960 zWarning = "CR line endings";
961 }else{
962 zWarning = "CR/NL line endings";
 
 
963 }
964 zDisable = "\"crnl-glob\" setting";
965 }else{
966 if( encodingOk ){
967 return 0; /* We don't want encoding warnings for this file. */
@@ -993,11 +997,11 @@
993 int bomSize;
994 const unsigned char *bom = get_utf8_bom(&bomSize);
995 fwrite(bom, 1, bomSize, f);
996 blob_to_utf8_no_bom(p, 0);
997 }
998 if( lookFlags&(LOOK_LONE_CR|LOOK_CRLF) ){
999 blob_to_lf_only(p);
1000 }
1001 fwrite(blob_buffer(p), 1, blob_size(p), f);
1002 fclose(f);
1003 return 1;
1004
--- src/checkin.c
+++ src/checkin.c
@@ -919,11 +919,11 @@
919 if( fUnicode ){
920 lookFlags = looks_like_utf16(p, bReverse);
921 }else{
922 lookFlags = looks_like_utf8(p);
923 }
924 if( lookFlags&(LOOK_BINARY|LOOK_LONG|LOOK_CR) || fUnicode ){
925 const char *zWarning;
926 const char *zDisable;
927 const char *zConvert = "c=convert/";
928 Blob ans;
929 char cReply;
@@ -940,28 +940,32 @@
940 }else{
941 zWarning = "binary data";
942 zConvert = ""; /* We cannot convert binary files. */
943 }
944 zDisable = "\"binary-glob\" setting";
945 }else if( lookFlags&(LOOK_CR) && fUnicode ){
946 if( crnlOk && encodingOk ){
947 return 0; /* We don't want CR/NL and Unicode warnings for this file. */
948 }
949 if( (lookFlags&LOOK_EOL) == LOOK_LONE_CR ){
950 zWarning = "CR line endings and Unicode";
951 }else if( (lookFlags&LOOK_EOL) == LOOK_CRLF ){
952 zWarning = "CR/NL line endings and Unicode";
953 }else{
954 zWarning = "mixed line endings and Unicode";
955 }
956 zDisable = "\"crnl-glob\" and \"encoding-glob\" settings";
957 }else if( lookFlags&LOOK_CR ){
958 if( crnlOk ){
959 return 0; /* We don't want CR/NL warnings for this file. */
960 }
961 if( (lookFlags&LOOK_EOL) == LOOK_LONE_CR ){
962 zWarning = "CR line endings";
963 }else if( (lookFlags&LOOK_EOL) == LOOK_CRLF ){
964 zWarning = "CR/NL line endings";
965 }else{
966 zWarning = "mixed line endings";
967 }
968 zDisable = "\"crnl-glob\" setting";
969 }else{
970 if( encodingOk ){
971 return 0; /* We don't want encoding warnings for this file. */
@@ -993,11 +997,11 @@
997 int bomSize;
998 const unsigned char *bom = get_utf8_bom(&bomSize);
999 fwrite(bom, 1, bomSize, f);
1000 blob_to_utf8_no_bom(p, 0);
1001 }
1002 if( lookFlags&LOOK_CR ){
1003 blob_to_lf_only(p);
1004 }
1005 fwrite(blob_buffer(p), 1, blob_size(p), f);
1006 fclose(f);
1007 return 1;
1008
+1
--- src/diff.c
+++ src/diff.c
@@ -79,10 +79,11 @@
7979
#define LOOK_LONG ((int)0x00000040) /* An over length line was found. */
8080
#define LOOK_ODD ((int)0x00000080) /* An odd number of bytes was found. */
8181
#define LOOK_SHORT ((int)0x00000100) /* Unable to perform full check. */
8282
#define LOOK_INVALID ((int)0x00000200) /* Invalid sequence was found. */
8383
#define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */
84
+#define LOOK_EOL (LOOK_LONE_CR | LOOK_LONE_LF | LOOK_CRLF) /* Any eol type. */
8485
#endif /* INTERFACE */
8586
8687
/*
8788
** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes)
8889
*/
8990
--- src/diff.c
+++ src/diff.c
@@ -79,10 +79,11 @@
79 #define LOOK_LONG ((int)0x00000040) /* An over length line was found. */
80 #define LOOK_ODD ((int)0x00000080) /* An odd number of bytes was found. */
81 #define LOOK_SHORT ((int)0x00000100) /* Unable to perform full check. */
82 #define LOOK_INVALID ((int)0x00000200) /* Invalid sequence was found. */
83 #define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */
 
84 #endif /* INTERFACE */
85
86 /*
87 ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes)
88 */
89
--- src/diff.c
+++ src/diff.c
@@ -79,10 +79,11 @@
79 #define LOOK_LONG ((int)0x00000040) /* An over length line was found. */
80 #define LOOK_ODD ((int)0x00000080) /* An odd number of bytes was found. */
81 #define LOOK_SHORT ((int)0x00000100) /* Unable to perform full check. */
82 #define LOOK_INVALID ((int)0x00000200) /* Invalid sequence was found. */
83 #define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */
84 #define LOOK_EOL (LOOK_LONE_CR | LOOK_LONE_LF | LOOK_CRLF) /* Any eol type. */
85 #endif /* INTERFACE */
86
87 /*
88 ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes)
89 */
90

Keyboard Shortcuts

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