Fossil

Check-in [1ca59832]
Login

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

Overview
Comment:Slightly more efficient than previous commit
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1ca598325e65101444daf14effd9b4e42b78ea47
User & Date: jan.nijtmans 2016-06-10 12:03:47
Context
2016-06-10
12:46
Add the --include and --exclude options to the tarball and zip commands and the in= and ex= query parameters to the /tarball and /zip webpages. check-in: ef449a11 user: drh tags: trunk
12:03
Slightly more efficient than previous commit check-in: 1ca59832 user: jan.nijtmans tags: trunk
11:49
Add many test-cases of (possible) invalid UTF-8 sequences check-in: acf7fe47 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lookslike.c.

160
161
162
163
164
165
166
167
168
169
170
171
172
173

174
175
176
177
178
179
180
    c = *++z;
    if( c2>=0x80 ){
      if( ((c2<0xc2) || (c2>=0xf4) || ((c&0xc0)!=0x80)) &&
          (((c2!=0xf4) || (c>=0x90)) && ((c2!=0xc0) || (c!=0x80))) ){
        return LOOK_INVALID; /* Invalid UTF-8 */
      }
      if( c2>=0xe0 ){
        if( c2>=0xf0 ){
          if (c2==0xf0 && c<0x90) return LOOK_INVALID; /* Invalid UTF-8 */
          c = (c2<<1)|3;
        }else{
          if (c2==0xe0 && c<0xa0) return LOOK_INVALID; /* Invalid UTF-8 */
          c = (c2<<1)|3;
        }

      }else{
        c = ' ';
      }
    }
  }
  return (c>=0x80) ? LOOK_INVALID : 0; /* Last byte must be ASCII. */
}







|
|
<
<
<
<

>







160
161
162
163
164
165
166
167
168




169
170
171
172
173
174
175
176
177
    c = *++z;
    if( c2>=0x80 ){
      if( ((c2<0xc2) || (c2>=0xf4) || ((c&0xc0)!=0x80)) &&
          (((c2!=0xf4) || (c>=0x90)) && ((c2!=0xc0) || (c!=0x80))) ){
        return LOOK_INVALID; /* Invalid UTF-8 */
      }
      if( c2>=0xe0 ){
        if ((c2==0xf0 && c<0x90)||(c2==0xe0 && c<0xa0)){
          return LOOK_INVALID; /* Invalid UTF-8, too short */




        }
        c = (c2<<1)|3;
      }else{
        c = ' ';
      }
    }
  }
  return (c>=0x80) ? LOOK_INVALID : 0; /* Last byte must be ASCII. */
}