24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 * |
27 * |
28 */ |
28 */ |
|
29 |
|
30 #include <unistd.h> |
|
31 |
29 #include "c2html.h" |
32 #include "c2html.h" |
|
33 #include "highlighter.h" |
30 |
34 |
31 #include "ucx/list.h" |
35 #include "ucx/list.h" |
32 |
36 |
33 void printhelp() { |
37 void printhelp() { |
34 printf("Formats source code using HTML.\n\nUsage:\n" |
38 printf("Formats source code using HTML.\n\nUsage:\n" |
43 " -l Disable line numbers\n" |
47 " -l Disable line numbers\n" |
44 " -V, -v Prints version and exits\n" |
48 " -V, -v Prints version and exits\n" |
45 "\n"); |
49 "\n"); |
46 } |
50 } |
47 |
51 |
48 static void plain_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) { |
|
49 while (*src && *src != '\n') { |
|
50 put_htmlescaped(dest, *src); |
|
51 src++; |
|
52 } |
|
53 ucx_buffer_putc(dest, '\n'); |
|
54 } |
|
55 |
|
56 void formatlines(highlighter_func highlighter, |
52 void formatlines(highlighter_func highlighter, |
57 UcxList *in, write_func out, void *stream, int showlineno) { |
53 UcxList *in, write_func out, void *stream, int showlineno) { |
58 |
54 |
59 /* compute width of line numbering */ |
55 /* compute width of line numbering */ |
60 int lnw; |
56 int lnw; |