Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Performance optimization in the htmlize() utility routine. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
4c1d38f97b4ecf18ae95f36c42936dd5 |
| User & Date: | drh 2020-11-21 21:04:34.617 |
Context
|
2020-11-22
| ||
| 06:54 | Added named anchors in the /fileedit doc page. check-in: 66851cd6bc user: wyoung tags: trunk | |
|
2020-11-21
| ||
| 21:04 | Performance optimization in the htmlize() utility routine. check-in: 4c1d38f97b user: drh tags: trunk | |
| 19:46 | More aggressive reuse of prepared statements for improved performance. check-in: f044cf2a91 user: drh tags: trunk | |
Changes
Changes to src/encode.c.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 | ** Make the given string safe for HTML by converting every "<" into "<", ** every ">" into ">" and every "&" into "&". Return a pointer ** to a new string obtained from malloc(). ** ** We also encode " as " and ' as ' so they can appear as an argument ** to markup. */ | | | | > | | | | | | | | | | > > > > > | > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
** Make the given string safe for HTML by converting every "<" into "<",
** every ">" into ">" and every "&" into "&". Return a pointer
** to a new string obtained from malloc().
**
** We also encode " as " and ' as ' so they can appear as an argument
** to markup.
*/
char *htmlize(const char *z, int n){
unsigned char c;
int i = 0;
int count = 0;
unsigned char *zOut;
const unsigned char *zIn = (const unsigned char*)z;
if( n<0 ) n = strlen(z);
while( i<n ){
switch( zIn[i] ){
case '<': count += 3; break;
case '>': count += 3; break;
case '&': count += 4; break;
case '"': count += 5; break;
case '\'': count += 4; break;
case 0: n = i; break;
}
i++;
}
i = 0;
zOut = fossil_malloc( count+n+1 );
if( count==0 ){
memcpy(zOut, zIn, n);
zOut[n] = 0;
return (char*)zOut;
}
while( n-->0 ){
c = *(zIn++);
switch( c ){
case '<':
zOut[i++] = '&';
zOut[i++] = 'l';
zOut[i++] = 't';
zOut[i++] = ';';
break;
|
| ︙ | ︙ | |||
84 85 86 87 88 89 90 |
zOut[i++] = '9';
zOut[i++] = ';';
break;
default:
zOut[i++] = c;
break;
}
| < | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
zOut[i++] = '9';
zOut[i++] = ';';
break;
default:
zOut[i++] = c;
break;
}
}
zOut[i] = 0;
return (char*)zOut;
}
/*
** Append HTML-escaped text to a Blob.
*/
void htmlize_to_blob(Blob *p, const char *zIn, int n){
int c, i, j;
|
| ︙ | ︙ |