Fossil

Check-in [c8eaeb1b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:styling
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | improve_commit_warning
Files: files | file ages | folders
SHA1: c8eaeb1b8a3f51d16dec612f20660acca6583795
User & Date: jan.nijtmans 2012-11-07 09:47:40
Context
2012-11-07
10:14
fix Abandoning warning check-in: 4d6ae5c0 user: jan.nijtmans tags: improve_commit_warning
09:47
styling check-in: c8eaeb1b user: jan.nijtmans tags: improve_commit_warning
09:43
merge trunk.

simplify utf-8 continuation byte checking, using a loop in stead of separater 2/3/4-byte versions.

check-in: 2f7ac60f user: jan.nijtmans tags: improve_commit_warning
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
  result |= 4;  /* Invalid 1-byte or multibyte UTF-8, continue */ \
}else do{ \
  /* Check if all continuation bytes >=0x80 and <0xC0 */ \
  if( n<2 || ((z[1]&0xC0)!=0x80) ){ \
    result |= 4; /* Invalid continuation byte, continue */ \
    break; \
  }else{ \
	/* prepare for checking remaining continuation bytes */ \
    c<<=2; --n; ++j; ++z; \
  } \
}while( c>=0xC0 );

/*
** This function attempts to scan each logical line within the blob to
** determine the type of content it appears to contain.  Possible return
................................................................................
  */
  if( n==0 ) return 1;  /* Empty file -> text */
  c = *z;
  j = (c!='\n');
  if( c>=0x80 ){
    CHECKUTF8(c)
  } else if( c==0 ){
    return 0;  /* Zero byte in a file -> binary */ \
  }
  while( --n>0 ){
    c = *++z; ++j;
    if( c>=0x80 ){
      CHECKUTF8(c)
    } else if( c==0 ){
      return 0;  /* Zero byte in a file -> binary */ \
    } else if( c=='\n' ){
      if( z[-1]=='\r' ){
        result |= 2;  /* Contains CR/NL, continue */
      }
      if( j>LENGTH_MASK ){
        return -4;  /* Very long line -> binary */
      }







|







 







|






|







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
  result |= 4;  /* Invalid 1-byte or multibyte UTF-8, continue */ \
}else do{ \
  /* Check if all continuation bytes >=0x80 and <0xC0 */ \
  if( n<2 || ((z[1]&0xC0)!=0x80) ){ \
    result |= 4; /* Invalid continuation byte, continue */ \
    break; \
  }else{ \
    /* prepare for checking remaining continuation bytes */ \
    c<<=2; --n; ++j; ++z; \
  } \
}while( c>=0xC0 );

/*
** This function attempts to scan each logical line within the blob to
** determine the type of content it appears to contain.  Possible return
................................................................................
  */
  if( n==0 ) return 1;  /* Empty file -> text */
  c = *z;
  j = (c!='\n');
  if( c>=0x80 ){
    CHECKUTF8(c)
  } else if( c==0 ){
    return 0;  /* Zero byte in a file -> binary */
  }
  while( --n>0 ){
    c = *++z; ++j;
    if( c>=0x80 ){
      CHECKUTF8(c)
    } else if( c==0 ){
      return 0;  /* Zero byte in a file -> binary */
    } else if( c=='\n' ){
      if( z[-1]=='\r' ){
        result |= 2;  /* Contains CR/NL, continue */
      }
      if( j>LENGTH_MASK ){
        return -4;  /* Very long line -> binary */
      }