src/c2html.c

changeset 47
c39ecbbca7c0
parent 46
534a4ef4143d
child 48
b2724c711203
equal deleted inserted replaced
46:534a4ef4143d 47:c39ecbbca7c0
46 " -V, -v Prints version and exits\n" 46 " -V, -v Prints version and exits\n"
47 "\n"); 47 "\n");
48 } 48 }
49 49
50 /* TODO: remove this workaround after refactoring highlighter structure */ 50 /* TODO: remove this workaround after refactoring highlighter structure */
51 static void plainparseline(char *src, UcxBuffer *dest, HighlighterData* hltr) { 51 static void plainparseline(char *src, UcxBuffer *dest, int* x) {
52 size_t dp = 0; 52 size_t dp = 0;
53 char *buf = dest->space + dest->pos; 53 char *buf = dest->space + dest->pos;
54 while (*src && *src != '\n') { 54 while (*src && *src != '\n') {
55 dp = writeescapedchar(buf, dp, *src); 55 dp = writeescapedchar(buf, dp, *src);
56 src++; 56 src++;
82 /* start monospace formatting */ 82 /* start monospace formatting */
83 out("<pre>\n", 1, 6, stream); 83 out("<pre>\n", 1, 6, stream);
84 84
85 /* process lines */ 85 /* process lines */
86 size_t lineno = 0; 86 size_t lineno = 0;
87 HighlighterData highlighter_data; 87 int multiline_comment = 0;
88 memset(&highlighter_data, 0, sizeof(HighlighterData));
89 88
90 UCX_FOREACH(sourceline, in) { 89 UCX_FOREACH(sourceline, in) {
91 /* increase line number and clean line buffer */ 90 /* increase line number and clean line buffer */
92 lineno++; 91 lineno++;
93 ucx_buffer_clear(line); 92 ucx_buffer_clear(line);
98 "<a name=\"l%d\" href=\"#l%d\">%*d </a></span> ", 97 "<a name=\"l%d\" href=\"#l%d\">%*d </a></span> ",
99 lineno, lineno, lnw, lineno); 98 lineno, lineno, lnw, lineno);
100 } 99 }
101 100
102 /* process code line */ 101 /* process code line */
103 highlighter(sourceline->data, line, &highlighter_data); 102 highlighter(sourceline->data, line, &multiline_comment);
104 103
105 /* write code line */ 104 /* write code line */
106 out(line->space, 1, line->size, stream); 105 out(line->space, 1, line->size, stream);
107 } 106 }
108 107
172 171
173 if (optind != argc-1) { 172 if (optind != argc-1) {
174 printhelp(); 173 printhelp();
175 return EXIT_FAILURE; 174 return EXIT_FAILURE;
176 } else { 175 } else {
177 /* Configure highlighter */ 176 /* Choose highlighter */
178 highlighter_func hltr = NULL; 177 highlighter_func hltr = NULL;
179 switch (sourcetype) { 178 switch (sourcetype) {
180 case SOURCE_C: 179 case SOURCE_C:
181 hltr = cparseline; 180 hltr = cparseline;
182 break; 181 break;

mercurial