diff options
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | Makefile.win | 66 | ||||
-rw-r--r-- | examples/smartypants.c | 1 | ||||
-rw-r--r-- | hoedown.def | 66 | ||||
-rw-r--r-- | src/html_smartypants.c | 3 | ||||
-rw-r--r-- | src/markdown.c | 17 |
7 files changed, 96 insertions, 84 deletions
@@ -1,5 +1,9 @@ *.o -libhoedown.so* +*.obj +*.exe hoedown +hoedown.dll +hoedown.exp +hoedown.lib smartypants -*.exe +libhoedown.so* @@ -1,6 +1,11 @@ -CFLAGS = -c -g -O3 -fpic -Wall -Werror -Wsign-compare -Isrc +CFLAGS = -c -g -O3 -Wall -Werror -Wsign-compare -Isrc LDFLAGS = -g -O3 -Wall -Werror +# MingW/Cygwin +ifneq ($(OS),Windows_NT) + CFLAGS += -fPIC +endif + HOEDOWN_SRC=\ src/autolink.o \ src/buffer.o \ @@ -15,7 +20,7 @@ HOEDOWN_SRC=\ all: libhoedown.so hoedown smartypants -# libraries +# Libraries libhoedown.so: libhoedown.so.1 ln -f -s $^ $@ @@ -23,7 +28,7 @@ libhoedown.so: libhoedown.so.1 libhoedown.so.1: $(HOEDOWN_SRC) $(CC) $(LDFLAGS) -shared $^ -o $@ -# executables +# Executables hoedown: examples/hoedown.o $(HOEDOWN_SRC) $(CC) $(LDFLAGS) $^ -o $@ @@ -31,25 +36,25 @@ hoedown: examples/hoedown.o $(HOEDOWN_SRC) smartypants: examples/smartypants.o $(HOEDOWN_SRC) $(CC) $(LDFLAGS) $^ -o $@ -# perfect hashing +# Perfect hashing src/html_blocks.c: html_block_names.gperf gperf -L ANSI-C -N hoedown_find_block_tag -c -C -E -S 1 --ignore-case -m100 $^ > $@ -# testing +# Testing test: hoedown perl test/MarkdownTest_1.0.3/MarkdownTest.pl \ --script=./hoedown --testdir=test/MarkdownTest_1.0.3/Tests --tidy -# housekeeping +# Housekeeping clean: $(RM) -f src/*.o examples/*.o $(RM) -f libhoedown.so libhoedown.so.1 hoedown smartypants $(RM) -f hoedown.exe smartypants.exe -# generic object compilations +# Generic object compilations %.o: src/%.c examples/%.c $(CC) $(CFLAGS) -o $@ $< diff --git a/Makefile.win b/Makefile.win index 59827bd..b1a7e51 100644 --- a/Makefile.win +++ b/Makefile.win @@ -1,33 +1,33 @@ - -CFLAGS=/O2 /EHsc /I"src/" /I"examples"/ -CC=cl - -HOEDOWN_SRC=\ - src\autolink.obj \ - src\buffer.obj \ - src\escape.obj \ - src\html.obj \ - src\html_blocks.obj \ - src\html_smartpants.obj \ - src\markdown.obj \ - src\stack.obj - -all: hoedown.dll hoedown.exe - -hoedown.dll: $(HOEDOWN_SRC) hoedown.def - $(CC) $(HOEDOWN_SRC) hoedown.def /link /DLL $(LDFLAGS) /out:$@ - -hoedown.exe: examples\hoedown.obj $(HOEDOWN_SRC) - $(CC) examples\hoedown.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@ - -# housekeeping -clean: - del $(HOEDOWN_SRC) - del hoedown.dll hoedown.exe - del hoedown.exp hoedown.lib - -# generic object compilations - -.c.obj: - $(CC) $(CFLAGS) /c $< /Fo$@ - +CC = cl
+CFLAGS = /O2 /EHsc /I"src/"
+
+HOEDOWN_SRC = \
+ src\autolink.obj \
+ src\buffer.obj \
+ src\escape.obj \
+ src\html.obj \
+ src\html_blocks.obj \
+ src\html_smartypants.obj \
+ src\markdown.obj \
+ src\stack.obj
+
+all: hoedown.dll hoedown.exe smartypants.exe
+
+hoedown.dll: $(HOEDOWN_SRC) hoedown.def
+ $(CC) $(HOEDOWN_SRC) hoedown.def /link /DLL $(LDFLAGS) /out:$@
+
+hoedown.exe: examples\hoedown.obj $(HOEDOWN_SRC)
+ $(CC) examples\hoedown.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@
+
+smartypants.exe: examples\smartypants.obj $(HOEDOWN_SRC)
+ $(CC) examples\smartypants.obj $(HOEDOWN_SRC) /link $(LDFLAGS) /out:$@
+
+# Housekeeping
+
+clean:
+ del $(HOEDOWN_SRC) hoedown.dll hoedown.exe hoedown.exp hoedown.lib smartypants.exe
+
+# Generic object compilations
+
+.c.obj:
+ $(CC) $(CFLAGS) /c $< /Fo$@
diff --git a/examples/smartypants.c b/examples/smartypants.c index a8a2ef4..007ccb6 100644 --- a/examples/smartypants.c +++ b/examples/smartypants.c @@ -1,7 +1,6 @@ #include "html.h" #include <errno.h> -#include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/hoedown.def b/hoedown.def index cc0b385..5cc546f 100644 --- a/hoedown.def +++ b/hoedown.def @@ -1,33 +1,33 @@ -LIBRARY HOEDOWN -EXPORTS - hoedown_autolink_issafe - hoedown_autolink__www - hoedown_autolink__email - hoedown_autolink__url - hoedown_buffer_grow - hoedown_buffer_new - hoedown_buffer_cstr - hoedown_buffer_prefix - hoedown_buffer_put - hoedown_buffer_puts - hoedown_buffer_putc - hoedown_buffer_release - hoedown_buffer_reset - hoedown_buffer_slurp - hoedown_buffer_printf - hoedown_escape_html - hoedown_escape_href - hoedown_html_is_tag - hoedown_html_renderer - hoedown_html_toc_renderer - hoedown_html_smartypants - hoedown_markdown_new - hoedown_markdown_render - hoedown_markdown_free - hoedown_version - hoedown_stack_free - hoedown_stack_grow - hoedown_stack_init - hoedown_stack_push - hoedown_stack_pop - hoedown_stack_top +LIBRARY HOEDOWN
+EXPORTS
+ hoedown_autolink_issafe
+ hoedown_autolink__www
+ hoedown_autolink__email
+ hoedown_autolink__url
+ hoedown_buffer_grow
+ hoedown_buffer_new
+ hoedown_buffer_cstr
+ hoedown_buffer_prefix
+ hoedown_buffer_put
+ hoedown_buffer_puts
+ hoedown_buffer_putc
+ hoedown_buffer_release
+ hoedown_buffer_reset
+ hoedown_buffer_slurp
+ hoedown_buffer_printf
+ hoedown_escape_html
+ hoedown_escape_href
+ hoedown_html_is_tag
+ hoedown_html_renderer
+ hoedown_html_toc_renderer
+ hoedown_html_smartypants
+ hoedown_markdown_new
+ hoedown_markdown_render
+ hoedown_markdown_free
+ hoedown_version
+ hoedown_stack_free
+ hoedown_stack_grow
+ hoedown_stack_init
+ hoedown_stack_push
+ hoedown_stack_pop
+ hoedown_stack_top
diff --git a/src/html_smartypants.c b/src/html_smartypants.c index acb8e5b..f8e46f7 100644 --- a/src/html_smartypants.c +++ b/src/html_smartypants.c @@ -207,12 +207,13 @@ smartypants_cb__dash(struct hoedown_buffer *ob, struct smartypants_data *smrt, u static size_t smartypants_cb__amp(struct hoedown_buffer *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size) { + int len; if (size >= 6 && memcmp(text, """, 6) == 0) { if (smartypants_quotes(ob, previous_char, size >= 7 ? text[6] : 0, 'd', &smrt->in_dquote)) return 5; } - int len = squote_len(text, size); + len = squote_len(text, size); if (len > 0) { return (len-1) + smartypants_squote(ob, smrt, previous_char, text+(len-1), size-(len-1), text, len); } diff --git a/src/markdown.c b/src/markdown.c index 99be8f4..daa860c 100644 --- a/src/markdown.c +++ b/src/markdown.c @@ -1007,11 +1007,11 @@ char_link(struct hoedown_buffer *ob, struct hoedown_markdown *rndr, uint8_t *dat /* footnote link */ if (rndr->ext_flags & HOEDOWN_EXT_FOOTNOTES && data[1] == '^') { - if (txt_e < 3) - goto cleanup; - struct hoedown_buffer id = { 0, 0, 0, 0 }; struct footnote_ref *fr; + + if (txt_e < 3) + goto cleanup; id.data = data + 2; id.size = txt_e - 2; @@ -1040,6 +1040,8 @@ char_link(struct hoedown_buffer *ob, struct hoedown_markdown *rndr, uint8_t *dat /* inline style link */ if (i < size && data[i] == '(') { + size_t nb_p; + /* skipping initial whitespace */ i++; @@ -1050,7 +1052,7 @@ char_link(struct hoedown_buffer *ob, struct hoedown_markdown *rndr, uint8_t *dat /* looking for link end: ' " ) */ /* Count the number of open parenthesis */ - size_t nb_p = 0; + nb_p = 0; while (i < size) { if (data[i] == '\\') i += 2; @@ -2766,12 +2768,13 @@ hoedown_markdown_new( void hoedown_markdown_render(struct hoedown_buffer *ob, const uint8_t *document, size_t doc_size, struct hoedown_markdown *md) { -#define MARKDOWN_GROW(x) ((x) + ((x) >> 1)) static const char UTF8_BOM[] = {0xEF, 0xBB, 0xBF}; struct hoedown_buffer *text; size_t beg, end; + int footnotes_enabled; + text = hoedown_buffer_new(64); if (!text) return; @@ -2782,7 +2785,7 @@ hoedown_markdown_render(struct hoedown_buffer *ob, const uint8_t *document, size /* reset the references table */ memset(&md->refs, 0x0, REF_TABLE_SIZE * sizeof(void *)); - int footnotes_enabled = md->ext_flags & HOEDOWN_EXT_FOOTNOTES; + footnotes_enabled = md->ext_flags & HOEDOWN_EXT_FOOTNOTES; /* reset the footnotes lists */ if (footnotes_enabled) { @@ -2823,7 +2826,7 @@ hoedown_markdown_render(struct hoedown_buffer *ob, const uint8_t *document, size } /* pre-grow the output buffer to minimize allocations */ - hoedown_buffer_grow(ob, MARKDOWN_GROW(text->size)); + hoedown_buffer_grow(ob, text->size + (text->size >> 1)); /* second pass: actual rendering */ if (md->cb.doc_header) |