Fossil SCM

Put html_tag const table (from markdown implementation) in constant memory.

jan.nijtmans 2014-01-27 08:23 trunk
Commit 7c4414ca10e9f24216b7443f25dc89fb60d93447
1 file changed +6 -6
+6 -6
--- src/markdown.c
+++ src/markdown.c
@@ -161,11 +161,11 @@
161161
};
162162
163163
164164
/* html_tag -- structure for quick HTML tag search (inspired from discount) */
165165
struct html_tag {
166
- char *text;
166
+ const char *text;
167167
int size;
168168
};
169169
170170
171171
@@ -172,11 +172,11 @@
172172
/********************
173173
* GLOBAL VARIABLES *
174174
********************/
175175
176176
/* block_tags -- recognised block tags, sorted by cmp_html_tag */
177
-static struct html_tag block_tags[] = {
177
+static const struct html_tag block_tags[] = {
178178
{ "p", 1 },
179179
{ "dl", 2 },
180180
{ "h1", 2 },
181181
{ "h2", 2 },
182182
{ "h3", 2 },
@@ -276,11 +276,11 @@
276276
return fossil_strnicmp(hta->text, htb->text, hta->size);
277277
}
278278
279279
280280
/* find_block_tag -- returns the current block tag */
281
-static struct html_tag *find_block_tag(char *data, size_t size){
281
+static const struct html_tag *find_block_tag(const char *data, size_t size){
282282
size_t i = 0;
283283
struct html_tag key;
284284
285285
/* looking for the word end */
286286
while( i<size
@@ -1070,11 +1070,11 @@
10701070
/*********************************
10711071
* BLOCK-LEVEL PARSING FUNCTIONS *
10721072
*********************************/
10731073
10741074
/* is_empty -- returns the line length when it is empty, 0 otherwise */
1075
-static size_t is_empty(char *data, size_t size){
1075
+static size_t is_empty(const char *data, size_t size){
10761076
size_t i;
10771077
for(i=0; i<size && data[i]!='\n'; i++){
10781078
if( data[i]!=' ' && data[i]!='\t' ) return 0;
10791079
}
10801080
return i+1;
@@ -1631,11 +1631,11 @@
16311631
}
16321632
16331633
16341634
/* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */
16351635
/* returns the length on match, 0 otherwise */
1636
-static size_t htmlblock_end(struct html_tag *tag, char *data, size_t size){
1636
+static size_t htmlblock_end(const struct html_tag *tag, const char *data, size_t size){
16371637
size_t i, w;
16381638
16391639
/* assuming data[0]=='<' && data[1]=='/' already tested */
16401640
16411641
/* checking tag is a match */
@@ -1668,11 +1668,11 @@
16681668
struct render *rndr,
16691669
char *data,
16701670
size_t size
16711671
){
16721672
size_t i, j = 0;
1673
- struct html_tag *curtag;
1673
+ const struct html_tag *curtag;
16741674
int found;
16751675
size_t work_size = 0;
16761676
struct Blob work = BLOB_INITIALIZER;
16771677
16781678
/* identification of the opening tag */
16791679
--- src/markdown.c
+++ src/markdown.c
@@ -161,11 +161,11 @@
161 };
162
163
164 /* html_tag -- structure for quick HTML tag search (inspired from discount) */
165 struct html_tag {
166 char *text;
167 int size;
168 };
169
170
171
@@ -172,11 +172,11 @@
172 /********************
173 * GLOBAL VARIABLES *
174 ********************/
175
176 /* block_tags -- recognised block tags, sorted by cmp_html_tag */
177 static struct html_tag block_tags[] = {
178 { "p", 1 },
179 { "dl", 2 },
180 { "h1", 2 },
181 { "h2", 2 },
182 { "h3", 2 },
@@ -276,11 +276,11 @@
276 return fossil_strnicmp(hta->text, htb->text, hta->size);
277 }
278
279
280 /* find_block_tag -- returns the current block tag */
281 static struct html_tag *find_block_tag(char *data, size_t size){
282 size_t i = 0;
283 struct html_tag key;
284
285 /* looking for the word end */
286 while( i<size
@@ -1070,11 +1070,11 @@
1070 /*********************************
1071 * BLOCK-LEVEL PARSING FUNCTIONS *
1072 *********************************/
1073
1074 /* is_empty -- returns the line length when it is empty, 0 otherwise */
1075 static size_t is_empty(char *data, size_t size){
1076 size_t i;
1077 for(i=0; i<size && data[i]!='\n'; i++){
1078 if( data[i]!=' ' && data[i]!='\t' ) return 0;
1079 }
1080 return i+1;
@@ -1631,11 +1631,11 @@
1631 }
1632
1633
1634 /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */
1635 /* returns the length on match, 0 otherwise */
1636 static size_t htmlblock_end(struct html_tag *tag, char *data, size_t size){
1637 size_t i, w;
1638
1639 /* assuming data[0]=='<' && data[1]=='/' already tested */
1640
1641 /* checking tag is a match */
@@ -1668,11 +1668,11 @@
1668 struct render *rndr,
1669 char *data,
1670 size_t size
1671 ){
1672 size_t i, j = 0;
1673 struct html_tag *curtag;
1674 int found;
1675 size_t work_size = 0;
1676 struct Blob work = BLOB_INITIALIZER;
1677
1678 /* identification of the opening tag */
1679
--- src/markdown.c
+++ src/markdown.c
@@ -161,11 +161,11 @@
161 };
162
163
164 /* html_tag -- structure for quick HTML tag search (inspired from discount) */
165 struct html_tag {
166 const char *text;
167 int size;
168 };
169
170
171
@@ -172,11 +172,11 @@
172 /********************
173 * GLOBAL VARIABLES *
174 ********************/
175
176 /* block_tags -- recognised block tags, sorted by cmp_html_tag */
177 static const struct html_tag block_tags[] = {
178 { "p", 1 },
179 { "dl", 2 },
180 { "h1", 2 },
181 { "h2", 2 },
182 { "h3", 2 },
@@ -276,11 +276,11 @@
276 return fossil_strnicmp(hta->text, htb->text, hta->size);
277 }
278
279
280 /* find_block_tag -- returns the current block tag */
281 static const struct html_tag *find_block_tag(const char *data, size_t size){
282 size_t i = 0;
283 struct html_tag key;
284
285 /* looking for the word end */
286 while( i<size
@@ -1070,11 +1070,11 @@
1070 /*********************************
1071 * BLOCK-LEVEL PARSING FUNCTIONS *
1072 *********************************/
1073
1074 /* is_empty -- returns the line length when it is empty, 0 otherwise */
1075 static size_t is_empty(const char *data, size_t size){
1076 size_t i;
1077 for(i=0; i<size && data[i]!='\n'; i++){
1078 if( data[i]!=' ' && data[i]!='\t' ) return 0;
1079 }
1080 return i+1;
@@ -1631,11 +1631,11 @@
1631 }
1632
1633
1634 /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */
1635 /* returns the length on match, 0 otherwise */
1636 static size_t htmlblock_end(const struct html_tag *tag, const char *data, size_t size){
1637 size_t i, w;
1638
1639 /* assuming data[0]=='<' && data[1]=='/' already tested */
1640
1641 /* checking tag is a match */
@@ -1668,11 +1668,11 @@
1668 struct render *rndr,
1669 char *data,
1670 size_t size
1671 ){
1672 size_t i, j = 0;
1673 const struct html_tag *curtag;
1674 int found;
1675 size_t work_size = 0;
1676 struct Blob work = BLOB_INITIALIZER;
1677
1678 /* identification of the opening tag */
1679

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button