src/highlighter.c

changeset 57
eba880c1705c
parent 55
bf54085ce341
child 61
47a5fc33590a
child 66
1b12cf799fee
equal deleted inserted replaced
56:81d99e9ceb20 57:eba880c1705c
71 return 1; 71 return 1;
72 } 72 }
73 73
74 /* Plaintext Highlighter */ 74 /* Plaintext Highlighter */
75 75
76 void c2html_plain_highlighter(char *src, UcxBuffer *dest, c2html_highlighter_data *hd) { 76 void c2html_plain_highlighter(char *src, UcxBuffer *dest,
77 c2html_highlighter_data *hd) {
77 while (*src && *src != '\n') { 78 while (*src && *src != '\n') {
78 put_htmlescaped(dest, *src); 79 if (*src != '\r') {
80 put_htmlescaped(dest, *src);
81 }
79 src++; 82 src++;
80 } 83 }
81 ucx_buffer_putc(dest, '\n'); 84 ucx_buffer_putc(dest, '\n');
82 } 85 }
83 86
89 "long", "register", "return", "short", "signed", "sizeof", "static", 92 "long", "register", "return", "short", "signed", "sizeof", "static",
90 "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", 93 "struct", "switch", "typedef", "union", "unsigned", "void", "volatile",
91 "while", NULL 94 "while", NULL
92 }; 95 };
93 96
94 void c2html_c_highlighter(char *src, UcxBuffer *dest, c2html_highlighter_data *hd) { 97 void c2html_c_highlighter(char *src, UcxBuffer *dest,
98 c2html_highlighter_data *hd) {
95 /* reset buffers without clearing them */ 99 /* reset buffers without clearing them */
96 hd->primary_buffer->size = hd->primary_buffer->pos = 0; 100 hd->primary_buffer->size = hd->primary_buffer->pos = 0;
97 hd->secondary_buffer->size = hd->secondary_buffer->pos = 0; 101 hd->secondary_buffer->size = hd->secondary_buffer->pos = 0;
98 102
99 /* alias the buffers for better handling */ 103 /* alias the buffers for better handling */
113 } 117 }
114 118
115 char c; 119 char c;
116 do { 120 do {
117 c = src[++sp]; 121 c = src[++sp];
122 if (c == '\r') continue;
118 123
119 /* comments */ 124 /* comments */
120 if (!isstring && c == '/') { 125 if (!isstring && c == '/') {
121 if (hd->multiline_comment && sp > 0 && src[sp-1] == '*') { 126 if (hd->multiline_comment && sp > 0 && src[sp-1] == '*') {
122 iscomment = 0; 127 iscomment = 0;
232 "transient", "catch", "extends", "int", "short", "try", "char", "final", 237 "transient", "catch", "extends", "int", "short", "try", "char", "final",
233 "interface", "static", "void", "class", "finally", "long", "strictfp", 238 "interface", "static", "void", "class", "finally", "long", "strictfp",
234 "volatile", "const", "float", "native", "super", "while", NULL 239 "volatile", "const", "float", "native", "super", "while", NULL
235 }; 240 };
236 241
237 void c2html_java_highlighter(char *src, UcxBuffer *dest, c2html_highlighter_data *hd) { 242 void c2html_java_highlighter(char *src, UcxBuffer *dest,
243 c2html_highlighter_data *hd) {
238 /* reset buffers without clearing them */ 244 /* reset buffers without clearing them */
239 hd->primary_buffer->size = hd->primary_buffer->pos = 0; 245 hd->primary_buffer->size = hd->primary_buffer->pos = 0;
240 hd->secondary_buffer->size = hd->secondary_buffer->pos = 0; 246 hd->secondary_buffer->size = hd->secondary_buffer->pos = 0;
241 247
242 /* alias the buffers for better handling */ 248 /* alias the buffers for better handling */
254 } 260 }
255 261
256 char c; 262 char c;
257 do { 263 do {
258 c = src[++sp]; 264 c = src[++sp];
265 if (c == '\r') continue;
259 266
260 /* comments */ 267 /* comments */
261 if (!isstring && c == '/') { 268 if (!isstring && c == '/') {
262 if (hd->multiline_comment && sp > 0 && src[sp-1] == '*') { 269 if (hd->multiline_comment && sp > 0 && src[sp-1] == '*') {
263 iscomment = 0; 270 iscomment = 0;

mercurial