Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Simplify the looks_like_binary() macro. Remove literal tab character, adjust styling and comments in looks_like_text(). |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
c8e72df08eeaeac71f4c64c31af4294d |
| User & Date: | mistachkin 2012-10-28 23:01:39.209 |
Context
|
2012-10-29
| ||
| 14:35 | fix "possible unresolved merge conflict" warning message to show the pathname relative to the wd in stead of the root ... (check-in: 2a15d87edb user: jan.nijtmans tags: trunk) | |
| 08:27 | merge trunk ... (check-in: f61d0a1c50 user: jan.nijtmans tags: use-blob_strip_bom) | |
|
2012-10-28
| ||
| 23:01 | Simplify the looks_like_binary() macro. Remove literal tab character, adjust styling and comments in looks_like_text(). ... (check-in: c8e72df08e user: mistachkin tags: trunk) | |
| 22:37 | missing <tr> tag ... (check-in: b2204034ec user: jan.nijtmans tags: trunk) | |
Changes
Changes to src/diff.c.
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
*/
#define DIFF_CANNOT_COMPUTE_BINARY \
"cannot compute difference between binary files\n"
#define DIFF_CANNOT_COMPUTE_SYMLINK \
"cannot compute difference between symlink and regular file\n"
| | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
*/
#define DIFF_CANNOT_COMPUTE_BINARY \
"cannot compute difference between binary files\n"
#define DIFF_CANNOT_COMPUTE_SYMLINK \
"cannot compute difference between symlink and regular file\n"
#define looks_like_binary(blob) (looks_like_text((blob)) == 0)
#endif /* INTERFACE */
/*
** Maximum length of a line in a text file. (8192)
*/
#define LENGTH_MASK_SZ 13
#define LENGTH_MASK ((1<<LENGTH_MASK_SZ)-1)
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 |
** contains a line that is too long
** Returns -1, if the file appears text, but it contains CrLf
*/
int looks_like_text(const Blob *pContent){
const char *z = blob_buffer(pContent);
unsigned int n = blob_size(pContent);
int j, c;
| | | | | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
** contains a line that is too long
** Returns -1, if the file appears text, but it contains CrLf
*/
int looks_like_text(const Blob *pContent){
const char *z = blob_buffer(pContent);
unsigned int n = blob_size(pContent);
int j, c;
int result = 1; /* Assume text with no CrLf */
/* Check individual lines.
*/
if( n==0 ) return result; /* Empty file -> text */
c = *z;
if( c==0 ) return 0; /* \000 byte in a file -> binary */
j = (c!='\n');
while( --n>0 ){
c = *++z; ++j;
if( c==0 ) return 0; /* \000 byte in a file -> binary */
if( c=='\n' ){
if( z[-1]=='\r' ){
result = -1; /* Contains CrLf, continue */
}
if( j>LENGTH_MASK ){
return 0; /* Very long line -> binary */
}
j = 0;
}
}
if( j>LENGTH_MASK ){
return 0; /* Very long line -> binary */
}
return result; /* No problems seen -> not binary */
}
/*
** Return true if two DLine elements are identical.
*/
static int same_dline(DLine *pA, DLine *pB){
return pA->h==pB->h && memcmp(pA->z,pB->z,pA->h & LENGTH_MASK)==0;
|
| ︙ | ︙ |