src/ccodegen.c

Tue, 23 Aug 2016 17:31:15 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 23 Aug 2016 17:31:15 +0200
changeset 49
f86f0b054464
parent 48
b2724c711203
child 50
17408c3607ce
permissions
-rw-r--r--

cleans up includes

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
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
40 void c_highlighter(char *src, UcxBuffer *dest, int *multiline_comment) {
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
41 /* TODO: try to replace these buffers */
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
42 char wordbuf[WORDBUF_SIZE];
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
43 sstr_t word;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
44 word.ptr = wordbuf; word.length = 0;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
45
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
46 char includefilebuf[512];
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
47 sstr_t includefile;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
48 includefile.ptr = includefilebuf;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
49 includefile.length = 0;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
50
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
51 size_t sp = (size_t)-1;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 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
53 char quote = '\0';
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 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
55
50ae611a785c fixed corrupted multi line comments, when a blank line (containing only white spaces) is present in the comment
universe
parents: 29
diff changeset
56 /* continue a multi line comment highlighting */
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
57 if (*multiline_comment) {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 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
59 ucx_buffer_puts(dest, "<span class=\"c2html-comment\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61
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
62 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
63 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
64 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
65 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
66
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 /* comments */
26
05c3c6842aef fixed wrong comment formatting in strings
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
68 if (!isstring && c == '/') {
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
69 if (*multiline_comment && sp > 0 && src[sp-1] == '*') {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 iscomment = 0;
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
71 *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
72 ucx_buffer_puts(dest, "/</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 continue;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 } else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
75 iscomment = 1;
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
76 *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
77 ucx_buffer_puts(dest, "<span class=\"c2html-comment\">");
21
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
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 if (iscomment) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 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
83 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
84 } else {
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
85 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87 } else if (isinclude) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 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
89 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
90 "<span class=\"c2html-stdinclude\">&lt;");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 } else if (c == '\"') {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 if (parseinclude) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
93 ucx_bprintf(dest, "\">%.*s\"</a>",
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
94 includefile.length, includefile.ptr);
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=\"");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
99 includefile.length = 0;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
100 includefile.ptr[includefile.length++] = '\"';
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 parseinclude = 1;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103 } 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
104 ucx_buffer_puts(dest, "&gt;</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
105 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 if (parseinclude) {
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
107 includefile.ptr[includefile.length++] = c;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
108 }
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
109 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 /* strings */
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 if (!isescaping && (c == '\'' || c == '\"')) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 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
115 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
116 if (c == quote) {
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
117 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
118 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
119 } 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
120 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
121 }
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 } else {
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
123 isstring = 1;
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
124 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
125 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
126 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 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
130 put_htmlescaped(dest, c);
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
131 } else if (!check_alnumex(c)) {
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
132 if (word.length > 0 && word.length < WORDBUF_SIZE) {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 int closespan = 1;
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
134 sstr_t typesuffix = ST("_t");
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
135 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
136 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
137 "<span class=\"c2html-keyword\">");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
138 } 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
139 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
140 "<span class=\"c2html-type\">");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
141 } else if (word.ptr[0] == '#') {
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
142 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
143 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
144 "<span class=\"c2html-directive\">");
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
145 } 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
146 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
147 "<span class=\"c2html-macroconst\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
149 closespan = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
150 }
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
151 put_htmlescapedstr(dest, word);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 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
153 ucx_buffer_puts(dest, "</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
154 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 }
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
156 word.length = 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
157 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
158 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
159 /* read word */
47
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
160 if (word.length < WORDBUF_SIZE) {
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
161 word.ptr[word.length++] = c;
c39ecbbca7c0 words (token) are now stored as sstr_t
Mike Becker <universe@uap-core.de>
parents: 46
diff changeset
162 } else if (word.length == WORDBUF_SIZE) {
48
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
163 /* TODO: this will be removed */
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
164 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
165 "!!! WARNING - WORD TOO LONG TO PARSE !!!");
b2724c711203 highlighter now use the UcxBuffer API for writing to the destination buffer
Mike Becker <universe@uap-core.de>
parents: 47
diff changeset
166 word.length = 0;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 } 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
168 put_htmlescaped(dest, c);
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
170 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
171 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173 isescaping = !isescaping & (c == '\\');
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 }
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
175 } while (c != '\n');
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 }

mercurial