"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mkd2html.c" between
discount-2.2.4.tar.bz2 and discount-2.2.6.tar.bz2

About: Discount is an implementation of the "Markdown" markup language (written in C).

mkd2html.c  (discount-2.2.4.tar.bz2):mkd2html.c  (discount-2.2.6.tar.bz2)
skipping to change at line 71 skipping to change at line 71
va_list ptr; va_list ptr;
va_start(ptr,why); va_start(ptr,why);
fprintf(stderr, "%s: ", pgm); fprintf(stderr, "%s: ", pgm);
vfprintf(stderr, why, ptr); vfprintf(stderr, why, ptr);
fputc('\n', stderr); fputc('\n', stderr);
va_end(ptr); va_end(ptr);
exit(1); exit(1);
} }
enum { ADD_CSS, ADD_HEADER, ADD_FOOTER }; enum { GFM, ADD_CSS, ADD_HEADER, ADD_FOOTER };
struct h_opt opts[] = { struct h_opt opts[] = {
{ GFM, "gfm",'G', 0, "Github style markdown" },
{ ADD_CSS, "css", 0, "url", "Additional css for this page" }, { ADD_CSS, "css", 0, "url", "Additional css for this page" },
{ ADD_HEADER, "header", 0, "header", "Additonal headers for this page" }, { ADD_HEADER, "header", 0, "header", "Additonal headers for this page" },
{ ADD_FOOTER, "footer", 0, "footer", "Additional footers for this page" }, { ADD_FOOTER, "footer", 0, "footer", "Additional footers for this page" },
}; };
#define NROPTS (sizeof opts/sizeof opts[0]) #define NROPTS (sizeof opts/sizeof opts[0])
#if USE_H1TITLE #if USE_H1TITLE
extern char* mkd_h1_title(MMIOT *); extern char* mkd_h1_title(MMIOT *);
#endif #endif
int
main(argc, argv) main(argc, argv)
char **argv; char **argv;
{ {
char *h; char *h;
char *source = 0, *dest = 0; char *source = 0, *dest = 0;
MMIOT *mmiot; MMIOT *mmiot;
int i; int i;
int gfm = 0;
FILE *input, *output; FILE *input, *output;
STRING(char*) css, headers, footers; STRING(char*) css, headers, footers;
struct h_opt *res; struct h_opt *res;
struct h_context flags; struct h_context flags;
CREATE(css); CREATE(css);
CREATE(headers); CREATE(headers);
CREATE(footers); CREATE(footers);
pgm = basename(argv[0]); pgm = basename(argv[0]);
hoptset(&flags, argc, argv); hoptset(&flags, argc, argv);
hopterr(&flags, 1); hopterr(&flags, 1);
while ( res = gethopt(&flags, opts, NROPTS) ) { while ( res = gethopt(&flags, opts, NROPTS) ) {
if ( res == HOPTERR ) { if ( res == HOPTERR ) {
hoptusage(argv[0], opts, NROPTS, "source [dest]"); hoptusage(pgm, opts, NROPTS, "source [dest]");
exit(1); exit(1);
} }
switch ( res->option ) { switch ( res->option ) {
case ADD_CSS: case ADD_CSS:
EXPAND(css) = hoptarg(&flags); EXPAND(css) = hoptarg(&flags);
break; break;
case ADD_HEADER: case ADD_HEADER:
EXPAND(headers) = hoptarg(&flags); EXPAND(headers) = hoptarg(&flags);
break; break;
case ADD_FOOTER: case ADD_FOOTER:
EXPAND(footers) = hoptarg(&flags); EXPAND(footers) = hoptarg(&flags);
break; break;
case GFM:
gfm = 1;
break;
default: default:
fprintf(stderr, "unknown option?\n"); fprintf(stderr, "unknown option?\n");
break; break;
} }
} }
argc -= hoptind(&flags); argc -= hoptind(&flags);
argv += hoptind(&flags); argv += hoptind(&flags);
switch ( argc ) { switch ( argc ) {
skipping to change at line 144 skipping to change at line 150
case 1: case 1:
case 2: case 2:
dest = malloc(strlen(argv[argc-1]) + 6); dest = malloc(strlen(argv[argc-1]) + 6);
source = malloc(strlen(argv[0]) + 6); source = malloc(strlen(argv[0]) + 6);
if ( !(source && dest) ) if ( !(source && dest) )
fail("out of memory allocating name buffers"); fail("out of memory allocating name buffers");
strcpy(source, argv[0]); strcpy(source, argv[0]);
strcpy(dest, argv[argc-1]);
if (( p = strrchr(source, '/') )) if (( p = strrchr(source, '/') ))
p = source; p = source;
else else
++p; ++p;
if ( (input = fopen(source, "r")) == 0 ) { if ( (input = fopen(source, "r")) == 0 ) {
strcat(source, ".text"); strcat(source, ".text");
if ( (input = fopen(source, "r")) == 0 ) if ( (input = fopen(source, "r")) == 0 )
fail("can't open either %s or %s", argv[0], source); fail("can't open either %s or %s", argv[0], source);
} }
strcpy(dest, source);
if ( notspecial(dest) ) { if ( notspecial(dest) ) {
if (( dot = strrchr(dest, '.') )) if (( dot = strrchr(dest, '.') ))
*dot = 0; *dot = 0;
strcat(dest, ".html"); strcat(dest, ".html");
} }
if ( (output = fopen(dest, "w")) == 0 ) if ( (output = fopen(dest, "w")) == 0 )
fail("can't write to %s", dest); fail("can't write to %s", dest);
break; break;
default: default:
hoptusage(argv[0], opts, NROPTS, "source [dest]"); hoptusage(pgm, opts, NROPTS, "source [dest]");
exit(1); exit(1);
} }
if ( (mmiot = mkd_in(input, 0)) == 0 ) mmiot = gfm ? gfm_in(input, 0) : mkd_in(input, 0);
if ( mmiot == 0 )
fail("can't read %s", source ? source : "stdin"); fail("can't read %s", source ? source : "stdin");
if ( !mkd_compile(mmiot, 0) ) if ( !mkd_compile(mmiot, 0) )
fail("couldn't compile input"); fail("couldn't compile input");
h = mkd_doc_title(mmiot); h = mkd_doc_title(mmiot);
#if USE_H1TITLE #if USE_H1TITLE
if ( ! h ) if ( ! h )
h = mkd_h1_title(mmiot); h = mkd_h1_title(mmiot);
#endif #endif
 End of changes. 10 change blocks. 
5 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)