| | @@ -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_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. */ |
| 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. */ |
| 51 | 49 | #define LOOK_BINARY (LOOK_NUL | LOOK_LONG | LOOK_SHORT) /* May be binary. */ |
| 52 | 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 were found. */ |
| 52 | +#define LOOK_LF (LOOK_LONE_LF | LOOK_CRLF) /* One or more LF chars were found. */ |
| 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,11 +93,10 @@ |
| 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; |
| 99 | 98 | if( n<=1 || z[1]!='\n' ){ |
| 100 | 99 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 101 | 100 | } |
| 102 | 101 | } |
| 103 | 102 | j = (c!='\n'); |
| | @@ -106,11 +105,10 @@ |
| 106 | 105 | int c2 = c; |
| 107 | 106 | c = *++z; ++j; |
| 108 | 107 | if( c==0 ){ |
| 109 | 108 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 110 | 109 | }else if( c=='\n' ){ |
| 111 | | - flags |= LOOK_LF; |
| 112 | 110 | if( c2=='\r' ){ |
| 113 | 111 | flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */ |
| 114 | 112 | }else{ |
| 115 | 113 | flags |= LOOK_LONE_LF; |
| 116 | 114 | } |
| | @@ -117,11 +115,10 @@ |
| 117 | 115 | if( j>LENGTH_MASK ){ |
| 118 | 116 | flags |= LOOK_LONG; /* Very long line -> binary */ |
| 119 | 117 | } |
| 120 | 118 | j = 0; |
| 121 | 119 | }else if( c=='\r' ){ |
| 122 | | - flags |= LOOK_CR; |
| 123 | 120 | if( n<=1 || z[1]!='\n' ){ |
| 124 | 121 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 125 | 122 | } |
| 126 | 123 | } |
| 127 | 124 | } |
| | @@ -242,11 +239,10 @@ |
| 242 | 239 | c = UTF16_SWAP(c); |
| 243 | 240 | } |
| 244 | 241 | if( c==0 ){ |
| 245 | 242 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 246 | 243 | }else if( c=='\r' ){ |
| 247 | | - flags |= LOOK_CR; |
| 248 | 244 | if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){ |
| 249 | 245 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 250 | 246 | } |
| 251 | 247 | } |
| 252 | 248 | j = (c!='\n'); |
| | @@ -259,11 +255,10 @@ |
| 259 | 255 | } |
| 260 | 256 | ++j; |
| 261 | 257 | if( c==0 ){ |
| 262 | 258 | flags |= LOOK_NUL; /* NUL character in a file -> binary */ |
| 263 | 259 | }else if( c=='\n' ){ |
| 264 | | - flags |= LOOK_LF; |
| 265 | 260 | if( c2=='\r' ){ |
| 266 | 261 | flags |= (LOOK_CR | LOOK_CRLF); /* Found LF preceded by CR */ |
| 267 | 262 | }else{ |
| 268 | 263 | flags |= LOOK_LONE_LF; |
| 269 | 264 | } |
| | @@ -270,11 +265,10 @@ |
| 270 | 265 | if( j>UTF16_LENGTH_MASK ){ |
| 271 | 266 | flags |= LOOK_LONG; /* Very long line -> binary */ |
| 272 | 267 | } |
| 273 | 268 | j = 0; |
| 274 | 269 | }else if( c=='\r' ){ |
| 275 | | - flags |= LOOK_CR; |
| 276 | 270 | if( n<(2*sizeof(WCHAR_T)) || UTF16_SWAP_IF(bReverse, z[1])!='\n' ){ |
| 277 | 271 | flags |= LOOK_LONE_CR; /* More chars, next char is not LF */ |
| 278 | 272 | } |
| 279 | 273 | } |
| 280 | 274 | } |
| 281 | 275 | |