src/c2html.c

changeset 50
17408c3607ce
parent 49
f86f0b054464
child 51
f25ba6fd7a08
equal deleted inserted replaced
49:f86f0b054464 50:17408c3607ce
51 src++; 51 src++;
52 } 52 }
53 ucx_buffer_putc(dest, '\n'); 53 ucx_buffer_putc(dest, '\n');
54 } 54 }
55 55
56 int formatlines(highlighter_func highlighter, 56 void formatlines(highlighter_func highlighter,
57 UcxList *in, write_func out, void *stream, int showlineno) { 57 UcxList *in, write_func out, void *stream, int showlineno) {
58 58
59 /* compute width of line numbering */ 59 /* compute width of line numbering */
60 int lnw; 60 int lnw;
61 if (showlineno) { 61 if (showlineno) {
66 } 66 }
67 67
68 /* allocate line buffer */ 68 /* allocate line buffer */
69 UcxBuffer *line = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); 69 UcxBuffer *line = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
70 if(!line) { 70 if(!line) {
71 return 1; 71 perror("Error allocating line buffer for output");
72 return;
72 } 73 }
73 74
74 /* start monospace formatting */ 75 /* start monospace formatting */
75 out("<pre>\n", 1, 6, stream); 76 out("<pre>\n", 1, 6, stream);
76 77
91 } 92 }
92 93
93 /* process code line */ 94 /* process code line */
94 highlighter(sourceline->data, line, &multiline_comment); 95 highlighter(sourceline->data, line, &multiline_comment);
95 96
96 /* write code line and reset buffer */ 97 /* write code line */
97 out(line->space, 1, line->size, stream); 98 out(line->space, 1, line->size, stream);
98 } 99 }
99 100
100 /* end monospace formatting */ 101 /* end monospace formatting */
101 out("</pre>\n", 1, 7, stream); 102 out("</pre>\n", 1, 7, stream);
102 103
103 /* cleanup and return */ 104 /* cleanup and return */
104 ucx_buffer_free(line); 105 ucx_buffer_free(line);
105 return 0;
106 } 106 }
107 107
108 #define FILEBUF_SIZE 4096 108 #define FILEBUF_SIZE 4096
109 109
110 enum source_type { 110 enum source_type {

mercurial