src/ccodegen.c

Tue, 23 Aug 2016 15:28:56 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 23 Aug 2016 15:28:56 +0200
changeset 45
1f3835182aeb
parent 39
ac35daceb24c
child 46
534a4ef4143d
permissions
-rw-r--r--

changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet

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 #include <string.h>
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 #include <ctype.h>
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 const char* ckeywords[] = {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 "auto", "break", "case", "char", "const", "continue", "default", "do",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 "double", "else", "enum", "extern", "float", "for", "goto", "if", "int",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 "long", "register", "return", "short", "signed", "sizeof", "static",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 "struct", "switch", "typedef", "union", "unsigned", "void", "volatile",
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 "while", NULL
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 };
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41
36
be60c22cddfe fixed possible naming conflicts with is.* functions
Mike Becker <universe@uap-core.de>
parents: 35
diff changeset
42 int check_ctype(char *word, size_t len) {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 return (word[len-2] == '_' && word[len-1] == 't');
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45
36
be60c22cddfe fixed possible naming conflicts with is.* functions
Mike Becker <universe@uap-core.de>
parents: 35
diff changeset
46 int check_cdirective(char *word) {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 return (word[0] == '#');
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
50 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
51 dp += sizeof(str)-1
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
52
45
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
53 void cparseline(char *src, UcxBuffer *destbuf, highlighter_t *hltr) {
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
54 /* TODO: workaround for using old code with UcxBuffer */
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
55 char *dest = destbuf->space + destbuf->pos;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 memset(hltr->word, 0, WORDBUF_SIZE);
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
58 size_t wp = 0, ifp = 0, sp = (size_t)-1, dp = 0;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 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
60 char quote = '\0';
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 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
62
50ae611a785c fixed corrupted multi line comments, when a blank line (containing only white spaces) is present in the comment
universe
parents: 29
diff changeset
63 /* continue a multi line comment highlighting */
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 if (hltr->iscommentml) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 iscomment = 1;
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
66 memcpy_const(dest, dp, "<span class=\"c2html-comment\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68
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
69 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
70 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
71 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
72 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
73
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 /* comments */
26
05c3c6842aef fixed wrong comment formatting in strings
Mike Becker <universe@uap-core.de>
parents: 24
diff changeset
75 if (!isstring && c == '/') {
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
76 if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
77 iscomment = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78 hltr->iscommentml = 0;
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
79 memcpy_const(dest, dp, "/</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 continue;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81 } else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
82 iscomment = 1;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
83 hltr->iscommentml = (src[sp+1] == '*');
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
84 memcpy_const(dest, dp, "<span class=\"c2html-comment\">");
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 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
88 if (iscomment) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
89 if (c == '\n') {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
90 memcpy_const(dest, dp, "</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
91 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
92 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
93 } else if (isinclude) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
94 if (c == '<') {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
95 memcpy_const(dest, dp, "<span class=\"c2html-stdinclude\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
96 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
97 } else if (c == '\"') {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
98 if (parseinclude) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
99 dest[dp++] = '\"';
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
100 dest[dp++] = '>';
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
101 memcpy(&(dest[dp]), hltr->includefile, ifp);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
102 dp += ifp;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
103
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
104 dp = writeescapedchar(dest, dp, c);
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
105 memcpy_const(dest, dp, "</a>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
106 parseinclude = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
107 } else {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
108 memcpy_const(dest, dp,
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
109 "<a class=\"c2html-userinclude\" href=");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
110 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
111 ifp = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
112 hltr->includefile[ifp++] = '\"';
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 parseinclude = 1;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
114 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 } else if (c == '>') {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 dp = writeescapedchar(dest, dp, c);
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
117 memcpy_const(dest, dp, "</span>");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 if (parseinclude) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120 hltr->includefile[ifp++] = c;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 /* strings */
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 if (!isescaping && (c == '\'' || c == '\"')) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 if (isstring) {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
128 dp = writeescapedchar(dest, dp, c);
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
129 if (c == quote) {
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
130 isstring = 0;
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
131 memcpy_const(dest, dp, "</span>");
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
132 } else {
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
133 dp = writeescapedchar(dest, dp, c);
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
134 }
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135 } else {
28
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
136 isstring = 1;
1be8ea902ef4 fixed string highlighting when different quote symbol is in string
Mike Becker <universe@uap-core.de>
parents: 26
diff changeset
137 quote = c;
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
138 memcpy_const(dest, dp,
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
139 "<span class=\"c2html-string\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
140 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 if (isstring) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 } else if (!iswordcharacter(c)) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146 /* interpret word int_t */
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 if (wp > 0 && wp < WORDBUF_SIZE) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148 int closespan = 1;
36
be60c22cddfe fixed possible naming conflicts with is.* functions
Mike Becker <universe@uap-core.de>
parents: 35
diff changeset
149 if (check_keyword(hltr->word, hltr->keywords)) {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
150 memcpy_const(dest, dp,
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
151 "<span class=\"c2html-keyword\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
152 } else if (hltr->istype(hltr->word, wp)) {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
153 memcpy_const(dest, dp,
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
154 "<span class=\"c2html-type\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
155 } else if (hltr->isdirective(hltr->word)) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
156 isinclude = !strncmp(
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
157 "#include", hltr->word, WORDBUF_SIZE);
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
158 memcpy_const(dest, dp,
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
159 "<span class=\"c2html-directive\">");
36
be60c22cddfe fixed possible naming conflicts with is.* functions
Mike Becker <universe@uap-core.de>
parents: 35
diff changeset
160 } else if (check_capsonly(hltr->word, wp)) {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
161 memcpy_const(dest, dp,
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
162 "<span class=\"c2html-macroconst\">");
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 closespan = 0;
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 for (int i = 0 ; i < wp ; i++) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
167 dp = writeescapedchar(dest, dp, hltr->word[i]);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
168 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 if (closespan) {
29
ec6e97454e64 introduced macro for constant string memcpy + fixed string highlight fix
Mike Becker <universe@uap-core.de>
parents: 28
diff changeset
170 memcpy_const(dest, dp, "</span>");
21
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 memset(hltr->word, 0, WORDBUF_SIZE);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
174 wp = 0;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
175 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
176 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
177 /* read word */
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
178 if (wp < WORDBUF_SIZE) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
179 hltr->word[wp++] = c;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
180 } else if (wp == WORDBUF_SIZE) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
181 for (int i = 0 ; i < WORDBUF_SIZE ; i++) {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
182 dp = writeescapedchar(dest, dp, hltr->word[i]);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
183 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
184 wp++;
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
185 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
186 } else {
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
187 dp = writeescapedchar(dest, dp, c);
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190 }
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192 isescaping = !isescaping & (c == '\\');
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
193 }
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
194 } while (c != '\n');
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
195 dest[dp] = 0;
45
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
196
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
197 /* TODO: workaround */
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
198 destbuf->pos += dp;
1f3835182aeb changes signature of parser functions to use a UcxBuffer - the functions itself don't use the API yet
Mike Becker <universe@uap-core.de>
parents: 39
diff changeset
199 destbuf->size += dp;
21
537aec525835 structured source code
Mike Becker <universe@uap-core.de>
parents:
diff changeset
200 }

mercurial