create a typedef for the function argument to mkd_string_to_anchor, because some

compilers (and by some compilers, I mean "gcc") whine bitterly when you pass a
function argument with with a more specific pointer in place of a void*.   And if
I can't trust the compiler to emit sensible warnings, I'll just cast the damned
argument to a type that makes it stfu.

In addition, I needed to add prototypes for the html5 tag adder and the two
functions that spit out a list of the flags that the code was compiled with.
This commit is contained in:
david parsons
2011-01-29 11:00:54 -08:00
parent 625a80b2d4
commit 2b6ea3799e
6 changed files with 21 additions and 10 deletions
+4 -2
View File
@@ -1342,7 +1342,9 @@ printheader(Paragraph *pp, MMIOT *f)
{
if ( f->flags & MKD_TOC ) {
Qstring("<a name=\"", f);
mkd_string_to_anchor(T(pp->text->text), S(pp->text->text), Qchar, f, 1);
mkd_string_to_anchor(T(pp->text->text),
S(pp->text->text),
(mkd_sta_function_t)Qchar, f, 1);
Qstring("\"></a>\n", f);
}
Qprintf(f, "<h%d>", pp->hnumber);
@@ -1648,7 +1650,7 @@ display(Paragraph *p, MMIOT *f)
static void
mkd_extra_footnotes(MMIOT *m)
{
int j, i, prefix=0;
int j, i;
Footnote *t;
if ( m->reference == 0 )
+3 -3
View File
@@ -39,7 +39,7 @@ char *pgm = "markdown";
static struct {
char *name;
int off;
int flag;
mkd_flag_t flag;
} opts[] = {
{ "tabstop", 0, MKD_TABSTOP },
{ "image", 1, MKD_NOIMAGE },
@@ -72,7 +72,7 @@ static struct {
void
set(int *flags, char *optionstring)
set(mkd_flag_t *flags, char *optionstring)
{
int i;
int enable;
@@ -119,7 +119,7 @@ main(int argc, char **argv)
{
int opt;
int rc;
int flags = 0;
mkd_flag_t flags = 0;
int debug = 0;
int toc = 0;
int version = 0;
+3 -1
View File
@@ -149,7 +149,9 @@ extern int mkd_line(char *, int, char **, DWORD);
extern int mkd_generateline(char *, int, FILE*, DWORD);
#define mkd_text mkd_generateline
extern void mkd_basename(Document*, char *);
extern void mkd_string_to_anchor(char*,int, void(*)(int,void*), void*, int);
typedef int (*mkd_sta_function_t)(const int,const void*);
extern void mkd_string_to_anchor(char*,int, mkd_sta_function_t, void*, int);
extern Document *mkd_in(FILE *, DWORD);
extern Document *mkd_string(char*,int, DWORD);
+1 -1
View File
@@ -215,7 +215,7 @@ markdown(Document *document, FILE *out, int flags)
/* write out a Cstring, mangled into a form suitable for `<a href=` or `<a id=`
*/
void
mkd_string_to_anchor(char *s, int len, void(*outchar)(int,void*),
mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
void *out, int labelformat)
{
unsigned char c;
+6 -1
View File
@@ -15,6 +15,7 @@ MMIOT *mkd_string(char*,int,mkd_flag_t); /* assemble input from a buffer */
void mkd_basename(MMIOT*,char*);
void mkd_initialize();
void mkd_with_html5_tags();
void mkd_shlib_destructor();
/* compilation, debugging, cleanup
@@ -27,7 +28,8 @@ int mkd_cleanup(MMIOT*);
int mkd_dump(MMIOT*, FILE*, int, char*);
int markdown(MMIOT*, FILE*, mkd_flag_t);
int mkd_line(char *, int, char **, mkd_flag_t);
void mkd_string_to_anchor(char *, int, int (*)(int,void*), void*, int);
typedef int (*mkd_sta_function_t)(const int,const void*);
void mkd_string_to_anchor(char *, int, mkd_sta_function_t, void*, int);
int mkd_xhtmlpage(MMIOT*,int,FILE*);
/* header block access
@@ -66,6 +68,9 @@ void mkd_e_data(void *, void *);
/* version#.
*/
extern char markdown_version[];
void mkd_mmiot_flags(FILE *, MMIOT *, int);
void mkd_flags_are(FILE*, mkd_flag_t, int);
/* special flags for markdown() and mkd_text()
*/
+4 -2
View File
@@ -52,10 +52,12 @@ mkd_toc(Document *p, char **doc)
}
Csprintf(&res, "%*s<li><a href=\"#", srcp->hnumber, "");
mkd_string_to_anchor(T(srcp->text->text),
S(srcp->text->text), Csputc, &res,1);
S(srcp->text->text),
(mkd_sta_function_t)Csputc, &res,1);
Csprintf(&res, "\">");
mkd_string_to_anchor(T(srcp->text->text),
S(srcp->text->text), Csputc, &res,0);
S(srcp->text->text),
(mkd_sta_function_t)Csputc, &res,0);
Csprintf(&res, "</a>");
Csprintf(&res, "</li>\n");
}