26 lines
468 B
C
26 lines
468 B
C
|
#include <stdio.h>
|
||
|
|
||
|
/* csv2html < file.csv > file.html */
|
||
|
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
int s;
|
||
|
|
||
|
printf("<table>\n<tr><td>");
|
||
|
|
||
|
while ((s = getchar()) != EOF) {
|
||
|
switch(s) {
|
||
|
case '\n': printf("</td></tr>\n<tr><td>"); break;
|
||
|
case ';': printf("</td><td>"); break;
|
||
|
case '<': printf("<"); break;
|
||
|
case '>': printf(">"); break;
|
||
|
case '&': printf("&"); break;
|
||
|
default: putchar(s);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
puts("</td></tr>\n</table>");
|
||
|
|
||
|
return 0;
|
||
|
}
|