Fossil SCM

Restore original definitions of the 'LOOK_*' flags.

mistachkin 2015-12-23 21:35 trunk
Commit 3161968463c0c6d59d2dee4b7349f00e45a29fe0
1 file changed +19 -13
+19 -13
--- src/lookslike.c
+++ src/lookslike.c
@@ -37,21 +37,21 @@
3737
** Output flags for the looks_like_utf8() and looks_like_utf16() routines used
3838
** to convey status information about the blob content.
3939
*/
4040
#define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */
4141
#define LOOK_NUL ((int)0x00000001) /* One or more NUL chars were found. */
42
-#define LOOK_LONE_CR ((int)0x00000002) /* An unpaired CR char was found. */
43
-#define LOOK_LONE_LF ((int)0x00000004) /* An unpaired LF char was found. */
44
-#define LOOK_CRLF ((int)0x00000008) /* One or more CR/LF pairs were found. */
45
-#define LOOK_LONG ((int)0x00000010) /* An over length line was found. */
46
-#define LOOK_ODD ((int)0x00000020) /* An odd number of bytes was found. */
47
-#define LOOK_SHORT ((int)0x00000040) /* Unable to perform full check. */
48
-#define LOOK_INVALID ((int)0x00000080) /* Invalid sequence was found. */
42
+#define LOOK_CR ((int)0x00000002) /* One or more CR chars were found. */
43
+#define LOOK_LONE_CR ((int)0x00000004) /* An unpaired CR char was found. */
44
+#define LOOK_LF ((int)0x00000008) /* One or more LF chars were found. */
45
+#define LOOK_LONE_LF ((int)0x00000010) /* An unpaired LF char was found. */
46
+#define LOOK_CRLF ((int)0x00000020) /* One or more CR/LF pairs were found. */
47
+#define LOOK_LONG ((int)0x00000040) /* An over length line was found. */
48
+#define LOOK_ODD ((int)0x00000080) /* An odd number of bytes was found. */
49
+#define LOOK_SHORT ((int)0x00000100) /* Unable to perform full check. */
50
+#define LOOK_INVALID ((int)0x00000200) /* Invalid sequence was found. */
4951
#define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */
5052
#define LOOK_EOL (LOOK_LONE_CR | LOOK_LONE_LF | LOOK_CRLF) /* Line seps. */
51
-#define LOOK_CR (LOOK_LONE_CR | LOOK_CRLF) /* One or more CR chars. */
52
-#define LOOK_LF (LOOK_LONE_LF | LOOK_CRLF) /* One or more LF chars. */
5353
#endif /* INTERFACE */
5454
5555
5656
/*
5757
** This function attempts to scan each logical line within the blob to
@@ -93,32 +93,35 @@
9393
if( n==0 ) return flags; /* Empty file -> text */
9494
c = *z;
9595
if( c==0 ){
9696
flags |= LOOK_NUL; /* NUL character in a file -> binary */
9797
}else if( c=='\r' ){
98
+ flags |= LOOK_CR;
9899
if( n<=1 || z[1]!='\n' ){
99100
flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
100101
}
101102
}
102103
j = (c!='\n');
103
- if( !j ) flags |= (LOOK_LONE_LF); /* Found LF as first char */
104
+ if( !j ) flags |= (LOOK_LF | LOOK_LONE_LF); /* Found LF as first char */
104105
while( !(flags&stopFlags) && --n>0 ){
105106
int c2 = c;
106107
c = *++z; ++j;
107108
if( c==0 ){
108109
flags |= LOOK_NUL; /* NUL character in a file -> binary */
109110
}else if( c=='\n' ){
111
+ flags |= LOOK_LF;
110112
if( c2=='\r' ){
111
- flags |= (LOOK_CRLF); /* Found LF preceded by CR */
113
+ flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */
112114
}else{
113115
flags |= LOOK_LONE_LF;
114116
}
115117
if( j>LENGTH_MASK ){
116118
flags |= LOOK_LONG; /* Very long line -> binary */
117119
}
118120
j = 0;
119121
}else if( c=='\r' ){
122
+ flags |= LOOK_CR;
120123
if( n<=1 || z[1]!='\n' ){
121124
flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
122125
}
123126
}
124127
}
@@ -239,16 +242,17 @@
239242
c = UTF16_SWAP(c);
240243
}
241244
if( c==0 ){
242245
flags |= LOOK_NUL; /* NUL character in a file -> binary */
243246
}else if( c=='\r' ){
247
+ flags |= LOOK_CR;
244248
if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){
245249
flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
246250
}
247251
}
248252
j = (c!='\n');
249
- if( !j ) flags |= (LOOK_LONE_LF); /* Found LF as first char */
253
+ if( !j ) flags |= (LOOK_LF | LOOK_LONE_LF); /* Found LF as first char */
250254
while( !(flags&stopFlags) && ((n-=sizeof(WCHAR_T))>=sizeof(WCHAR_T)) ){
251255
int c2 = c;
252256
c = *++z;
253257
if( bReverse ){
254258
c = UTF16_SWAP(c);
@@ -255,20 +259,22 @@
255259
}
256260
++j;
257261
if( c==0 ){
258262
flags |= LOOK_NUL; /* NUL character in a file -> binary */
259263
}else if( c=='\n' ){
264
+ flags |= LOOK_LF;
260265
if( c2=='\r' ){
261
- flags |= (LOOK_CRLF); /* Found LF preceded by CR */
266
+ flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */
262267
}else{
263268
flags |= LOOK_LONE_LF;
264269
}
265270
if( j>UTF16_LENGTH_MASK ){
266271
flags |= LOOK_LONG; /* Very long line -> binary */
267272
}
268273
j = 0;
269274
}else if( c=='\r' ){
275
+ flags |= LOOK_CR;
270276
if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){
271277
flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
272278
}
273279
}
274280
}
275281
--- src/lookslike.c
+++ src/lookslike.c
@@ -37,21 +37,21 @@
37 ** Output flags for the looks_like_utf8() and looks_like_utf16() routines used
38 ** to convey status information about the blob content.
39 */
40 #define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */
41 #define LOOK_NUL ((int)0x00000001) /* One or more NUL chars were found. */
42 #define LOOK_LONE_CR ((int)0x00000002) /* An unpaired CR char was found. */
43 #define LOOK_LONE_LF ((int)0x00000004) /* An unpaired LF char was found. */
44 #define LOOK_CRLF ((int)0x00000008) /* One or more CR/LF pairs were found. */
45 #define LOOK_LONG ((int)0x00000010) /* An over length line was found. */
46 #define LOOK_ODD ((int)0x00000020) /* An odd number of bytes was found. */
47 #define LOOK_SHORT ((int)0x00000040) /* Unable to perform full check. */
48 #define LOOK_INVALID ((int)0x00000080) /* Invalid sequence was found. */
 
 
49 #define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */
50 #define LOOK_EOL (LOOK_LONE_CR | LOOK_LONE_LF | LOOK_CRLF) /* Line seps. */
51 #define LOOK_CR (LOOK_LONE_CR | LOOK_CRLF) /* One or more CR chars. */
52 #define LOOK_LF (LOOK_LONE_LF | LOOK_CRLF) /* One or more LF chars. */
53 #endif /* INTERFACE */
54
55
56 /*
57 ** This function attempts to scan each logical line within the blob to
@@ -93,32 +93,35 @@
93 if( n==0 ) return flags; /* Empty file -> text */
94 c = *z;
95 if( c==0 ){
96 flags |= LOOK_NUL; /* NUL character in a file -> binary */
97 }else if( c=='\r' ){
 
98 if( n<=1 || z[1]!='\n' ){
99 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
100 }
101 }
102 j = (c!='\n');
103 if( !j ) flags |= (LOOK_LONE_LF); /* Found LF as first char */
104 while( !(flags&stopFlags) && --n>0 ){
105 int c2 = c;
106 c = *++z; ++j;
107 if( c==0 ){
108 flags |= LOOK_NUL; /* NUL character in a file -> binary */
109 }else if( c=='\n' ){
 
110 if( c2=='\r' ){
111 flags |= (LOOK_CRLF); /* Found LF preceded by CR */
112 }else{
113 flags |= LOOK_LONE_LF;
114 }
115 if( j>LENGTH_MASK ){
116 flags |= LOOK_LONG; /* Very long line -> binary */
117 }
118 j = 0;
119 }else if( c=='\r' ){
 
120 if( n<=1 || z[1]!='\n' ){
121 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
122 }
123 }
124 }
@@ -239,16 +242,17 @@
239 c = UTF16_SWAP(c);
240 }
241 if( c==0 ){
242 flags |= LOOK_NUL; /* NUL character in a file -> binary */
243 }else if( c=='\r' ){
 
244 if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){
245 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
246 }
247 }
248 j = (c!='\n');
249 if( !j ) flags |= (LOOK_LONE_LF); /* Found LF as first char */
250 while( !(flags&stopFlags) && ((n-=sizeof(WCHAR_T))>=sizeof(WCHAR_T)) ){
251 int c2 = c;
252 c = *++z;
253 if( bReverse ){
254 c = UTF16_SWAP(c);
@@ -255,20 +259,22 @@
255 }
256 ++j;
257 if( c==0 ){
258 flags |= LOOK_NUL; /* NUL character in a file -> binary */
259 }else if( c=='\n' ){
 
260 if( c2=='\r' ){
261 flags |= (LOOK_CRLF); /* Found LF preceded by CR */
262 }else{
263 flags |= LOOK_LONE_LF;
264 }
265 if( j>UTF16_LENGTH_MASK ){
266 flags |= LOOK_LONG; /* Very long line -> binary */
267 }
268 j = 0;
269 }else if( c=='\r' ){
 
270 if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){
271 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
272 }
273 }
274 }
275
--- src/lookslike.c
+++ src/lookslike.c
@@ -37,21 +37,21 @@
37 ** Output flags for the looks_like_utf8() and looks_like_utf16() routines used
38 ** to convey status information about the blob content.
39 */
40 #define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */
41 #define LOOK_NUL ((int)0x00000001) /* One or more NUL chars were found. */
42 #define LOOK_CR ((int)0x00000002) /* One or more CR chars were found. */
43 #define LOOK_LONE_CR ((int)0x00000004) /* An unpaired CR char was found. */
44 #define LOOK_LF ((int)0x00000008) /* One or more LF chars were found. */
45 #define LOOK_LONE_LF ((int)0x00000010) /* An unpaired LF char was found. */
46 #define LOOK_CRLF ((int)0x00000020) /* One or more CR/LF pairs were found. */
47 #define LOOK_LONG ((int)0x00000040) /* An over length line was found. */
48 #define LOOK_ODD ((int)0x00000080) /* An odd number of bytes was found. */
49 #define LOOK_SHORT ((int)0x00000100) /* Unable to perform full check. */
50 #define LOOK_INVALID ((int)0x00000200) /* Invalid sequence was found. */
51 #define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */
52 #define LOOK_EOL (LOOK_LONE_CR | LOOK_LONE_LF | LOOK_CRLF) /* Line seps. */
 
 
53 #endif /* INTERFACE */
54
55
56 /*
57 ** This function attempts to scan each logical line within the blob to
@@ -93,32 +93,35 @@
93 if( n==0 ) return flags; /* Empty file -> text */
94 c = *z;
95 if( c==0 ){
96 flags |= LOOK_NUL; /* NUL character in a file -> binary */
97 }else if( c=='\r' ){
98 flags |= LOOK_CR;
99 if( n<=1 || z[1]!='\n' ){
100 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
101 }
102 }
103 j = (c!='\n');
104 if( !j ) flags |= (LOOK_LF | LOOK_LONE_LF); /* Found LF as first char */
105 while( !(flags&stopFlags) && --n>0 ){
106 int c2 = c;
107 c = *++z; ++j;
108 if( c==0 ){
109 flags |= LOOK_NUL; /* NUL character in a file -> binary */
110 }else if( c=='\n' ){
111 flags |= LOOK_LF;
112 if( c2=='\r' ){
113 flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */
114 }else{
115 flags |= LOOK_LONE_LF;
116 }
117 if( j>LENGTH_MASK ){
118 flags |= LOOK_LONG; /* Very long line -> binary */
119 }
120 j = 0;
121 }else if( c=='\r' ){
122 flags |= LOOK_CR;
123 if( n<=1 || z[1]!='\n' ){
124 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
125 }
126 }
127 }
@@ -239,16 +242,17 @@
242 c = UTF16_SWAP(c);
243 }
244 if( c==0 ){
245 flags |= LOOK_NUL; /* NUL character in a file -> binary */
246 }else if( c=='\r' ){
247 flags |= LOOK_CR;
248 if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){
249 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
250 }
251 }
252 j = (c!='\n');
253 if( !j ) flags |= (LOOK_LF | LOOK_LONE_LF); /* Found LF as first char */
254 while( !(flags&stopFlags) && ((n-=sizeof(WCHAR_T))>=sizeof(WCHAR_T)) ){
255 int c2 = c;
256 c = *++z;
257 if( bReverse ){
258 c = UTF16_SWAP(c);
@@ -255,20 +259,22 @@
259 }
260 ++j;
261 if( c==0 ){
262 flags |= LOOK_NUL; /* NUL character in a file -> binary */
263 }else if( c=='\n' ){
264 flags |= LOOK_LF;
265 if( c2=='\r' ){
266 flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */
267 }else{
268 flags |= LOOK_LONE_LF;
269 }
270 if( j>UTF16_LENGTH_MASK ){
271 flags |= LOOK_LONG; /* Very long line -> binary */
272 }
273 j = 0;
274 }else if( c=='\r' ){
275 flags |= LOOK_CR;
276 if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){
277 flags |= LOOK_LONE_CR; /* More chars, next char is not LF */
278 }
279 }
280 }
281

Keyboard Shortcuts

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