src/ccodegen.c

Thu, 25 Aug 2016 12:16:57 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 25 Aug 2016 12:16:57 +0200
changeset 51
f25ba6fd7a08
parent 50
17408c3607ce
permissions
-rw-r--r--

replaces stack buffers with UCX buffers

21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
35
abaf2489c549 adjusted copyright info
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
4 * Copyright 2016 Mike Becker. All rights reserved.
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 *
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 */
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 #include "ccodegen.h"
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 const char* ckeywords[] = {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 "auto", "break", "case", "char", "const", "continue", "default", "do",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 "double", "else", "enum", "extern", "float", "for", "goto", "if", "int",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 "long", "register", "return", "short", "signed", "sizeof", "static",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 "struct", "switch", "typedef", "union", "unsigned", "void", "volatile",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 "while", NULL
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 };
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
40 void c_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) {
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
41 /* reset buffers without clearing them */
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
42 hd->primary_buffer->size = hd->primary_buffer->pos = 0;
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
43 hd->secondary_buffer->size = hd->secondary_buffer->pos = 0;
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
44
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
45 /* alias the buffers for better handling */
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
46 UcxBuffer *wbuf = hd->primary_buffer;
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
47 UcxBuffer *ifilebuf = hd->secondary_buffer;
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
48
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
49 /* local information */
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
50 size_t sp = (size_t)-1;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
52 char quote = '\0';
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 int isescaping = 0;
31
50ae611a785c fixed corrupted multi line comments, when a blank line (containing only white spaces) is present in the comment
universe
parents: 29
diff changeset
54
50ae611a785c fixed corrupted multi line comments, when a blank line (containing only white spaces) is present in the comment
universe
parents: 29
diff changeset
55 /* continue a multi line comment highlighting */
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
56 if (hd->multiline_comment) {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 iscomment = 1;
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
58 ucx_buffer_puts(dest, "<span class=\"c2html-comment\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60
39
ac35daceb24c adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
61 char c;
ac35daceb24c adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
62 do {
ac35daceb24c adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
63 c = src[++sp];
ac35daceb24c adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
64 if (!c) break;
ac35daceb24c adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
65
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 /* comments */
26
05c3c6842aef fixed wrong comment formatting in strings
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
67 if (!isstring && c == '/') {
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
68 if (hd->multiline_comment && sp > 0 && src[sp-1] == '*') {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 iscomment = 0;
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
70 hd->multiline_comment = 0;
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
71 ucx_buffer_puts(dest, "/</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 continue;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 } else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 iscomment = 1;
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
75 hd->multiline_comment = (src[sp+1] == '*');
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
76 ucx_buffer_puts(dest, "<span class=\"c2html-comment\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
79
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 if (iscomment) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 if (c == '\n') {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
82 ucx_buffer_puts(dest, "</span>\n");
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
83 } else {
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
84 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 } else if (isinclude) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 if (c == '<') {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
88 ucx_buffer_puts(dest,
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
89 "<span class=\"c2html-stdinclude\">&lt;");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
90 } else if (c == '\"') {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 if (parseinclude) {
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
92 ucx_buffer_puts(dest, "\">");
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
93 ucx_buffer_write(ifilebuf->space, 1, ifilebuf->size, dest);
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
94 ucx_buffer_puts(dest, "\"</a>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
95 parseinclude = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 } else {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
97 ucx_buffer_puts(dest,
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
98 "<a class=\"c2html-userinclude\" href=\"");
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
99 ucx_buffer_putc(ifilebuf, '\"');
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 parseinclude = 1;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 } else if (c == '>') {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
103 ucx_buffer_puts(dest, "&gt;</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 if (parseinclude) {
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
106 ucx_buffer_putc(ifilebuf, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 }
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
108 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
109 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 /* strings */
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 if (!isescaping && (c == '\'' || c == '\"')) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 if (isstring) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
114 put_htmlescaped(dest, c);
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
115 if (c == quote) {
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
116 isstring = 0;
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
117 ucx_buffer_puts(dest, "</span>");
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
118 } else {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
119 put_htmlescaped(dest, c);
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
120 }
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 } else {
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
122 isstring = 1;
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
123 quote = c;
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
124 ucx_buffer_puts(dest, "<span class=\"c2html-string\">");
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
125 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 if (isstring) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
129 put_htmlescaped(dest, c);
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
130 } else if (!isalnum(c) && c!='_' && c!='#') {
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
131 /* write buffered word, if any */
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
132 if (wbuf->size > 0) {
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
133 sstr_t word = sstrn(wbuf->space, wbuf->size);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 int closespan = 1;
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
135 sstr_t typesuffix = ST("_t");
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
136 if (check_keyword(word, ckeywords)) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
137 ucx_buffer_puts(dest,
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
138 "<span class=\"c2html-keyword\">");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
139 } else if (sstrsuffix(word, typesuffix)) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
140 ucx_buffer_puts(dest,
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
141 "<span class=\"c2html-type\">");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
142 } else if (word.ptr[0] == '#') {
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
143 isinclude = !sstrcmp(word, S("#include"));
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
144 ucx_buffer_puts(dest,
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
145 "<span class=\"c2html-directive\">");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
146 } else if (check_capsonly(word)) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
147 ucx_buffer_puts(dest,
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
148 "<span class=\"c2html-macroconst\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 closespan = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
151 }
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
152 put_htmlescapedstr(dest, word);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
153 if (closespan) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
154 ucx_buffer_puts(dest, "</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 }
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
157 wbuf->pos = wbuf->size = 0; /* reset word buffer */
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
158
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
159 /* write current character */
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
160 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
161 } else {
51
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
162 /* buffer the current word */
f25ba6fd7a08 replaces stack buffers with UCX buffers
Mike Becker <universe@uap-core.de>
parents: 50
diff changeset
163 ucx_buffer_putc(wbuf, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 isescaping = !isescaping & (c == '\\');
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 }
39
ac35daceb24c adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents: 36
diff changeset
169 } while (c != '\n');
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 }

mercurial