Fossil SCM
Restore original definitions of the 'LOOK_*' flags.
Commit
3161968463c0c6d59d2dee4b7349f00e45a29fe0
Parent
ea63a2d1f409581…
1 file changed
+19
-13
+19
-13
| --- src/lookslike.c | ||
| +++ src/lookslike.c | ||
| @@ -37,21 +37,21 @@ | ||
| 37 | 37 | ** Output flags for the looks_like_utf8() and looks_like_utf16() routines used |
| 38 | 38 | ** to convey status information about the blob content. |
| 39 | 39 | */ |
| 40 | 40 | #define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */ |
| 41 | 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. */ | |
| 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. */ | |
| 49 | 51 | #define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */ |
| 50 | 52 | #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 | 53 | #endif /* INTERFACE */ |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | /* |
| 57 | 57 | ** This function attempts to scan each logical line within the blob to |
| @@ -93,32 +93,35 @@ | ||
| 93 | 93 | if( n==0 ) return flags; /* Empty file -> text */ |
| 94 | 94 | c = *z; |
| 95 | 95 | if( c==0 ){ |
| 96 | 96 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 97 | 97 | }else if( c=='\r' ){ |
| 98 | + flags |= LOOK_CR; | |
| 98 | 99 | if( n<=1 || z[1]!='\n' ){ |
| 99 | 100 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 100 | 101 | } |
| 101 | 102 | } |
| 102 | 103 | 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 */ | |
| 104 | 105 | while( !(flags&stopFlags) && --n>0 ){ |
| 105 | 106 | int c2 = c; |
| 106 | 107 | c = *++z; ++j; |
| 107 | 108 | if( c==0 ){ |
| 108 | 109 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 109 | 110 | }else if( c=='\n' ){ |
| 111 | + flags |= LOOK_LF; | |
| 110 | 112 | if( c2=='\r' ){ |
| 111 | - flags |= (LOOK_CRLF); /* Found LF preceded by CR */ | |
| 113 | + flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */ | |
| 112 | 114 | }else{ |
| 113 | 115 | flags |= LOOK_LONE_LF; |
| 114 | 116 | } |
| 115 | 117 | if( j>LENGTH_MASK ){ |
| 116 | 118 | flags |= LOOK_LONG; /* Very long line -> binary */ |
| 117 | 119 | } |
| 118 | 120 | j = 0; |
| 119 | 121 | }else if( c=='\r' ){ |
| 122 | + flags |= LOOK_CR; | |
| 120 | 123 | if( n<=1 || z[1]!='\n' ){ |
| 121 | 124 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 122 | 125 | } |
| 123 | 126 | } |
| 124 | 127 | } |
| @@ -239,16 +242,17 @@ | ||
| 239 | 242 | c = UTF16_SWAP(c); |
| 240 | 243 | } |
| 241 | 244 | if( c==0 ){ |
| 242 | 245 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 243 | 246 | }else if( c=='\r' ){ |
| 247 | + flags |= LOOK_CR; | |
| 244 | 248 | if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){ |
| 245 | 249 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 246 | 250 | } |
| 247 | 251 | } |
| 248 | 252 | 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 */ | |
| 250 | 254 | while( !(flags&stopFlags) && ((n-=sizeof(WCHAR_T))>=sizeof(WCHAR_T)) ){ |
| 251 | 255 | int c2 = c; |
| 252 | 256 | c = *++z; |
| 253 | 257 | if( bReverse ){ |
| 254 | 258 | c = UTF16_SWAP(c); |
| @@ -255,20 +259,22 @@ | ||
| 255 | 259 | } |
| 256 | 260 | ++j; |
| 257 | 261 | if( c==0 ){ |
| 258 | 262 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 259 | 263 | }else if( c=='\n' ){ |
| 264 | + flags |= LOOK_LF; | |
| 260 | 265 | if( c2=='\r' ){ |
| 261 | - flags |= (LOOK_CRLF); /* Found LF preceded by CR */ | |
| 266 | + flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */ | |
| 262 | 267 | }else{ |
| 263 | 268 | flags |= LOOK_LONE_LF; |
| 264 | 269 | } |
| 265 | 270 | if( j>UTF16_LENGTH_MASK ){ |
| 266 | 271 | flags |= LOOK_LONG; /* Very long line -> binary */ |
| 267 | 272 | } |
| 268 | 273 | j = 0; |
| 269 | 274 | }else if( c=='\r' ){ |
| 275 | + flags |= LOOK_CR; | |
| 270 | 276 | if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){ |
| 271 | 277 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 272 | 278 | } |
| 273 | 279 | } |
| 274 | 280 | } |
| 275 | 281 |
| --- 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 |