[update] textproc/multimarkdown

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[update] textproc/multimarkdown

attila
Hi ports@,

The attached patch brings textproc/multimarkdown up to the latest
release (5.1.0).  It ditches a bunch of patches, some of which are no
longer necessary and some of which I tried and failed to sell to the
upstream.

Works okay for me on i386.  Sadly I have no other -current machines
right now.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0xE6CC1EDB

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 16 Mar 2016 01:00:52 -0000
@@ -1,13 +1,13 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.1.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
 PKGNAME = multimarkdown-${V}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
@@ -21,14 +21,18 @@ WANTLIB += c
 BUILD_DEPENDS = devel/greg
 
 USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+# avoid using cmake, not necc for us
+ALL_TARGET = deprecated
+
+# golf MAKE_FLAGS down to 80chars.. :-|
+_i = -include
+_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
+MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"
 
 # Test files aren't included in distfile.
 NO_TEST = Yes
 
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKSRC}/build/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 16 Mar 2016 01:00:52 -0000
@@ -1,2 +1,2 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (MultiMarkdown-5-5.1.0.tar.gz) = ZdT8mzDrZq9vYLN8HzJBlf3xqSb/umBoLd9+/MH4eGg=
+SIZE (MultiMarkdown-5-5.1.0.tar.gz) = 135170
Index: patches/patch-Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/patches/patch-Makefile,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ patches/patch-Makefile 16 Mar 2016 01:00:52 -0000
@@ -1,37 +1,40 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
+$OpenBSD$
 
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
+Patch up Makefile so we can use it instead of cmake.
+--- Makefile.orig Mon Feb 22 20:05:02 2016
++++ Makefile Tue Mar 15 18:56:50 2016
+@@ -1,6 +1,6 @@
+ BUILD_DIR = build
+
+-GREG = submodules/greg/greg
++GREG = /usr/local/bin/greg
+
+ # The release target will perform additional optimization
+ .PHONY : release
+@@ -81,7 +81,7 @@ $(GREG):
+ $(MAKE) -C submodules/greg
+
+ # Create build directory if it doesn't exist
+-$(BUILD_DIR): CHANGELOG
++$(BUILD_DIR):
+ -mkdir $(BUILD_DIR) 2>/dev/null
+ -cd $(BUILD_DIR); rm -rf *
+
+@@ -100,7 +100,7 @@ CHANGELOG:
+ #
+ # I don't recommend this approach, but it should work in a pinch
+
+-CFLAGS ?= -Wall -g -O3 -include src/GLibFacade.h -include src/version.h -include src/parser.h
++#CFLAGS ?= -Wall -g -O3 -include src/GLibFacade.h -include src/version.h -include src/parser.h
+ PROGRAM = multimarkdown
+
+ OBJS = build/multimarkdown.o build/parse_utilities.o build/parser.o build/GLibFacade.o build/writer.o build/text.o build/html.o build/latex.o build/memoir.o build/beamer.o build/lyx.o build/lyxbeamer.o build/opml.o build/odf.o build/critic.o build/rng.o build/rtf.o build/transclude.o build/toc.o
+@@ -119,7 +119,7 @@ src/parser.c: src/parser.leg $(GREG) src/parser.h
+ $(GREG) -o src/parser.c src/parser.leg
+
+ .PHONY : deprecated
+-deprecated: $(GREG) build/$(PROGRAM)
++deprecated: build/$(PROGRAM)
 
- $(PROGRAM) : $(OBJS)
+ build/$(PROGRAM): $(OBJS) $(BUILD_DIR) src/version.h
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS); \
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> Hi ports@,
>

Hi again, ports@.  Sorry to be a pain but this patch doesn't pass
muster.  I should never send things late at night.  Please ignore,
I'll send a better one soon.

Sorry for the noise.

> The attached patch brings textproc/multimarkdown up to the latest
> release (5.1.0).  It ditches a bunch of patches, some of which are no
> longer necessary and some of which I tried and failed to sell to the
> upstream.
>
> Works okay for me on i386.  Sadly I have no other -current machines
> right now.
>
> Pax, -A

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0xE6CC1EDB

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

Michael McConville-3
In reply to this post by attila
attila wrote:
> The attached patch brings textproc/multimarkdown up to the latest
> release (5.1.0).  It ditches a bunch of patches, some of which are no
> longer necessary and some of which I tried and failed to sell to the
> upstream.

Do you think any of these patches are worth keeping around regardless
for security reasons?

That said, I would drop the rand(3) removals. We alias it to
arc4random(3) anyway. One of the main benefits of that is that we don't
have to maintain tons of patches.

Also, a few comments inline:

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- Makefile 5 Apr 2015 13:31:15 -0000 1.2
> +++ Makefile 16 Mar 2016 01:00:52 -0000
> @@ -21,14 +21,18 @@ WANTLIB += c
>  BUILD_DEPENDS = devel/greg
>  
>  USE_GMAKE = Yes
> -ALL_TARGET = ALL
> -MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
> - GREG=${LOCALBASE}/bin/greg
> +# avoid using cmake, not necc for us
> +ALL_TARGET = deprecated
> +
> +# golf MAKE_FLAGS down to 80chars.. :-|
> +_i = -include
> +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
> +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"

Why golf? Can't you just use backslashes as necessary? I would get rid
of _i and _incs.

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

Stuart Henderson
On 2016/03/19 15:38, Michael McConville wrote:

> > +ALL_TARGET = deprecated
> > +
> > +# golf MAKE_FLAGS down to 80chars.. :-|
> > +_i = -include
> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"
>
> Why golf? Can't you just use backslashes as necessary? I would get rid
> of _i and _incs.
>

I think this approach is dangerous, better to keep those bits which are
normally part of upstream's Makefile in their Makefile and change the
way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
-include ...")

But then again, we have cmake, why not just use that? It's upstream's
preferred build infrastructure, whereas for the make-based one they say
"I don't recommend this approach, but it should work in a pinch"..

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

Stuart Henderson <[hidden email]> writes:

> On 2016/03/19 15:38, Michael McConville wrote:
>> > +ALL_TARGET = deprecated
>> > +
>> > +# golf MAKE_FLAGS down to 80chars.. :-|
>> > +_i = -include
>> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"
>>
>> Why golf? Can't you just use backslashes as necessary? I would get rid
>> of _i and _incs.
>>
>
> I think this approach is dangerous, better to keep those bits which are
> normally part of upstream's Makefile in their Makefile and change the
> way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
> change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
> -include ...")
>
> But then again, we have cmake, why not just use that? It's upstream's
> preferred build infrastructure, whereas for the make-based one they say
> "I don't recommend this approach, but it should work in a pinch"..
Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
find myself golfing I should stop.

Attached is new attempt that uses cmake instead.  Works for me on i386.

N.B.: I set NO_TEST to Yes now because the tests are buried in a git
submodule; furthermore, the repo on which the submodule is based has
no tags and thus no releases, making it impossible for me to reach out
for it as a distfile (unless I'm missing something).  I'm going to try
to convince the upstream to start tagging that repo, but if I fail
then I'll self-host a tarball for tests on the next update.

Thanks as always for the feedback.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 22 Mar 2016 18:48:31 -0000
@@ -1,13 +1,13 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.1.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
 PKGNAME = multimarkdown-${V}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
@@ -20,15 +20,19 @@ WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
+
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
 
 # Test files aren't included in distfile.
 NO_TEST = Yes
 
+pre-configure:
+ touch ${WRKBUILD}/README.html
+
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 22 Mar 2016 18:48:31 -0000
@@ -1,2 +1,2 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (MultiMarkdown-5-5.1.0.tar.gz) = ZdT8mzDrZq9vYLN8HzJBlf3xqSb/umBoLd9+/MH4eGg=
+SIZE (MultiMarkdown-5-5.1.0.tar.gz) = 135170
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Wed Mar 16 13:35:47 2016
++++ src/html.c Wed Mar 16 13:42:24 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
+rejected by upstream, keeping to quell ld-time warnings about strcat(3).
+--- src/latex.c.orig Wed Mar 16 13:44:52 2016
++++ src/latex.c Wed Mar 16 13:48:17 2016
+@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
+-
++ size_t result_len;
++
+ result = strdup(original);
+-
++ result_len = strlen(result);
++
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
++ if (strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
+
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
+strerror(3) if pledge(2) returns an error, as per practice elsewhere
+in the tree.
+--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
+@@ -63,6 +63,10 @@
+ #include "parser.h"
+ #include "transclude.h"
+ #include "version.h"
++#ifdef __OpenBSD__
++# include <errno.h> /* errno */
++# include <string.h> /* strerror(3) */
++#endif /* __OpenBSD__ */
+
+ /// main()
+ int main(int argc, char **argv)
+@@ -131,6 +135,13 @@ int main(int argc, char **argv)
+ unsigned long extensions = 0;
+ extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++#endif /* __OpenBSD__ */
++
+ /* process options */
+ while (1) {
+ int option_index = 0;
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
+@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+s/sprintf/asprintf/ and die on malloc failure
+--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
++++ src/parser.leg Wed Mar 16 13:59:00 2016
+@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto;
++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
+ld-time warnings.
+--- src/writer.c.orig Wed Mar 16 13:55:05 2016
++++ src/writer.c Wed Mar 16 13:58:02 2016
+@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension, "px");
++    if (ptr)
++        ptr[1] = 't'; /* px -> pt */
+
+     result = g_string_new(dimension);
+    
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

micah muer
On Tue, 22 Mar 2016 12:58:32 -0600
attila <[hidden email]> wrote:

> Stuart Henderson <[hidden email]> writes:
>
> > On 2016/03/19 15:38, Michael McConville wrote:  
> >> > +ALL_TARGET = deprecated
> >> > +
> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
> >> > +_i = -include
> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
> >>
> >> Why golf? Can't you just use backslashes as necessary? I would get rid
> >> of _i and _incs.
> >>  
> >
> > I think this approach is dangerous, better to keep those bits which are
> > normally part of upstream's Makefile in their Makefile and change the
> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
> > -include ...")
> >
> > But then again, we have cmake, why not just use that? It's upstream's
> > preferred build infrastructure, whereas for the make-based one they say
> > "I don't recommend this approach, but it should work in a pinch"..  
>
> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
> find myself golfing I should stop.
>
> Attached is new attempt that uses cmake instead.  Works for me on i386.
>
> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
> submodule; furthermore, the repo on which the submodule is based has
> no tags and thus no releases, making it impossible for me to reach out
> for it as a distfile (unless I'm missing something).  I'm going to try
> to convince the upstream to start tagging that repo, but if I fail
> then I'll self-host a tarball for tests on the next update.
>
> Thanks as always for the feedback.
>
> Pax, -A
> --
> http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Atilla's patch works well for me on amd64. I have used it heavily for
several days. However, upstream has a new release, so here's a new
patch 99% based on atilla's.

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 22 Mar 2016 18:48:31 -0000
@@ -1,13 +1,13 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.2.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
 PKGNAME = multimarkdown-${V}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
@@ -20,15 +20,19 @@ WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
+
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
 
 # Test files aren't included in distfile.
 NO_TEST = Yes
 
+pre-configure:
+ touch ${WRKBUILD}/README.html
+
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 22 Mar 2016 18:48:31 -0000
@@ -1,2 +1,2 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (MultiMarkdown-5-5.2.0.tar.gz) = 7tjLjDmJa1e41uAJOn2WhDMmp/cxA2xLp5CsBPhOEsM=
+SIZE (MultiMarkdown-5-5.2.0.tar.gz) = 135547
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Wed Mar 16 13:35:47 2016
++++ src/html.c Wed Mar 16 13:42:24 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
+rejected by upstream, keeping to quell ld-time warnings about strcat(3).
+--- src/latex.c.orig Wed Mar 16 13:44:52 2016
++++ src/latex.c Wed Mar 16 13:48:17 2016
+@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
+-
++ size_t result_len;
++
+ result = strdup(original);
+-
++ result_len = strlen(result);
++
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
++ if (strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
+
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
+strerror(3) if pledge(2) returns an error, as per practice elsewhere
+in the tree.
+--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
+@@ -63,6 +63,10 @@
+ #include "parser.h"
+ #include "transclude.h"
+ #include "version.h"
++#ifdef __OpenBSD__
++# include <errno.h> /* errno */
++# include <string.h> /* strerror(3) */
++#endif /* __OpenBSD__ */
+
+ /// main()
+ int main(int argc, char **argv)
+@@ -131,6 +135,13 @@ int main(int argc, char **argv)
+ unsigned long extensions = 0;
+ extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++#endif /* __OpenBSD__ */
++
+ /* process options */
+ while (1) {
+ int option_index = 0;
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
+@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+s/sprintf/asprintf/ and die on malloc failure
+--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
++++ src/parser.leg Wed Mar 16 13:59:00 2016
+@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto;
++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 22 Mar 2016 18:48:31 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
+ld-time warnings.
+--- src/writer.c.orig Wed Mar 16 13:55:05 2016
++++ src/writer.c Wed Mar 16 13:58:02 2016
+@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension, "px");
++    if (ptr)
++        ptr[1] = 't'; /* px -> pt */
+
+     result = g_string_new(dimension);
+    
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }



Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

Micah Muer <[hidden email]> writes:

> On Tue, 22 Mar 2016 12:58:32 -0600
> attila <[hidden email]> wrote:
>
>> Stuart Henderson <[hidden email]> writes:
>>
>> > On 2016/03/19 15:38, Michael McConville wrote:  
>> >> > +ALL_TARGET = deprecated
>> >> > +
>> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
>> >> > +_i = -include
>> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
>> >>
>> >> Why golf? Can't you just use backslashes as necessary? I would get rid
>> >> of _i and _incs.
>> >>  
>> >
>> > I think this approach is dangerous, better to keep those bits which are
>> > normally part of upstream's Makefile in their Makefile and change the
>> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
>> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
>> > -include ...")
>> >
>> > But then again, we have cmake, why not just use that? It's upstream's
>> > preferred build infrastructure, whereas for the make-based one they say
>> > "I don't recommend this approach, but it should work in a pinch"..  
>>
>> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
>> find myself golfing I should stop.
>>
>> Attached is new attempt that uses cmake instead.  Works for me on i386.
>>
>> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
>> submodule; furthermore, the repo on which the submodule is based has
>> no tags and thus no releases, making it impossible for me to reach out
>> for it as a distfile (unless I'm missing something).  I'm going to try
>> to convince the upstream to start tagging that repo, but if I fail
>> then I'll self-host a tarball for tests on the next update.
>>
>> Thanks as always for the feedback.
>>
>> Pax, -A
>> --
>> http://haqistan.net/~attila | [hidden email] | 0x62A729CF
>
> Atilla's patch works well for me on amd64. I have used it heavily for
> several days. However, upstream has a new release, so here's a new
> patch 99% based on atilla's.

Nice!  Thanks for doing this.  Works for me on i386.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> Micah Muer <[hidden email]> writes:
>
>> On Tue, 22 Mar 2016 12:58:32 -0600
>> attila <[hidden email]> wrote:
>>
>>> Stuart Henderson <[hidden email]> writes:
>>>
>>> > On 2016/03/19 15:38, Michael McConville wrote:  
>>> >> > +ALL_TARGET = deprecated
>>> >> > +
>>> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
>>> >> > +_i = -include
>>> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>>> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
>>> >>
>>> >> Why golf? Can't you just use backslashes as necessary? I would get rid
>>> >> of _i and _incs.
>>> >>  
>>> >
>>> > I think this approach is dangerous, better to keep those bits which are
>>> > normally part of upstream's Makefile in their Makefile and change the
>>> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
>>> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
>>> > -include ...")
>>> >
>>> > But then again, we have cmake, why not just use that? It's upstream's
>>> > preferred build infrastructure, whereas for the make-based one they say
>>> > "I don't recommend this approach, but it should work in a pinch"..  
>>>
>>> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
>>> find myself golfing I should stop.
>>>
>>> Attached is new attempt that uses cmake instead.  Works for me on i386.
>>>
>>> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
>>> submodule; furthermore, the repo on which the submodule is based has
>>> no tags and thus no releases, making it impossible for me to reach out
>>> for it as a distfile (unless I'm missing something).  I'm going to try
>>> to convince the upstream to start tagging that repo, but if I fail
>>> then I'll self-host a tarball for tests on the next update.
>>>
>>> Thanks as always for the feedback.
>>>
>>> Pax, -A
>>> --
>>> http://haqistan.net/~attila | [hidden email] | 0x62A729CF
>>
>> Atilla's patch works well for me on amd64. I have used it heavily for
>> several days. However, upstream has a new release, so here's a new
>> patch 99% based on atilla's.
>
> Nice!  Thanks for doing this.  Works for me on i386.
Ping?  Diff attached that includes Micah Muer's updates.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 4 Apr 2016 21:36:23 -0000
@@ -1,13 +1,13 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.2.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
 PKGNAME = multimarkdown-${V}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
@@ -20,15 +20,19 @@ WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
+
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
 
 # Test files aren't included in distfile.
 NO_TEST = Yes
 
+pre-configure:
+ touch ${WRKBUILD}/README.html
+
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 4 Apr 2016 21:36:23 -0000
@@ -1,2 +1,2 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (MultiMarkdown-5-5.2.0.tar.gz) = 7tjLjDmJa1e41uAJOn2WhDMmp/cxA2xLp5CsBPhOEsM=
+SIZE (MultiMarkdown-5-5.2.0.tar.gz) = 135547
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Wed Mar 16 13:35:47 2016
++++ src/html.c Wed Mar 16 13:42:24 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
+rejected by upstream, keeping to quell ld-time warnings about strcat(3).
+--- src/latex.c.orig Wed Mar 16 13:44:52 2016
++++ src/latex.c Wed Mar 16 13:48:17 2016
+@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
+-
++ size_t result_len;
++
+ result = strdup(original);
+-
++ result_len = strlen(result);
++
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
++ if (strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
+
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
+strerror(3) if pledge(2) returns an error, as per practice elsewhere
+in the tree.
+--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
+@@ -63,6 +63,10 @@
+ #include "parser.h"
+ #include "transclude.h"
+ #include "version.h"
++#ifdef __OpenBSD__
++# include <errno.h> /* errno */
++# include <string.h> /* strerror(3) */
++#endif /* __OpenBSD__ */
+
+ /// main()
+ int main(int argc, char **argv)
+@@ -131,6 +135,13 @@ int main(int argc, char **argv)
+ unsigned long extensions = 0;
+ extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++#endif /* __OpenBSD__ */
++
+ /* process options */
+ while (1) {
+ int option_index = 0;
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
+@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+s/sprintf/asprintf/ and die on malloc failure
+--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
++++ src/parser.leg Wed Mar 16 13:59:00 2016
+@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto;
++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 4 Apr 2016 21:36:23 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
+ld-time warnings.
+--- src/writer.c.orig Wed Mar 16 13:55:05 2016
++++ src/writer.c Wed Mar 16 13:58:02 2016
+@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension, "px");
++    if (ptr)
++        ptr[1] = 't'; /* px -> pt */
+
+     result = g_string_new(dimension);
+    
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> Micah Muer <[hidden email]> writes:
>>
>>> On Tue, 22 Mar 2016 12:58:32 -0600
>>> attila <[hidden email]> wrote:
>>>
>>>> Stuart Henderson <[hidden email]> writes:
>>>>
>>>> > On 2016/03/19 15:38, Michael McConville wrote:  
>>>> >> > +ALL_TARGET = deprecated
>>>> >> > +
>>>> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
>>>> >> > +_i = -include
>>>> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>>>> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
>>>> >>
>>>> >> Why golf? Can't you just use backslashes as necessary? I would get rid
>>>> >> of _i and _incs.
>>>> >>  
>>>> >
>>>> > I think this approach is dangerous, better to keep those bits which are
>>>> > normally part of upstream's Makefile in their Makefile and change the
>>>> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
>>>> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
>>>> > -include ...")
>>>> >
>>>> > But then again, we have cmake, why not just use that? It's upstream's
>>>> > preferred build infrastructure, whereas for the make-based one they say
>>>> > "I don't recommend this approach, but it should work in a pinch"..  
>>>>
>>>> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
>>>> find myself golfing I should stop.
>>>>
>>>> Attached is new attempt that uses cmake instead.  Works for me on i386.
>>>>
>>>> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
>>>> submodule; furthermore, the repo on which the submodule is based has
>>>> no tags and thus no releases, making it impossible for me to reach out
>>>> for it as a distfile (unless I'm missing something).  I'm going to try
>>>> to convince the upstream to start tagging that repo, but if I fail
>>>> then I'll self-host a tarball for tests on the next update.
>>>>
>>>> Thanks as always for the feedback.
>>>>
>>>> Pax, -A
>>>> --
>>>> http://haqistan.net/~attila | [hidden email] | 0x62A729CF
>>>
>>> Atilla's patch works well for me on amd64. I have used it heavily for
>>> several days. However, upstream has a new release, so here's a new
>>> patch 99% based on atilla's.
>>
>> Nice!  Thanks for doing this.  Works for me on i386.
>
> Ping?  Diff attached that includes Micah Muer's updates.
>
> Pax, -A
Reping?  New patch attached that brings us up to 5.2.0-1, released 16
March.  Nothing new, just updated distinfo and Makefile.  Works for me
under amd64, i386.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 15 Apr 2016 20:30:02 -0000
@@ -1,13 +1,13 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.2.0-1
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
-PKGNAME = multimarkdown-${V}
+PKGNAME = multimarkdown-${V:C/-/./}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
@@ -20,15 +20,19 @@ WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
+
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
 
 # Test files aren't included in distfile.
 NO_TEST = Yes
 
+pre-configure:
+ touch ${WRKBUILD}/README.html
+
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 15 Apr 2016 20:30:02 -0000
@@ -1,2 +1,2 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (MultiMarkdown-5-5.2.0-1.tar.gz) = be3wxbEGZQob8/ZZlHtBei0/S6T2FNyN3VI8RsEsyzI=
+SIZE (MultiMarkdown-5-5.2.0-1.tar.gz) = 135551
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Wed Mar 16 13:35:47 2016
++++ src/html.c Wed Mar 16 13:42:24 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
+rejected by upstream, keeping to quell ld-time warnings about strcat(3).
+--- src/latex.c.orig Wed Mar 16 13:44:52 2016
++++ src/latex.c Wed Mar 16 13:48:17 2016
+@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
+-
++ size_t result_len;
++
+ result = strdup(original);
+-
++ result_len = strlen(result);
++
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
++ if (strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
+
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
+strerror(3) if pledge(2) returns an error, as per practice elsewhere
+in the tree.
+--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
+@@ -63,6 +63,10 @@
+ #include "parser.h"
+ #include "transclude.h"
+ #include "version.h"
++#ifdef __OpenBSD__
++# include <errno.h> /* errno */
++# include <string.h> /* strerror(3) */
++#endif /* __OpenBSD__ */
+
+ /// main()
+ int main(int argc, char **argv)
+@@ -131,6 +135,13 @@ int main(int argc, char **argv)
+ unsigned long extensions = 0;
+ extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++#endif /* __OpenBSD__ */
++
+ /* process options */
+ while (1) {
+ int option_index = 0;
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
+@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+s/sprintf/asprintf/ and die on malloc failure
+--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
++++ src/parser.leg Wed Mar 16 13:59:00 2016
+@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto;
++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
+ld-time warnings.
+--- src/writer.c.orig Wed Mar 16 13:55:05 2016
++++ src/writer.c Wed Mar 16 13:58:02 2016
+@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension, "px");
++    if (ptr)
++        ptr[1] = 't'; /* px -> pt */
+
+     result = g_string_new(dimension);
+    
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> attila <[hidden email]> writes:
>>
>>> Micah Muer <[hidden email]> writes:
>>>
>>>> On Tue, 22 Mar 2016 12:58:32 -0600
>>>> attila <[hidden email]> wrote:
>>>>
>>>>> Stuart Henderson <[hidden email]> writes:
>>>>>
>>>>> > On 2016/03/19 15:38, Michael McConville wrote:  
>>>>> >> > +ALL_TARGET = deprecated
>>>>> >> > +
>>>>> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
>>>>> >> > +_i = -include
>>>>> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>>>>> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
>>>>> >>
>>>>> >> Why golf? Can't you just use backslashes as necessary? I would get rid
>>>>> >> of _i and _incs.
>>>>> >>  
>>>>> >
>>>>> > I think this approach is dangerous, better to keep those bits which are
>>>>> > normally part of upstream's Makefile in their Makefile and change the
>>>>> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
>>>>> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
>>>>> > -include ...")
>>>>> >
>>>>> > But then again, we have cmake, why not just use that? It's upstream's
>>>>> > preferred build infrastructure, whereas for the make-based one they say
>>>>> > "I don't recommend this approach, but it should work in a pinch"..  
>>>>>
>>>>> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
>>>>> find myself golfing I should stop.
>>>>>
>>>>> Attached is new attempt that uses cmake instead.  Works for me on i386.
>>>>>
>>>>> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
>>>>> submodule; furthermore, the repo on which the submodule is based has
>>>>> no tags and thus no releases, making it impossible for me to reach out
>>>>> for it as a distfile (unless I'm missing something).  I'm going to try
>>>>> to convince the upstream to start tagging that repo, but if I fail
>>>>> then I'll self-host a tarball for tests on the next update.
>>>>>
>>>>> Thanks as always for the feedback.
>>>>>
>>>>> Pax, -A
>>>>> --
>>>>> http://haqistan.net/~attila | [hidden email] | 0x62A729CF
>>>>
>>>> Atilla's patch works well for me on amd64. I have used it heavily for
>>>> several days. However, upstream has a new release, so here's a new
>>>> patch 99% based on atilla's.
>>>
>>> Nice!  Thanks for doing this.  Works for me on i386.
>>
>> Ping?  Diff attached that includes Micah Muer's updates.
>>
>> Pax, -A
>
> Reping?  New patch attached that brings us up to 5.2.0-1, released 16
> March.  Nothing new, just updated distinfo and Makefile.  Works for me
> under amd64, i386.
>
> Pax, -A

Ping.

Pax, -A
--
Sean Levy | [hidden email] | cluefactory.com | software development

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> attila <[hidden email]> writes:
>>
>>> attila <[hidden email]> writes:
>>>
>>>> Micah Muer <[hidden email]> writes:
>>>>
>>>>> On Tue, 22 Mar 2016 12:58:32 -0600
>>>>> attila <[hidden email]> wrote:
>>>>>
>>>>>> Stuart Henderson <[hidden email]> writes:
>>>>>>
>>>>>> > On 2016/03/19 15:38, Michael McConville wrote:  
>>>>>> >> > +ALL_TARGET = deprecated
>>>>>> >> > +
>>>>>> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
>>>>>> >> > +_i = -include
>>>>>> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>>>>>> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
>>>>>> >>
>>>>>> >> Why golf? Can't you just use backslashes as necessary? I would get rid
>>>>>> >> of _i and _incs.
>>>>>> >>  
>>>>>> >
>>>>>> > I think this approach is dangerous, better to keep those bits which are
>>>>>> > normally part of upstream's Makefile in their Makefile and change the
>>>>>> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
>>>>>> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
>>>>>> > -include ...")
>>>>>> >
>>>>>> > But then again, we have cmake, why not just use that? It's upstream's
>>>>>> > preferred build infrastructure, whereas for the make-based one they say
>>>>>> > "I don't recommend this approach, but it should work in a pinch"..  
>>>>>>
>>>>>> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
>>>>>> find myself golfing I should stop.
>>>>>>
>>>>>> Attached is new attempt that uses cmake instead.  Works for me on i386.
>>>>>>
>>>>>> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
>>>>>> submodule; furthermore, the repo on which the submodule is based has
>>>>>> no tags and thus no releases, making it impossible for me to reach out
>>>>>> for it as a distfile (unless I'm missing something).  I'm going to try
>>>>>> to convince the upstream to start tagging that repo, but if I fail
>>>>>> then I'll self-host a tarball for tests on the next update.
>>>>>>
>>>>>> Thanks as always for the feedback.
>>>>>>
>>>>>> Pax, -A
>>>>>> --
>>>>>> http://haqistan.net/~attila | [hidden email] | 0x62A729CF
>>>>>
>>>>> Atilla's patch works well for me on amd64. I have used it heavily for
>>>>> several days. However, upstream has a new release, so here's a new
>>>>> patch 99% based on atilla's.
>>>>
>>>> Nice!  Thanks for doing this.  Works for me on i386.
>>>
>>> Ping?  Diff attached that includes Micah Muer's updates.
>>>
>>> Pax, -A
>>
>> Reping?  New patch attached that brings us up to 5.2.0-1, released 16
>> March.  Nothing new, just updated distinfo and Makefile.  Works for me
>> under amd64, i386.
>>
>> Pax, -A
>
> Ping.
>
> Pax, -A

Ping.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> attila <[hidden email]> writes:
>>
>>> attila <[hidden email]> writes:
>>>
>>>> attila <[hidden email]> writes:
>>>>
>>>>> Micah Muer <[hidden email]> writes:
>>>>>
>>>>>> On Tue, 22 Mar 2016 12:58:32 -0600
>>>>>> attila <[hidden email]> wrote:
>>>>>>
>>>>>>> Stuart Henderson <[hidden email]> writes:
>>>>>>>
>>>>>>> > On 2016/03/19 15:38, Michael McConville wrote:  
>>>>>>> >> > +ALL_TARGET = deprecated
>>>>>>> >> > +
>>>>>>> >> > +# golf MAKE_FLAGS down to 80chars.. :-|
>>>>>>> >> > +_i = -include
>>>>>>> >> > +_incs = ${_i} src/GLibFacade.h ${_i} src/version.h ${_i} src/parser.h
>>>>>>> >> > +MAKE_FLAGS = CFLAGS="${CFLAGS} ${_incs}"  
>>>>>>> >>
>>>>>>> >> Why golf? Can't you just use backslashes as necessary? I would get rid
>>>>>>> >> of _i and _incs.
>>>>>>> >>  
>>>>>>> >
>>>>>>> > I think this approach is dangerous, better to keep those bits which are
>>>>>>> > normally part of upstream's Makefile in their Makefile and change the
>>>>>>> > way that you pass in CFLAGS. (e.g. maybe pass in COPTFLAGS instead and
>>>>>>> > change their Makefile to do COPTFLAGS?=-O3 and "CFLAGS?=${COPTFLAGS} ...
>>>>>>> > -include ...")
>>>>>>> >
>>>>>>> > But then again, we have cmake, why not just use that? It's upstream's
>>>>>>> > preferred build infrastructure, whereas for the make-based one they say
>>>>>>> > "I don't recommend this approach, but it should work in a pinch"..  
>>>>>>>
>>>>>>> Agree, this was sleazy and poorly considered.  I'm sorry.  Anytime I
>>>>>>> find myself golfing I should stop.
>>>>>>>
>>>>>>> Attached is new attempt that uses cmake instead.  Works for me on i386.
>>>>>>>
>>>>>>> N.B.: I set NO_TEST to Yes now because the tests are buried in a git
>>>>>>> submodule; furthermore, the repo on which the submodule is based has
>>>>>>> no tags and thus no releases, making it impossible for me to reach out
>>>>>>> for it as a distfile (unless I'm missing something).  I'm going to try
>>>>>>> to convince the upstream to start tagging that repo, but if I fail
>>>>>>> then I'll self-host a tarball for tests on the next update.
>>>>>>>
>>>>>>> Thanks as always for the feedback.
>>>>>>>
>>>>>>> Pax, -A
>>>>>>> --
>>>>>>> http://haqistan.net/~attila | [hidden email] | 0x62A729CF
>>>>>>
>>>>>> Atilla's patch works well for me on amd64. I have used it heavily for
>>>>>> several days. However, upstream has a new release, so here's a new
>>>>>> patch 99% based on atilla's.
>>>>>
>>>>> Nice!  Thanks for doing this.  Works for me on i386.
>>>>
>>>> Ping?  Diff attached that includes Micah Muer's updates.
>>>>
>>>> Pax, -A
>>>
>>> Reping?  New patch attached that brings us up to 5.2.0-1, released 16
>>> March.  Nothing new, just updated distinfo and Makefile.  Works for me
>>> under amd64, i386.
>>>
>>> Pax, -A
>>
>> Ping.
>>
>> Pax, -A
>
> Ping.
>
> Pax, -A
Ping.

Just tested that the diff works against recentish i386 snap (22 May).
Patch attached.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 15 Apr 2016 20:30:02 -0000
@@ -1,13 +1,13 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.2.0-1
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
-PKGNAME = multimarkdown-${V}
+PKGNAME = multimarkdown-${V:C/-/./}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
@@ -20,15 +20,19 @@ WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
+
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
 
 # Test files aren't included in distfile.
 NO_TEST = Yes
 
+pre-configure:
+ touch ${WRKBUILD}/README.html
+
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 15 Apr 2016 20:30:02 -0000
@@ -1,2 +1,2 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (MultiMarkdown-5-5.2.0-1.tar.gz) = be3wxbEGZQob8/ZZlHtBei0/S6T2FNyN3VI8RsEsyzI=
+SIZE (MultiMarkdown-5-5.2.0-1.tar.gz) = 135551
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Wed Mar 16 13:35:47 2016
++++ src/html.c Wed Mar 16 13:42:24 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
+rejected by upstream, keeping to quell ld-time warnings about strcat(3).
+--- src/latex.c.orig Wed Mar 16 13:44:52 2016
++++ src/latex.c Wed Mar 16 13:48:17 2016
+@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
+-
++ size_t result_len;
++
+ result = strdup(original);
+-
++ result_len = strlen(result);
++
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
++ if (strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
+
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
+strerror(3) if pledge(2) returns an error, as per practice elsewhere
+in the tree.
+--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
+@@ -63,6 +63,10 @@
+ #include "parser.h"
+ #include "transclude.h"
+ #include "version.h"
++#ifdef __OpenBSD__
++# include <errno.h> /* errno */
++# include <string.h> /* strerror(3) */
++#endif /* __OpenBSD__ */
+
+ /// main()
+ int main(int argc, char **argv)
+@@ -131,6 +135,13 @@ int main(int argc, char **argv)
+ unsigned long extensions = 0;
+ extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++#endif /* __OpenBSD__ */
++
+ /* process options */
+ while (1) {
+ int option_index = 0;
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
+@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+s/sprintf/asprintf/ and die on malloc failure
+--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
++++ src/parser.leg Wed Mar 16 13:59:00 2016
+@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto;
++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 15 Apr 2016 20:30:02 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
+ld-time warnings.
+--- src/writer.c.orig Wed Mar 16 13:55:05 2016
++++ src/writer.c Wed Mar 16 13:58:02 2016
+@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension, "px");
++    if (ptr)
++        ptr[1] = 't'; /* px -> pt */
+
+     result = g_string_new(dimension);
+    
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

Michael McConville-3
attila wrote:
> Ping.
>
> Just tested that the diff works against recentish i386 snap (22 May).
> Patch attached.

I can't comment on all of the changes, but this builds and runs fine for
me.


> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
> retrieving revision 1.2
> diff -u -p -r1.2 Makefile
> --- Makefile 5 Apr 2015 13:31:15 -0000 1.2
> +++ Makefile 15 Apr 2016 20:30:02 -0000
> @@ -1,13 +1,13 @@
>  # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
>  
> -V = 4.7.1
> +V = 5.2.0-1
>  COMMENT = marked-up plain text to formatted document converter
>  DISTNAME = ${GH_PROJECT}-${V}
> -PKGNAME = multimarkdown-${V}
> +PKGNAME = multimarkdown-${V:C/-/./}
>  CATEGORIES = textproc
>  
>  GH_ACCOUNT = fletcher
> -GH_PROJECT = MultiMarkdown-4
> +GH_PROJECT = MultiMarkdown-5
>  GH_TAGNAME = ${V}
>  
>  HOMEPAGE = http://fletcherpenney.net/multimarkdown/
> @@ -20,15 +20,19 @@ WANTLIB += c
>  
>  BUILD_DEPENDS = devel/greg
>  
> -USE_GMAKE = Yes
> -ALL_TARGET = ALL
> -MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
> - GREG=${LOCALBASE}/bin/greg
> +MODULES = devel/cmake
> +
> +CFLAGS += -DHAVE_SRAND_DETERMINISTIC
> +
> +CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
>  
>  # Test files aren't included in distfile.
>  NO_TEST = Yes
>  
> +pre-configure:
> + touch ${WRKBUILD}/README.html
> +
>  do-install:
> - ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
> + ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
>  
>  .include <bsd.port.mk>
> Index: distinfo
> ===================================================================
> RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 distinfo
> --- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ distinfo 15 Apr 2016 20:30:02 -0000
> @@ -1,2 +1,2 @@
> -SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
> -SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
> +SHA256 (MultiMarkdown-5-5.2.0-1.tar.gz) = be3wxbEGZQob8/ZZlHtBei0/S6T2FNyN3VI8RsEsyzI=
> +SIZE (MultiMarkdown-5-5.2.0-1.tar.gz) = 135551
> Index: patches/patch-CMakeLists_txt
> ===================================================================
> RCS file: patches/patch-CMakeLists_txt
> diff -N patches/patch-CMakeLists_txt
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-CMakeLists_txt 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,14 @@
> +$OpenBSD$
> +
> +Use installed greg
> +--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
> ++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
> +@@ -149,7 +149,7 @@ endif ()
> + # Need to build parser.c via greg
> + add_custom_command (
> + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
> +- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
> ++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
> + )
> +
> + # src_files are the primary files, and will be included in doxygen documentation
> Index: patches/patch-Makefile
> ===================================================================
> RCS file: patches/patch-Makefile
> diff -N patches/patch-Makefile
> --- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,37 +0,0 @@
> -$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
> -
> -Make it possible to pass GREG=/usr/local/bin/greg in on the
> -command line and avoid git submodules.
> -
> ---- Makefile.orig Mon Mar 23 18:21:56 2015
> -+++ Makefile Mon Mar 23 18:32:22 2015
> -@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
> - LDFLAGS += -static -static-libgcc
> - endif
> -
> --GREG= greg/greg
> -+# OUR_GREG: the version of greg in a submodule
> -+# GREG: the path to greg we want to use for parser.leg
> -+#
> -+# This way we can pass GREG=/usr/local/bin/greg in on
> -+# the command line if we have greg installed already.
> -
> -+OUR_GREG=greg/greg
> -+GREG?=$(OUR_GREG)
> -+
> - ALL : $(PROGRAM) enumMap.txt
> - static : $(PROGRAM) enumMap.txt
> -
> - %.o : %.c parser.h
> - $(CC) -c $(CFLAGS) -o $@ $<
> -
> --parser.c : parser.leg greg/greg parser.h
> -- greg/greg -o parser.c parser.leg
> -+parser.c : parser.leg $(GREG) parser.h
> -+ $(GREG) -o parser.c parser.leg
> -
> --$(GREG): greg
> -+$(OUR_GREG): greg
> - $(MAKE) -C greg
> -
> - $(PROGRAM) : $(OBJS)
> Index: patches/patch-html_c
> ===================================================================
> RCS file: patches/patch-html_c
> diff -N patches/patch-html_c
> --- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,59 +0,0 @@
> -$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
> -
> -Switch to using arc4random(3) everywhere, since they don't really want
> -repeatability (as evidenced by the arguments they pass to srand(3)).
> -
> ---- html.c.orig Mon Mar  9 18:52:39 2015
> -+++ html.c Sat Mar 21 15:44:10 2015
> -@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
> - scratch->footnote_para_counter --;
> - if (scratch->footnote_para_counter == 0) {
> - if (scratch->extensions & EXT_RANDOM_FOOT) {
> -+#ifdef HAVE_ARC4RANDOM
> -+ random = arc4random_uniform(99999) + 1;
> -+#else
> - srand(scratch->random_seed_base + scratch->footnote_to_print);
> - random = rand() % 99999 + 1;
> -+#endif
> - } else {
> - random = scratch->footnote_to_print;
> - }
> -@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
> - temp_node = node_for_count(scratch->used_notes, lev);
> -
> - if (scratch->extensions & EXT_RANDOM_FOOT) {
> -+#ifdef HAVE_ARC4RANDOM
> -+ random = arc4random_uniform(99999) + 1;
> -+#else
> - srand(scratch->random_seed_base + lev);
> - random = rand() % 99999 + 1;
> -+#endif
> - } else {
> - random = lev;
> - }
> -@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
> - fprintf(stderr, "matching cite found - %d\n",lev);
> - #endif
> - if (scratch->extensions & EXT_RANDOM_FOOT) {
> -+#ifdef HAVE_ARC4RANDOM
> -+ random = arc4random_uniform(99999) + 1;
> -+#else
> - srand(scratch->random_seed_base + lev);
> - random = rand() % 99999 + 1;
> -+#endif
> - } else {
> - random = lev;
> - }
> -@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
> - pad(out, 1, scratch);
> -
> - if (scratch->extensions & EXT_RANDOM_FOOT) {
> -+#ifdef HAVE_ARC4RANDOM
> -+ random = arc4random_uniform(99999) + 1;
> -+#else
> - srand(scratch->random_seed_base + counter);
> - random = rand() % 99999 + 1;
> -+#endif
> - } else {
> - random = counter;
> - }
> Index: patches/patch-latex_c
> ===================================================================
> RCS file: patches/patch-latex_c
> diff -N patches/patch-latex_c
> --- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,29 +0,0 @@
> -$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
> -
> -Switch from strcat(3) to a safer idiom.
> -
> ---- latex.c.orig Mon Mar  9 18:52:39 2015
> -+++ latex.c Sat Mar 21 15:44:10 2015
> -@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
> - char * correct_dimension_units(char *original) {
> - char *result;
> - int i;
> --
> -+ size_t result_len;
> -+
> - result = strdup(original);
> --
> -+ result_len = strlen(result);
> -+
> - for (i = 0; result[i]; i++)
> - result[i] = tolower(result[i]);
> -
> -- if (strstr(&result[strlen(result)-2],"px")) {
> -- result[strlen(result)-2] = '\0';
> -- strcat(result, "pt");
> -- }
> -+ if (strstr(&result[result_len-2],"px"))
> -+ result[result_len-1] = 't';
> -
> - return result;
> - }
> Index: patches/patch-parse_utilities_c
> ===================================================================
> RCS file: patches/patch-parse_utilities_c
> diff -N patches/patch-parse_utilities_c
> --- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,52 +0,0 @@
> -$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
> -
> -ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
> -
> ---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
> -+++ parse_utilities.c Wed Jan  7 16:02:19 2015
> -@@ -22,7 +22,9 @@
> - #include "parser.h"
> - #include <libgen.h>
> -
> -+#ifndef __OpenBSD__
> - #pragma mark - Parse Tree
> -+#endif /* __OpenBSD__ */
> -
> - /* Create a new node in the parse tree */
> - node * mk_node(int key) {
> -@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
> - }
> - }
> -
> -+#ifndef __OpenBSD__
> - #pragma mark - Parser Data
> -+#endif /* __OpenBSD__ */
> -
> - /* Create parser data - this is where you stash stuff to communicate
> - into and out of the parser */
> -@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
> - }
> -
> - /* mk_scratch_pad -- store stuff here while exporting the result tree */
> -+#ifndef HAVE_ARC4RANDOM
> - void ran_start(long seed);
> -+#endif
> - scratch_pad * mk_scratch_pad(unsigned long extensions) {
> - scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
> - result->extensions = extensions;
> -@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
> - result->table_alignment = NULL;
> - result->table_column = 0;
> -
> -+#ifndef HAVE_ARC4RANDOM
> - if (extensions & EXT_RANDOM_FOOT) {
> -    srand((int)time(NULL));
> - result->random_seed_base = rand() % 32000;
> -@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
> - result->random_seed_base = 0;
> - }
> - ran_start(310952L);
> -+#endif /* !HAVE_ARC4RANDOM */
> -
> - result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
> - result->lyx_level = 0;                    /* CRC - out outside level */
> Index: patches/patch-parser_leg
> ===================================================================
> RCS file: patches/patch-parser_leg
> diff -N patches/patch-parser_leg
> --- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,19 +0,0 @@
> -$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
> -
> -Switch from sprintf(3) to snprintf(3)
> -
> ---- parser.leg.orig Mon Mar  9 18:52:39 2015
> -+++ parser.leg Sat Mar 21 15:44:10 2015
> -@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
> -
> - AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
> - {
> -- char *mailto = malloc(strlen(yytext) + 8);
> -- sprintf(mailto, "mailto:%s", yytext);
> -+ size_t mailto_len = strlen(yytext) + 8;
> -+ char *mailto = malloc(mailto_len);
> -+ assert(mailto);
> -+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
> - $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
> - free(mailto);
> - }
> Index: patches/patch-src_html_c
> ===================================================================
> RCS file: patches/patch-src_html_c
> diff -N patches/patch-src_html_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_html_c 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,53 @@
> +$OpenBSD$
> +
> +Use srand_deterministic(3) if available.
> +--- src/html.c.orig Wed Mar 16 13:35:47 2016
> ++++ src/html.c Wed Mar 16 13:42:24 2016
> +@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
> + scratch->footnote_para_counter --;
> + if (scratch->footnote_para_counter == 0) {
> + if (scratch->extensions & EXT_RANDOM_FOOT) {
> ++#ifdef HAVE_SRAND_DETERMINISTIC
> ++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
> ++#else
> + srand(scratch->random_seed_base + scratch->footnote_to_print);
> ++#endif /* HAVE_SRAND_DETERMINISTIC */
> + random = rand() % 99999 + 1;
> + } else {
> + random = scratch->footnote_to_print;
> +@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
> + temp_node = node_for_count(scratch->used_notes, lev);
> +
> + if (scratch->extensions & EXT_RANDOM_FOOT) {
> ++#ifdef HAVE_SRAND_DETERMINISTIC
> ++ srand_deterministic(scratch->random_seed_base + lev);
> ++#else
> + srand(scratch->random_seed_base + lev);
> ++#endif /* HAVE_SRAND_DETERMINISTIC */
> + random = rand() % 99999 + 1;
> + } else {
> + random = lev;
> +@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
> + fprintf(stderr, "matching cite found - %d\n",lev);
> + #endif
> + if (scratch->extensions & EXT_RANDOM_FOOT) {
> ++#ifdef HAVE_SRAND_DETERMINISTIC
> ++ srand_deterministic(scratch->random_seed_base + lev);
> ++#else
> + srand(scratch->random_seed_base + lev);
> ++#endif /* HAVE_SRAND_DETERMINISTIC */
> + random = rand() % 99999 + 1;
> + } else {
> + random = lev;
> +@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
> + pad(out, 1, scratch);
> +
> + if (scratch->extensions & EXT_RANDOM_FOOT) {
> ++#ifdef HAVE_SRAND_DETERMINISTIC
> ++ srand_deterministic(scratch->random_seed_base + counter);
> ++#else
> + srand(scratch->random_seed_base + counter);
> ++#endif /* HAVE_SRAND_DETERMINISTIC */
> + random = rand() % 99999 + 1;
> + } else {
> + random = counter;
> Index: patches/patch-src_latex_c
> ===================================================================
> RCS file: patches/patch-src_latex_c
> diff -N patches/patch-src_latex_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_latex_c 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,29 @@
> +$OpenBSD$
> +
> +Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
> +rejected by upstream, keeping to quell ld-time warnings about strcat(3).
> +--- src/latex.c.orig Wed Mar 16 13:44:52 2016
> ++++ src/latex.c Wed Mar 16 13:48:17 2016
> +@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
> + char * correct_dimension_units(char *original) {
> + char *result;
> + int i;
> +-
> ++ size_t result_len;
> ++
> + result = strdup(original);
> +-
> ++ result_len = strlen(result);
> ++
> + for (i = 0; result[i]; i++)
> + result[i] = tolower(result[i]);
> +
> +- if (strstr(&result[strlen(result)-2],"px")) {
> +- result[strlen(result)-2] = '\0';
> +- strcat(result, "pt");
> +- }
> ++ if (strstr(&result[result_len-2],"px"))
> ++ result[result_len-1] = 't';
> +
> + return result;
> + }
> Index: patches/patch-src_multimarkdown_c
> ===================================================================
> RCS file: patches/patch-src_multimarkdown_c
> diff -N patches/patch-src_multimarkdown_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_multimarkdown_c 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,32 @@
> +$OpenBSD$
> +
> +Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
> +strerror(3) if pledge(2) returns an error, as per practice elsewhere
> +in the tree.
> +--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
> ++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
> +@@ -63,6 +63,10 @@
> + #include "parser.h"
> + #include "transclude.h"
> + #include "version.h"
> ++#ifdef __OpenBSD__
> ++# include <errno.h> /* errno */
> ++# include <string.h> /* strerror(3) */
> ++#endif /* __OpenBSD__ */
> +
> + /// main()
> + int main(int argc, char **argv)
> +@@ -131,6 +135,13 @@ int main(int argc, char **argv)
> + unsigned long extensions = 0;
> + extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
> +
> ++#ifdef __OpenBSD__
> ++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
> ++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
> ++ exit(EXIT_FAILURE);
> ++ }
> ++#endif /* __OpenBSD__ */
> ++
> + /* process options */
> + while (1) {
> + int option_index = 0;
> Index: patches/patch-src_parse_utilities_c
> ===================================================================
> RCS file: patches/patch-src_parse_utilities_c
> diff -N patches/patch-src_parse_utilities_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_parse_utilities_c 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,31 @@
> +$OpenBSD$
> +
> +Use srand_deterministic(3) on OpenBSD
> +--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
> ++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
> +@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
> + result->inside_footnote = 0;
> +
> + if (extensions & EXT_RANDOM_FOOT) {
> ++#ifdef HAVE_SRAND_DETERMINISTIC
> ++    srand_deterministic((int)time(NULL));
> ++#else
> +    srand((int)time(NULL));
> ++#endif /* HAVE_SRAND_DETERMINISTIC */
> + result->random_seed_base = rand() % 32000;
> + } else {
> ++#ifdef HAVE_SRAND_DETERMINISTIC
> ++ srand_deterministic(1);
> ++#else
> + srand(1);
> ++#endif /* HAVE_SRAND_DETERMINISTIC */
> + result->random_seed_base = 0;
> + }
> + ran_start(310952L);
> +@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
> + result[len] = '\0';
> +
> + return result;
> +-}
> +\ No newline at end of file
> ++}
> Index: patches/patch-src_parser_leg
> ===================================================================
> RCS file: patches/patch-src_parser_leg
> diff -N patches/patch-src_parser_leg
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_parser_leg 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,16 @@
> +$OpenBSD$
> +
> +s/sprintf/asprintf/ and die on malloc failure
> +--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
> ++++ src/parser.leg Wed Mar 16 13:59:00 2016
> +@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
> +
> + AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
> + {
> +- char *mailto = malloc(strlen(yytext) + 8);
> +- sprintf(mailto, "mailto:%s", yytext);
> ++ char *mailto;
> ++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
> + $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
> + free(mailto);
> + }
> Index: patches/patch-src_writer_c
> ===================================================================
> RCS file: patches/patch-src_writer_c
> diff -N patches/patch-src_writer_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_writer_c 15 Apr 2016 20:30:02 -0000
> @@ -0,0 +1,21 @@
> +$OpenBSD$
> +
> +Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
> +ld-time warnings.
> +--- src/writer.c.orig Wed Mar 16 13:55:05 2016
> ++++ src/writer.c Wed Mar 16 13:58:02 2016
> +@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
> + fprintf(stderr, "b\n");
> + #endif
> +
> +-    if (strstr(dimension, "px")) {
> +-        ptr = strstr(dimension,"px");
> +-        ptr[0] = '\0';
> +-        strcat(ptr,"pt");
> +-    }
> ++    ptr = strstr(dimension, "px");
> ++    if (ptr)
> ++        ptr[1] = 't'; /* px -> pt */
> +
> +     result = g_string_new(dimension);
> +    
> Index: patches/patch-writer_c
> ===================================================================
> RCS file: patches/patch-writer_c
> diff -N patches/patch-writer_c
> --- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,42 +0,0 @@
> -$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
> -
> -Switch from strcat to a safer idiom.
> -
> ---- writer.c.orig Mon Mar  9 18:52:39 2015
> -+++ writer.c Sat Mar 21 15:44:10 2015
> -@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
> -     int i;
> -     char *upper;
> -     GString *result;
> -+    size_t dimension_len;
> -
> -     attribute = node_for_attribute(querystring, list);
> -     if (attribute == NULL) return NULL;
> -@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
> - fprintf(stderr, "a\n");
> - #endif
> -
> -+    dimension_len = strlen(attribute->children->str);
> -     dimension = strdup(attribute->children->str);
> -     upper = strdup(attribute->children->str);
> -
> -@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
> - fprintf(stderr, "b\n");
> - #endif
> -
> --    if (strstr(dimension, "px")) {
> --        ptr = strstr(dimension,"px");
> --        ptr[0] = '\0';
> --        strcat(ptr,"pt");
> --    }
> -+    ptr = strstr(dimension, "px");
> -+    if (ptr)
> -+        ptr[1] = 't';
> -
> -     result = g_string_new(dimension);
> -    
> --    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
> -+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
> -         /* no units */
> -         g_string_append_printf(result, "pt");
> -     }

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

Michael McConville <[hidden email]> writes:

> attila wrote:
>> Ping.
>>
>> Just tested that the diff works against recentish i386 snap (22 May).
>> Patch attached.
>
> I can't comment on all of the changes, but this builds and runs fine for
> me.

Thanks for looking at it, but the upstream has moved on and there's a
newer release.  I'm working on an update to that instead, and maybe
finally get the unit tests working... I'll try to post something soon
(today or tomorrow).

Pax, -A

>
>> Index: Makefile
>> ===================================================================
>> RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
>> retrieving revision 1.2
>> diff -u -p -r1.2 Makefile
>> --- Makefile 5 Apr 2015 13:31:15 -0000 1.2
>> +++ Makefile 15 Apr 2016 20:30:02 -0000
>> @@ -1,13 +1,13 @@
>>  # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
>>  
>> -V = 4.7.1
>> +V = 5.2.0-1
>>  COMMENT = marked-up plain text to formatted document converter
>>  DISTNAME = ${GH_PROJECT}-${V}
>> -PKGNAME = multimarkdown-${V}
>> +PKGNAME = multimarkdown-${V:C/-/./}
>>  CATEGORIES = textproc
>>  
>>  GH_ACCOUNT = fletcher
>> -GH_PROJECT = MultiMarkdown-4
>> +GH_PROJECT = MultiMarkdown-5
>>  GH_TAGNAME = ${V}
>>  
>>  HOMEPAGE = http://fletcherpenney.net/multimarkdown/
>> @@ -20,15 +20,19 @@ WANTLIB += c
>>  
>>  BUILD_DEPENDS = devel/greg
>>  
>> -USE_GMAKE = Yes
>> -ALL_TARGET = ALL
>> -MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
>> - GREG=${LOCALBASE}/bin/greg
>> +MODULES = devel/cmake
>> +
>> +CFLAGS += -DHAVE_SRAND_DETERMINISTIC
>> +
>> +CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
>>  
>>  # Test files aren't included in distfile.
>>  NO_TEST = Yes
>>  
>> +pre-configure:
>> + touch ${WRKBUILD}/README.html
>> +
>>  do-install:
>> - ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
>> + ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
>>  
>>  .include <bsd.port.mk>
>> Index: distinfo
>> ===================================================================
>> RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
>> retrieving revision 1.1.1.1
>> diff -u -p -r1.1.1.1 distinfo
>> --- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ distinfo 15 Apr 2016 20:30:02 -0000
>> @@ -1,2 +1,2 @@
>> -SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
>> -SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
>> +SHA256 (MultiMarkdown-5-5.2.0-1.tar.gz) = be3wxbEGZQob8/ZZlHtBei0/S6T2FNyN3VI8RsEsyzI=
>> +SIZE (MultiMarkdown-5-5.2.0-1.tar.gz) = 135551
>> Index: patches/patch-CMakeLists_txt
>> ===================================================================
>> RCS file: patches/patch-CMakeLists_txt
>> diff -N patches/patch-CMakeLists_txt
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-CMakeLists_txt 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,14 @@
>> +$OpenBSD$
>> +
>> +Use installed greg
>> +--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
>> ++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
>> +@@ -149,7 +149,7 @@ endif ()
>> + # Need to build parser.c via greg
>> + add_custom_command (
>> + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
>> +- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
>> ++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
>> + )
>> +
>> + # src_files are the primary files, and will be included in doxygen documentation
>> Index: patches/patch-Makefile
>> ===================================================================
>> RCS file: patches/patch-Makefile
>> diff -N patches/patch-Makefile
>> --- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ /dev/null 1 Jan 1970 00:00:00 -0000
>> @@ -1,37 +0,0 @@
>> -$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
>> -
>> -Make it possible to pass GREG=/usr/local/bin/greg in on the
>> -command line and avoid git submodules.
>> -
>> ---- Makefile.orig Mon Mar 23 18:21:56 2015
>> -+++ Makefile Mon Mar 23 18:32:22 2015
>> -@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
>> - LDFLAGS += -static -static-libgcc
>> - endif
>> -
>> --GREG= greg/greg
>> -+# OUR_GREG: the version of greg in a submodule
>> -+# GREG: the path to greg we want to use for parser.leg
>> -+#
>> -+# This way we can pass GREG=/usr/local/bin/greg in on
>> -+# the command line if we have greg installed already.
>> -
>> -+OUR_GREG=greg/greg
>> -+GREG?=$(OUR_GREG)
>> -+
>> - ALL : $(PROGRAM) enumMap.txt
>> - static : $(PROGRAM) enumMap.txt
>> -
>> - %.o : %.c parser.h
>> - $(CC) -c $(CFLAGS) -o $@ $<
>> -
>> --parser.c : parser.leg greg/greg parser.h
>> -- greg/greg -o parser.c parser.leg
>> -+parser.c : parser.leg $(GREG) parser.h
>> -+ $(GREG) -o parser.c parser.leg
>> -
>> --$(GREG): greg
>> -+$(OUR_GREG): greg
>> - $(MAKE) -C greg
>> -
>> - $(PROGRAM) : $(OBJS)
>> Index: patches/patch-html_c
>> ===================================================================
>> RCS file: patches/patch-html_c
>> diff -N patches/patch-html_c
>> --- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ /dev/null 1 Jan 1970 00:00:00 -0000
>> @@ -1,59 +0,0 @@
>> -$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
>> -
>> -Switch to using arc4random(3) everywhere, since they don't really want
>> -repeatability (as evidenced by the arguments they pass to srand(3)).
>> -
>> ---- html.c.orig Mon Mar  9 18:52:39 2015
>> -+++ html.c Sat Mar 21 15:44:10 2015
>> -@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
>> - scratch->footnote_para_counter --;
>> - if (scratch->footnote_para_counter == 0) {
>> - if (scratch->extensions & EXT_RANDOM_FOOT) {
>> -+#ifdef HAVE_ARC4RANDOM
>> -+ random = arc4random_uniform(99999) + 1;
>> -+#else
>> - srand(scratch->random_seed_base + scratch->footnote_to_print);
>> - random = rand() % 99999 + 1;
>> -+#endif
>> - } else {
>> - random = scratch->footnote_to_print;
>> - }
>> -@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
>> - temp_node = node_for_count(scratch->used_notes, lev);
>> -
>> - if (scratch->extensions & EXT_RANDOM_FOOT) {
>> -+#ifdef HAVE_ARC4RANDOM
>> -+ random = arc4random_uniform(99999) + 1;
>> -+#else
>> - srand(scratch->random_seed_base + lev);
>> - random = rand() % 99999 + 1;
>> -+#endif
>> - } else {
>> - random = lev;
>> - }
>> -@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
>> - fprintf(stderr, "matching cite found - %d\n",lev);
>> - #endif
>> - if (scratch->extensions & EXT_RANDOM_FOOT) {
>> -+#ifdef HAVE_ARC4RANDOM
>> -+ random = arc4random_uniform(99999) + 1;
>> -+#else
>> - srand(scratch->random_seed_base + lev);
>> - random = rand() % 99999 + 1;
>> -+#endif
>> - } else {
>> - random = lev;
>> - }
>> -@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
>> - pad(out, 1, scratch);
>> -
>> - if (scratch->extensions & EXT_RANDOM_FOOT) {
>> -+#ifdef HAVE_ARC4RANDOM
>> -+ random = arc4random_uniform(99999) + 1;
>> -+#else
>> - srand(scratch->random_seed_base + counter);
>> - random = rand() % 99999 + 1;
>> -+#endif
>> - } else {
>> - random = counter;
>> - }
>> Index: patches/patch-latex_c
>> ===================================================================
>> RCS file: patches/patch-latex_c
>> diff -N patches/patch-latex_c
>> --- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ /dev/null 1 Jan 1970 00:00:00 -0000
>> @@ -1,29 +0,0 @@
>> -$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
>> -
>> -Switch from strcat(3) to a safer idiom.
>> -
>> ---- latex.c.orig Mon Mar  9 18:52:39 2015
>> -+++ latex.c Sat Mar 21 15:44:10 2015
>> -@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
>> - char * correct_dimension_units(char *original) {
>> - char *result;
>> - int i;
>> --
>> -+ size_t result_len;
>> -+
>> - result = strdup(original);
>> --
>> -+ result_len = strlen(result);
>> -+
>> - for (i = 0; result[i]; i++)
>> - result[i] = tolower(result[i]);
>> -
>> -- if (strstr(&result[strlen(result)-2],"px")) {
>> -- result[strlen(result)-2] = '\0';
>> -- strcat(result, "pt");
>> -- }
>> -+ if (strstr(&result[result_len-2],"px"))
>> -+ result[result_len-1] = 't';
>> -
>> - return result;
>> - }
>> Index: patches/patch-parse_utilities_c
>> ===================================================================
>> RCS file: patches/patch-parse_utilities_c
>> diff -N patches/patch-parse_utilities_c
>> --- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ /dev/null 1 Jan 1970 00:00:00 -0000
>> @@ -1,52 +0,0 @@
>> -$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
>> -
>> -ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
>> -
>> ---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
>> -+++ parse_utilities.c Wed Jan  7 16:02:19 2015
>> -@@ -22,7 +22,9 @@
>> - #include "parser.h"
>> - #include <libgen.h>
>> -
>> -+#ifndef __OpenBSD__
>> - #pragma mark - Parse Tree
>> -+#endif /* __OpenBSD__ */
>> -
>> - /* Create a new node in the parse tree */
>> - node * mk_node(int key) {
>> -@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
>> - }
>> - }
>> -
>> -+#ifndef __OpenBSD__
>> - #pragma mark - Parser Data
>> -+#endif /* __OpenBSD__ */
>> -
>> - /* Create parser data - this is where you stash stuff to communicate
>> - into and out of the parser */
>> -@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
>> - }
>> -
>> - /* mk_scratch_pad -- store stuff here while exporting the result tree */
>> -+#ifndef HAVE_ARC4RANDOM
>> - void ran_start(long seed);
>> -+#endif
>> - scratch_pad * mk_scratch_pad(unsigned long extensions) {
>> - scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
>> - result->extensions = extensions;
>> -@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
>> - result->table_alignment = NULL;
>> - result->table_column = 0;
>> -
>> -+#ifndef HAVE_ARC4RANDOM
>> - if (extensions & EXT_RANDOM_FOOT) {
>> -    srand((int)time(NULL));
>> - result->random_seed_base = rand() % 32000;
>> -@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
>> - result->random_seed_base = 0;
>> - }
>> - ran_start(310952L);
>> -+#endif /* !HAVE_ARC4RANDOM */
>> -
>> - result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
>> - result->lyx_level = 0;                    /* CRC - out outside level */
>> Index: patches/patch-parser_leg
>> ===================================================================
>> RCS file: patches/patch-parser_leg
>> diff -N patches/patch-parser_leg
>> --- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ /dev/null 1 Jan 1970 00:00:00 -0000
>> @@ -1,19 +0,0 @@
>> -$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
>> -
>> -Switch from sprintf(3) to snprintf(3)
>> -
>> ---- parser.leg.orig Mon Mar  9 18:52:39 2015
>> -+++ parser.leg Sat Mar 21 15:44:10 2015
>> -@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
>> -
>> - AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
>> - {
>> -- char *mailto = malloc(strlen(yytext) + 8);
>> -- sprintf(mailto, "mailto:%s", yytext);
>> -+ size_t mailto_len = strlen(yytext) + 8;
>> -+ char *mailto = malloc(mailto_len);
>> -+ assert(mailto);
>> -+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
>> - $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
>> - free(mailto);
>> - }
>> Index: patches/patch-src_html_c
>> ===================================================================
>> RCS file: patches/patch-src_html_c
>> diff -N patches/patch-src_html_c
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-src_html_c 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,53 @@
>> +$OpenBSD$
>> +
>> +Use srand_deterministic(3) if available.
>> +--- src/html.c.orig Wed Mar 16 13:35:47 2016
>> ++++ src/html.c Wed Mar 16 13:42:24 2016
>> +@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
>> + scratch->footnote_para_counter --;
>> + if (scratch->footnote_para_counter == 0) {
>> + if (scratch->extensions & EXT_RANDOM_FOOT) {
>> ++#ifdef HAVE_SRAND_DETERMINISTIC
>> ++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
>> ++#else
>> + srand(scratch->random_seed_base + scratch->footnote_to_print);
>> ++#endif /* HAVE_SRAND_DETERMINISTIC */
>> + random = rand() % 99999 + 1;
>> + } else {
>> + random = scratch->footnote_to_print;
>> +@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
>> + temp_node = node_for_count(scratch->used_notes, lev);
>> +
>> + if (scratch->extensions & EXT_RANDOM_FOOT) {
>> ++#ifdef HAVE_SRAND_DETERMINISTIC
>> ++ srand_deterministic(scratch->random_seed_base + lev);
>> ++#else
>> + srand(scratch->random_seed_base + lev);
>> ++#endif /* HAVE_SRAND_DETERMINISTIC */
>> + random = rand() % 99999 + 1;
>> + } else {
>> + random = lev;
>> +@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
>> + fprintf(stderr, "matching cite found - %d\n",lev);
>> + #endif
>> + if (scratch->extensions & EXT_RANDOM_FOOT) {
>> ++#ifdef HAVE_SRAND_DETERMINISTIC
>> ++ srand_deterministic(scratch->random_seed_base + lev);
>> ++#else
>> + srand(scratch->random_seed_base + lev);
>> ++#endif /* HAVE_SRAND_DETERMINISTIC */
>> + random = rand() % 99999 + 1;
>> + } else {
>> + random = lev;
>> +@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
>> + pad(out, 1, scratch);
>> +
>> + if (scratch->extensions & EXT_RANDOM_FOOT) {
>> ++#ifdef HAVE_SRAND_DETERMINISTIC
>> ++ srand_deterministic(scratch->random_seed_base + counter);
>> ++#else
>> + srand(scratch->random_seed_base + counter);
>> ++#endif /* HAVE_SRAND_DETERMINISTIC */
>> + random = rand() % 99999 + 1;
>> + } else {
>> + random = counter;
>> Index: patches/patch-src_latex_c
>> ===================================================================
>> RCS file: patches/patch-src_latex_c
>> diff -N patches/patch-src_latex_c
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-src_latex_c 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,29 @@
>> +$OpenBSD$
>> +
>> +Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
>> +rejected by upstream, keeping to quell ld-time warnings about strcat(3).
>> +--- src/latex.c.orig Wed Mar 16 13:44:52 2016
>> ++++ src/latex.c Wed Mar 16 13:48:17 2016
>> +@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
>> + char * correct_dimension_units(char *original) {
>> + char *result;
>> + int i;
>> +-
>> ++ size_t result_len;
>> ++
>> + result = strdup(original);
>> +-
>> ++ result_len = strlen(result);
>> ++
>> + for (i = 0; result[i]; i++)
>> + result[i] = tolower(result[i]);
>> +
>> +- if (strstr(&result[strlen(result)-2],"px")) {
>> +- result[strlen(result)-2] = '\0';
>> +- strcat(result, "pt");
>> +- }
>> ++ if (strstr(&result[result_len-2],"px"))
>> ++ result[result_len-1] = 't';
>> +
>> + return result;
>> + }
>> Index: patches/patch-src_multimarkdown_c
>> ===================================================================
>> RCS file: patches/patch-src_multimarkdown_c
>> diff -N patches/patch-src_multimarkdown_c
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-src_multimarkdown_c 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,32 @@
>> +$OpenBSD$
>> +
>> +Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
>> +strerror(3) if pledge(2) returns an error, as per practice elsewhere
>> +in the tree.
>> +--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
>> ++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
>> +@@ -63,6 +63,10 @@
>> + #include "parser.h"
>> + #include "transclude.h"
>> + #include "version.h"
>> ++#ifdef __OpenBSD__
>> ++# include <errno.h> /* errno */
>> ++# include <string.h> /* strerror(3) */
>> ++#endif /* __OpenBSD__ */
>> +
>> + /// main()
>> + int main(int argc, char **argv)
>> +@@ -131,6 +135,13 @@ int main(int argc, char **argv)
>> + unsigned long extensions = 0;
>> + extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
>> +
>> ++#ifdef __OpenBSD__
>> ++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
>> ++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
>> ++ exit(EXIT_FAILURE);
>> ++ }
>> ++#endif /* __OpenBSD__ */
>> ++
>> + /* process options */
>> + while (1) {
>> + int option_index = 0;
>> Index: patches/patch-src_parse_utilities_c
>> ===================================================================
>> RCS file: patches/patch-src_parse_utilities_c
>> diff -N patches/patch-src_parse_utilities_c
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-src_parse_utilities_c 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,31 @@
>> +$OpenBSD$
>> +
>> +Use srand_deterministic(3) on OpenBSD
>> +--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
>> ++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
>> +@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
>> + result->inside_footnote = 0;
>> +
>> + if (extensions & EXT_RANDOM_FOOT) {
>> ++#ifdef HAVE_SRAND_DETERMINISTIC
>> ++    srand_deterministic((int)time(NULL));
>> ++#else
>> +    srand((int)time(NULL));
>> ++#endif /* HAVE_SRAND_DETERMINISTIC */
>> + result->random_seed_base = rand() % 32000;
>> + } else {
>> ++#ifdef HAVE_SRAND_DETERMINISTIC
>> ++ srand_deterministic(1);
>> ++#else
>> + srand(1);
>> ++#endif /* HAVE_SRAND_DETERMINISTIC */
>> + result->random_seed_base = 0;
>> + }
>> + ran_start(310952L);
>> +@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
>> + result[len] = '\0';
>> +
>> + return result;
>> +-}
>> +\ No newline at end of file
>> ++}
>> Index: patches/patch-src_parser_leg
>> ===================================================================
>> RCS file: patches/patch-src_parser_leg
>> diff -N patches/patch-src_parser_leg
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-src_parser_leg 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,16 @@
>> +$OpenBSD$
>> +
>> +s/sprintf/asprintf/ and die on malloc failure
>> +--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
>> ++++ src/parser.leg Wed Mar 16 13:59:00 2016
>> +@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
>> +
>> + AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
>> + {
>> +- char *mailto = malloc(strlen(yytext) + 8);
>> +- sprintf(mailto, "mailto:%s", yytext);
>> ++ char *mailto;
>> ++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
>> + $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
>> + free(mailto);
>> + }
>> Index: patches/patch-src_writer_c
>> ===================================================================
>> RCS file: patches/patch-src_writer_c
>> diff -N patches/patch-src_writer_c
>> --- /dev/null 1 Jan 1970 00:00:00 -0000
>> +++ patches/patch-src_writer_c 15 Apr 2016 20:30:02 -0000
>> @@ -0,0 +1,21 @@
>> +$OpenBSD$
>> +
>> +Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
>> +ld-time warnings.
>> +--- src/writer.c.orig Wed Mar 16 13:55:05 2016
>> ++++ src/writer.c Wed Mar 16 13:58:02 2016
>> +@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
>> + fprintf(stderr, "b\n");
>> + #endif
>> +
>> +-    if (strstr(dimension, "px")) {
>> +-        ptr = strstr(dimension,"px");
>> +-        ptr[0] = '\0';
>> +-        strcat(ptr,"pt");
>> +-    }
>> ++    ptr = strstr(dimension, "px");
>> ++    if (ptr)
>> ++        ptr[1] = 't'; /* px -> pt */
>> +
>> +     result = g_string_new(dimension);
>> +    
>> Index: patches/patch-writer_c
>> ===================================================================
>> RCS file: patches/patch-writer_c
>> diff -N patches/patch-writer_c
>> --- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
>> +++ /dev/null 1 Jan 1970 00:00:00 -0000
>> @@ -1,42 +0,0 @@
>> -$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
>> -
>> -Switch from strcat to a safer idiom.
>> -
>> ---- writer.c.orig Mon Mar  9 18:52:39 2015
>> -+++ writer.c Sat Mar 21 15:44:10 2015
>> -@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
>> -     int i;
>> -     char *upper;
>> -     GString *result;
>> -+    size_t dimension_len;
>> -
>> -     attribute = node_for_attribute(querystring, list);
>> -     if (attribute == NULL) return NULL;
>> -@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
>> - fprintf(stderr, "a\n");
>> - #endif
>> -
>> -+    dimension_len = strlen(attribute->children->str);
>> -     dimension = strdup(attribute->children->str);
>> -     upper = strdup(attribute->children->str);
>> -
>> -@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
>> - fprintf(stderr, "b\n");
>> - #endif
>> -
>> --    if (strstr(dimension, "px")) {
>> --        ptr = strstr(dimension,"px");
>> --        ptr[0] = '\0';
>> --        strcat(ptr,"pt");
>> --    }
>> -+    ptr = strstr(dimension, "px");
>> -+    if (ptr)
>> -+        ptr[1] = 't';
>> -
>> -     result = g_string_new(dimension);
>> -    
>> --    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
>> -+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
>> -         /* no units */
>> -         g_string_append_printf(result, "pt");
>> -     }

--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila
In reply to this post by Michael McConville-3

Michael McConville <[hidden email]> writes:

> attila wrote:
>> Ping.
>>
>> Just tested that the diff works against recentish i386 snap (22 May).
>> Patch attached.
>
> I can't comment on all of the changes, but this builds and runs fine for
> me.
>

Attached is an update that brings us from 4.7.1 to 5.4.0, released 8
Aug.  It shuffles the patches around because the source tree was
rearranged and adds support for tests.  Sadly, the tests don't all
pass.  I think I need a t-dep for something LaTeXish but I'm not sure
what is best, nor am I sure if that's the only reason for the
failures.  If anyone has a spare cycle or two to look at it I'd
appreciate it.  If not I'll get back to it by the end of the week.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 9 Aug 2016 19:50:42 -0000
@@ -1,15 +1,19 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.4.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
-PKGNAME = multimarkdown-${V}
+PKGNAME = multimarkdown-${V:C/-/./}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
+TESTS_COMMIT = 8d5ad66e3bbaeb0de8646783bfe964261ddb39c7
+DIST_SUBDIR = multimarkdown
+MASTER_SITES_GITHUB = https://github.com/fletcher/MMD-Test-Suite/archive/
+DISTFILES = ${DISTNAME}${EXTRACT_SUFX} ${TESTS_COMMIT}${EXTRACT_SUFX}
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
 MAINTAINER = Sean Levy <[hidden email]>
 
@@ -20,15 +24,24 @@ WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
 
-# Test files aren't included in distfile.
-NO_TEST = Yes
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
+
+# Not all tests pass now but make test does something
+#NO_TEST = No
+
+post-extract:
+ rm -rf ${WRKSRC}/submodules/MarkdownTest
+ tar -C ${WRKSRC}/submodules -zxf ${FULLDISTDIR}/${TESTS_COMMIT}${EXTRACT_SUFX}
+ mv ${WRKSRC}/submodules/MMD-Test-Suite-${TESTS_COMMIT} ${WRKSRC}/submodules/MarkdownTest
+
+pre-configure:
+ touch ${WRKBUILD}/README.html
 
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 9 Aug 2016 19:50:42 -0000
@@ -1,2 +1,4 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = xGdoX+aZ/y+8ND+LXK24XSgNCccYJV9S6qAW2NI/DKw=
+SHA256 (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = HMA4X/1sghwmXpcPgcxOwAnH7Lv7EuDhFce7WzPQmoM=
+SIZE (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = 185408
+SIZE (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = 136693
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Wed Mar 16 13:35:47 2016
++++ src/html.c Wed Mar 16 13:42:24 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -599,7 +603,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -653,7 +661,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -946,7 +958,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+Avoid strcat(3) using similar strategy to patch-src_writer_c.  Was also
+rejected by upstream, keeping to quell ld-time warnings about strcat(3).
+--- src/latex.c.orig Wed Mar 16 13:44:52 2016
++++ src/latex.c Wed Mar 16 13:48:17 2016
+@@ -1218,16 +1218,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
+-
++ size_t result_len;
++
+ result = strdup(original);
+-
++ result_len = strlen(result);
++
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
++ if (strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
+
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.  Include <string.h> on OpenBSD so we can use
+strerror(3) if pledge(2) returns an error, as per practice elsewhere
+in the tree.
+--- src/multimarkdown.c.orig Mon Feb 22 20:05:02 2016
++++ src/multimarkdown.c Wed Mar 16 14:56:04 2016
+@@ -63,6 +63,10 @@
+ #include "parser.h"
+ #include "transclude.h"
+ #include "version.h"
++#ifdef __OpenBSD__
++# include <errno.h> /* errno */
++# include <string.h> /* strerror(3) */
++#endif /* __OpenBSD__ */
+
+ /// main()
+ int main(int argc, char **argv)
+@@ -131,6 +135,13 @@ int main(int argc, char **argv)
+ unsigned long extensions = 0;
+ extensions = extensions | EXT_SMART | EXT_NOTES | EXT_OBFUSCATE;
+
++#ifdef __OpenBSD__
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr, "%s: pledge: %s\n", argv[0], strerror(errno));
++ exit(EXIT_FAILURE);
++ }
++#endif /* __OpenBSD__ */
++
+ /* process options */
+ while (1) {
+ int option_index = 0;
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Wed Mar 16 14:30:51 2016
++++ src/parse_utilities.c Wed Mar 16 14:32:10 2016
+@@ -267,10 +267,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -905,4 +913,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+s/sprintf/asprintf/ and die on malloc failure
+--- src/parser.leg.orig Wed Mar 16 13:59:32 2016
++++ src/parser.leg Wed Mar 16 13:59:00 2016
+@@ -612,8 +612,8 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto;
++ assert(asprintf(&mailto, "mailto:%s", yytext) >= 7);
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 9 Aug 2016 19:50:42 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+Avoid strcat(3).  Was rejected by upstream previously, keeping to quell
+ld-time warnings.
+--- src/writer.c.orig Wed Mar 16 13:55:05 2016
++++ src/writer.c Wed Mar 16 13:58:02 2016
+@@ -696,11 +696,9 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension, "px");
++    if (ptr)
++        ptr[1] = 't'; /* px -> pt */
+
+     result = g_string_new(dimension);
+    
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> Michael McConville <[hidden email]> writes:
>
>> attila wrote:
>>> Ping.
>>>
>>> Just tested that the diff works against recentish i386 snap (22 May).
>>> Patch attached.
>>
>> I can't comment on all of the changes, but this builds and runs fine for
>> me.
>>
>
> Attached is an update that brings us from 4.7.1 to 5.4.0, released 8
> Aug.  It shuffles the patches around because the source tree was
> rearranged and adds support for tests.  Sadly, the tests don't all
> pass.  I think I need a t-dep for something LaTeXish but I'm not sure
> what is best, nor am I sure if that's the only reason for the
> failures.  If anyone has a spare cycle or two to look at it I'd
> appreciate it.  If not I'll get back to it by the end of the week.
>
> Pax, -A
I finally got back to this.  It turns out there wasn't much standing
in the way of the tests working other than me.  Attached is a patch
that brings textproc/multimarkdown up to the latest release (5.4.0
released 5 Aug).  Notable changes:

* Switched to CMake;
* Ditched the patches I tried and failed to upstream (strcat/sprintf);
* Reworked two remaining patches (HAVE_SRAND_DETERMINISTIC) in the hope
  I might get them upstream;
* Added pledge;
* make test now passes all tests.

Tested on amd64.

Comments, feedback most welcome.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 15 Sep 2016 21:41:05 -0000
@@ -1,34 +1,45 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.4.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
-PKGNAME = multimarkdown-${V}
+PKGNAME = multimarkdown-${V:C/-/./}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
+TESTS_COMMIT = 8d5ad66e3bbaeb0de8646783bfe964261ddb39c7
+DIST_SUBDIR = multimarkdown
+MASTER_SITES_GITHUB = https://github.com/fletcher/MMD-Test-Suite/archive/
+DISTFILES = ${DISTNAME}${EXTRACT_SUFX} ${TESTS_COMMIT}${EXTRACT_SUFX}
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
 MAINTAINER = Sean Levy <[hidden email]>
 
 # Dual licensed: MIT and GPLv2+
 PERMIT_PACKAGE_CDROM = Yes
 
-WANTLIB += c
+# uses pledge()
+WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
 
-# Test files aren't included in distfile.
-NO_TEST = Yes
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
+
+post-extract:
+ rm -rf ${WRKSRC}/submodules/MarkdownTest
+ cp -r ${WRKDIR}/MMD-Test-Suite-${TESTS_COMMIT} \
+ ${WRKSRC}/submodules/MarkdownTest
+
+pre-configure:
+ touch ${WRKBUILD}/README.html
 
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 15 Sep 2016 21:41:05 -0000
@@ -1,2 +1,4 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = xGdoX+aZ/y+8ND+LXK24XSgNCccYJV9S6qAW2NI/DKw=
+SHA256 (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = HMA4X/1sghwmXpcPgcxOwAnH7Lv7EuDhFce7WzPQmoM=
+SIZE (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = 185408
+SIZE (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = 136693
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 15 Sep 2016 21:41:05 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 15 Sep 2016 21:41:05 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Fri Aug  5 09:08:36 2016
++++ src/html.c Thu Sep 15 15:35:50 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -604,7 +608,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -658,7 +666,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -951,7 +963,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 15 Sep 2016 21:41:05 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.
+--- src/multimarkdown.c.orig Fri Aug  5 09:08:36 2016
++++ src/multimarkdown.c Thu Sep 15 17:28:27 2016
+@@ -58,6 +58,7 @@
+ */
+
+
++#include <errno.h>
+ #include <getopt.h>
+ #include <libgen.h>
+ #include "parser.h"
+@@ -262,6 +263,11 @@ int main(int argc, char **argv)
+ abort();
+ }
+ }
++
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr,"pledge: error #%d\n", errno);
++ exit(EXIT_FAILURE);
++ }
+
+ /* Compatibility mode emulates the behavior of Markdown.pl */
+ if (compatibility_flag) {
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 15 Sep 2016 21:41:05 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Fri Aug  5 09:08:36 2016
++++ src/parse_utilities.c Thu Sep 15 15:35:50 2016
+@@ -268,10 +268,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -909,4 +917,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> Michael McConville <[hidden email]> writes:
>>
>>> attila wrote:
>>>> Ping.
>>>>
>>>> Just tested that the diff works against recentish i386 snap (22 May).
>>>> Patch attached.
>>>
>>> I can't comment on all of the changes, but this builds and runs fine for
>>> me.
>>>
>>
>> Attached is an update that brings us from 4.7.1 to 5.4.0, released 8
>> Aug.  It shuffles the patches around because the source tree was
>> rearranged and adds support for tests.  Sadly, the tests don't all
>> pass.  I think I need a t-dep for something LaTeXish but I'm not sure
>> what is best, nor am I sure if that's the only reason for the
>> failures.  If anyone has a spare cycle or two to look at it I'd
>> appreciate it.  If not I'll get back to it by the end of the week.
>>
>> Pax, -A
>
> I finally got back to this.  It turns out there wasn't much standing
> in the way of the tests working other than me.  Attached is a patch
> that brings textproc/multimarkdown up to the latest release (5.4.0
> released 5 Aug).  Notable changes:
>
> * Switched to CMake;
> * Ditched the patches I tried and failed to upstream (strcat/sprintf);
> * Reworked two remaining patches (HAVE_SRAND_DETERMINISTIC) in the hope
>   I might get them upstream;
> * Added pledge;
> * make test now passes all tests.
>
> Tested on amd64.
>
> Comments, feedback most welcome.
>
> Pax, -A

Ping.
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> attila <[hidden email]> writes:
>>
>>> Michael McConville <[hidden email]> writes:
>>>
>>>> attila wrote:
>>>>> Ping.
>>>>>
>>>>> Just tested that the diff works against recentish i386 snap (22 May).
>>>>> Patch attached.
>>>>
>>>> I can't comment on all of the changes, but this builds and runs fine for
>>>> me.
>>>>
>>>
>>> Attached is an update that brings us from 4.7.1 to 5.4.0, released 8
>>> Aug.  It shuffles the patches around because the source tree was
>>> rearranged and adds support for tests.  Sadly, the tests don't all
>>> pass.  I think I need a t-dep for something LaTeXish but I'm not sure
>>> what is best, nor am I sure if that's the only reason for the
>>> failures.  If anyone has a spare cycle or two to look at it I'd
>>> appreciate it.  If not I'll get back to it by the end of the week.
>>>
>>> Pax, -A
>>
>> I finally got back to this.  It turns out there wasn't much standing
>> in the way of the tests working other than me.  Attached is a patch
>> that brings textproc/multimarkdown up to the latest release (5.4.0
>> released 5 Aug).  Notable changes:
>>
>> * Switched to CMake;
>> * Ditched the patches I tried and failed to upstream (strcat/sprintf);
>> * Reworked two remaining patches (HAVE_SRAND_DETERMINISTIC) in the hope
>>   I might get them upstream;
>> * Added pledge;
>> * make test now passes all tests.
>>
>> Tested on amd64.
>>
>> Comments, feedback most welcome.
>>
>> Pax, -A
>
> Ping.
I reinstated the strcat/sprintf-related patches but done slightly
better.  Tests pass on amd64.  Updated patch attached.

Feedback, comments most welcome.

Pax, -A
--
http://haqistan.net/~attila | [hidden email] | 0x62A729CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 1 Oct 2016 18:11:36 -0000
@@ -1,34 +1,45 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.4.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
-PKGNAME = multimarkdown-${V}
+PKGNAME = multimarkdown-${V:C/-/./}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
+TESTS_COMMIT = 8d5ad66e3bbaeb0de8646783bfe964261ddb39c7
+DIST_SUBDIR = multimarkdown
+MASTER_SITES_GITHUB = https://github.com/fletcher/MMD-Test-Suite/archive/
+DISTFILES = ${DISTNAME}${EXTRACT_SUFX} ${TESTS_COMMIT}${EXTRACT_SUFX}
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
 MAINTAINER = Sean Levy <[hidden email]>
 
 # Dual licensed: MIT and GPLv2+
 PERMIT_PACKAGE_CDROM = Yes
 
-WANTLIB += c
+# uses pledge()
+WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
 
-# Test files aren't included in distfile.
-NO_TEST = Yes
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
+
+post-extract:
+ rm -rf ${WRKSRC}/submodules/MarkdownTest
+ cp -r ${WRKDIR}/MMD-Test-Suite-${TESTS_COMMIT} \
+ ${WRKSRC}/submodules/MarkdownTest
+
+pre-configure:
+ touch ${WRKBUILD}/README.html
 
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 1 Oct 2016 18:11:36 -0000
@@ -1,2 +1,4 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = xGdoX+aZ/y+8ND+LXK24XSgNCccYJV9S6qAW2NI/DKw=
+SHA256 (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = HMA4X/1sghwmXpcPgcxOwAnH7Lv7EuDhFce7WzPQmoM=
+SIZE (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = 185408
+SIZE (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = 136693
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Fri Aug  5 09:08:36 2016
++++ src/html.c Thu Sep 15 15:35:50 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -604,7 +608,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -658,7 +666,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -951,7 +963,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,28 @@
+$OpenBSD$
+
+Switch from strcat(3) to safer idiom, ensure bogus input doesn't result
+in out of bounds pointer.
+--- src/latex.c.orig Sat Oct  1 11:12:24 2016
++++ src/latex.c Sat Oct  1 11:23:02 2016
+@@ -1219,16 +1219,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
++ size_t result_len;
+
+ result = strdup(original);
++ result_len = strlen(result);
+
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
+-
++ if ((result_len > 1) && strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
++
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.
+--- src/multimarkdown.c.orig Fri Aug  5 09:08:36 2016
++++ src/multimarkdown.c Thu Sep 15 17:28:27 2016
+@@ -58,6 +58,7 @@
+ */
+
+
++#include <errno.h>
+ #include <getopt.h>
+ #include <libgen.h>
+ #include "parser.h"
+@@ -262,6 +263,11 @@ int main(int argc, char **argv)
+ abort();
+ }
+ }
++
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr,"pledge: error #%d\n", errno);
++ exit(EXIT_FAILURE);
++ }
+
+ /* Compatibility mode emulates the behavior of Markdown.pl */
+ if (compatibility_flag) {
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Fri Aug  5 09:08:36 2016
++++ src/parse_utilities.c Thu Sep 15 15:35:50 2016
+@@ -268,10 +268,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -909,4 +917,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,20 @@
+$OpenBSD$
+
+Switch from sprintf(3) to safer idiom.  Handle errors as elsewhere in code.
+--- src/parser.leg.orig Fri Aug  5 09:08:36 2016
++++ src/parser.leg Sat Oct  1 14:05:54 2016
+@@ -637,8 +637,12 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto = NULL;
++ if (asprintf(&mailto, "mailto:%s", yytext) == -1) {
++ fprintf(stderr, "error copying mailto link: %s\n",
++ yytext);
++ exit(1);
++ }
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,43 @@
+$OpenBSD$
+
+Switch from strcat(3) to a safer idiom, make sure bogus dimension does
+not result in out of bounds pointer.
+--- src/writer.c.orig Sat Oct  1 11:18:59 2016
++++ src/writer.c Sat Oct  1 11:22:21 2016
+@@ -690,6 +690,7 @@ char * dimension_for_attribute(char *querystring, node
+     int i;
+     char *upper;
+     GString *result;
++    size_t dimension_len;
+
+     attribute = node_for_attribute(querystring, list);
+     if (attribute == NULL) return NULL;
+@@ -698,6 +699,7 @@ char * dimension_for_attribute(char *querystring, node
+ #endif
+
+     dimension = strdup(attribute->children->str);
++    dimension_len = strlen(dimension);
+     upper = strdup(attribute->children->str);
+
+     for(i = 0; dimension[ i ]; i++)
+@@ -709,15 +711,14 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension,"px");
++    if (ptr)
++        ptr[1] = 't';
+
+     result = g_string_new(dimension);
+    
+-    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
++    if ((strcmp(dimension,upper) == 0) && (dimension_len > 0) &&
++        (dimension[dimension_len-1] != '%')) {
+         /* no units */
+         g_string_append_printf(result, "pt");
+     }
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

attila

attila <[hidden email]> writes:

> attila <[hidden email]> writes:
>
>> attila <[hidden email]> writes:
>>
>>> attila <[hidden email]> writes:
>>>
>>>> Michael McConville <[hidden email]> writes:
>>>>
>>>>> attila wrote:
>>>>>> Ping.
>>>>>>
>>>>>> Just tested that the diff works against recentish i386 snap (22 May).
>>>>>> Patch attached.
>>>>>
>>>>> I can't comment on all of the changes, but this builds and runs fine for
>>>>> me.
>>>>>
>>>>
>>>> Attached is an update that brings us from 4.7.1 to 5.4.0, released 8
>>>> Aug.  It shuffles the patches around because the source tree was
>>>> rearranged and adds support for tests.  Sadly, the tests don't all
>>>> pass.  I think I need a t-dep for something LaTeXish but I'm not sure
>>>> what is best, nor am I sure if that's the only reason for the
>>>> failures.  If anyone has a spare cycle or two to look at it I'd
>>>> appreciate it.  If not I'll get back to it by the end of the week.
>>>>
>>>> Pax, -A
>>>
>>> I finally got back to this.  It turns out there wasn't much standing
>>> in the way of the tests working other than me.  Attached is a patch
>>> that brings textproc/multimarkdown up to the latest release (5.4.0
>>> released 5 Aug).  Notable changes:
>>>
>>> * Switched to CMake;
>>> * Ditched the patches I tried and failed to upstream (strcat/sprintf);
>>> * Reworked two remaining patches (HAVE_SRAND_DETERMINISTIC) in the hope
>>>   I might get them upstream;
>>> * Added pledge;
>>> * make test now passes all tests.
>>>
>>> Tested on amd64.
>>>
>>> Comments, feedback most welcome.
>>>
>>> Pax, -A
>>
>> Ping.
>
> I reinstated the strcat/sprintf-related patches but done slightly
> better.  Tests pass on amd64.  Updated patch attached.
>
> Feedback, comments most welcome.
>
> Pax, -A
Finally getting back to this.  Version 5.4.0 is still the latest
stable release (6.0.x exists but is considered beta).  Just tried my
update on the most recent snap and it passess tests and seems to work
for me.  Patch attached.

Feedback most welcome.

Pax, -A
--
https://haqistan.net/~attila | attila@{stalphonsos.com,haqistan.net}
pgp: 0x62A729CF | C2CE 2487 03AC 4C2F 101D  09C1 4068 D5D5 62A7 29CF

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- Makefile 5 Apr 2015 13:31:15 -0000 1.2
+++ Makefile 1 Oct 2016 18:11:36 -0000
@@ -1,34 +1,45 @@
 # $OpenBSD: Makefile,v 1.2 2015/04/05 13:31:15 sthen Exp $
 
-V = 4.7.1
+V = 5.4.0
 COMMENT = marked-up plain text to formatted document converter
 DISTNAME = ${GH_PROJECT}-${V}
-PKGNAME = multimarkdown-${V}
+PKGNAME = multimarkdown-${V:C/-/./}
 CATEGORIES = textproc
 
 GH_ACCOUNT = fletcher
-GH_PROJECT = MultiMarkdown-4
+GH_PROJECT = MultiMarkdown-5
 GH_TAGNAME = ${V}
 
+TESTS_COMMIT = 8d5ad66e3bbaeb0de8646783bfe964261ddb39c7
+DIST_SUBDIR = multimarkdown
+MASTER_SITES_GITHUB = https://github.com/fletcher/MMD-Test-Suite/archive/
+DISTFILES = ${DISTNAME}${EXTRACT_SUFX} ${TESTS_COMMIT}${EXTRACT_SUFX}
 HOMEPAGE = http://fletcherpenney.net/multimarkdown/
 MAINTAINER = Sean Levy <[hidden email]>
 
 # Dual licensed: MIT and GPLv2+
 PERMIT_PACKAGE_CDROM = Yes
 
-WANTLIB += c
+# uses pledge()
+WANTLIB += c
 
 BUILD_DEPENDS = devel/greg
 
-USE_GMAKE = Yes
-ALL_TARGET = ALL
-MAKE_FLAGS = CFLAGS="${CFLAGS} -include GLibFacade.h -DHAVE_ARC4RANDOM" \
- GREG=${LOCALBASE}/bin/greg
+MODULES = devel/cmake
 
-# Test files aren't included in distfile.
-NO_TEST = Yes
+CFLAGS += -DHAVE_SRAND_DETERMINISTIC
+
+CONFIGURE_ARGS += -DGREG=${LOCALBASE}/bin/greg
+
+post-extract:
+ rm -rf ${WRKSRC}/submodules/MarkdownTest
+ cp -r ${WRKDIR}/MMD-Test-Suite-${TESTS_COMMIT} \
+ ${WRKSRC}/submodules/MarkdownTest
+
+pre-configure:
+ touch ${WRKBUILD}/README.html
 
 do-install:
- ${INSTALL_PROGRAM} ${WRKSRC}/multimarkdown ${PREFIX}/bin/
+ ${INSTALL_PROGRAM} ${WRKBUILD}/multimarkdown ${PREFIX}/bin/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/multimarkdown/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ distinfo 1 Oct 2016 18:11:36 -0000
@@ -1,2 +1,4 @@
-SHA256 (MultiMarkdown-4-4.7.1.tar.gz) = gy5dzm+hv/TWfmSsLMJPCSCujZEoDlPqh5I3odQ/SGU=
-SIZE (MultiMarkdown-4-4.7.1.tar.gz) = 120896
+SHA256 (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = xGdoX+aZ/y+8ND+LXK24XSgNCccYJV9S6qAW2NI/DKw=
+SHA256 (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = HMA4X/1sghwmXpcPgcxOwAnH7Lv7EuDhFce7WzPQmoM=
+SIZE (multimarkdown/8d5ad66e3bbaeb0de8646783bfe964261ddb39c7.tar.gz) = 185408
+SIZE (multimarkdown/MultiMarkdown-5-5.4.0.tar.gz) = 136693
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Use installed greg
+--- CMakeLists.txt.orig Mon Feb 22 20:05:02 2016
++++ CMakeLists.txt Tue Mar 22 12:45:41 2016
+@@ -149,7 +149,7 @@ endif ()
+ # Need to build parser.c via greg
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/parser.c
+- COMMAND ${PROJECT_SOURCE_DIR}/submodules/greg/greg -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
++ COMMAND ${GREG} -o ${CMAKE_CURRENT_BINARY_DIR}/parser.c ${PROJECT_SOURCE_DIR}/src/parser.leg
+ )
+
+ # src_files are the primary files, and will be included in doxygen documentation
Index: patches/patch-Makefile
===================================================================
RCS file: patches/patch-Makefile
diff -N patches/patch-Makefile
--- patches/patch-Makefile 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-$OpenBSD: patch-Makefile,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Make it possible to pass GREG=/usr/local/bin/greg in on the
-command line and avoid git submodules.
-
---- Makefile.orig Mon Mar 23 18:21:56 2015
-+++ Makefile Mon Mar 23 18:32:22 2015
-@@ -32,18 +32,25 @@ ifeq ($(MAKECMDGOALS),static)
- LDFLAGS += -static -static-libgcc
- endif
-
--GREG= greg/greg
-+# OUR_GREG: the version of greg in a submodule
-+# GREG: the path to greg we want to use for parser.leg
-+#
-+# This way we can pass GREG=/usr/local/bin/greg in on
-+# the command line if we have greg installed already.
-
-+OUR_GREG=greg/greg
-+GREG?=$(OUR_GREG)
-+
- ALL : $(PROGRAM) enumMap.txt
- static : $(PROGRAM) enumMap.txt
-
- %.o : %.c parser.h
- $(CC) -c $(CFLAGS) -o $@ $<
-
--parser.c : parser.leg greg/greg parser.h
-- greg/greg -o parser.c parser.leg
-+parser.c : parser.leg $(GREG) parser.h
-+ $(GREG) -o parser.c parser.leg
-
--$(GREG): greg
-+$(OUR_GREG): greg
- $(MAKE) -C greg
-
- $(PROGRAM) : $(OBJS)
Index: patches/patch-html_c
===================================================================
RCS file: patches/patch-html_c
diff -N patches/patch-html_c
--- patches/patch-html_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-$OpenBSD: patch-html_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch to using arc4random(3) everywhere, since they don't really want
-repeatability (as evidenced by the arguments they pass to srand(3)).
-
---- html.c.orig Mon Mar  9 18:52:39 2015
-+++ html.c Sat Mar 21 15:44:10 2015
-@@ -112,8 +112,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- scratch->footnote_para_counter --;
- if (scratch->footnote_para_counter == 0) {
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + scratch->footnote_to_print);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = scratch->footnote_to_print;
- }
-@@ -574,8 +578,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- temp_node = node_for_count(scratch->used_notes, lev);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -628,8 +636,12 @@ void print_html_node(GString *out, node *n, scratch_pa
- fprintf(stderr, "matching cite found - %d\n",lev);
- #endif
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + lev);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = lev;
- }
-@@ -901,8 +913,12 @@ void print_html_endnotes(GString *out, scratch_pad *sc
- pad(out, 1, scratch);
-
- if (scratch->extensions & EXT_RANDOM_FOOT) {
-+#ifdef HAVE_ARC4RANDOM
-+ random = arc4random_uniform(99999) + 1;
-+#else
- srand(scratch->random_seed_base + counter);
- random = rand() % 99999 + 1;
-+#endif
- } else {
- random = counter;
- }
Index: patches/patch-latex_c
===================================================================
RCS file: patches/patch-latex_c
diff -N patches/patch-latex_c
--- patches/patch-latex_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-$OpenBSD: patch-latex_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat(3) to a safer idiom.
-
---- latex.c.orig Mon Mar  9 18:52:39 2015
-+++ latex.c Sat Mar 21 15:44:10 2015
-@@ -1202,16 +1202,16 @@ void print_latex_url(GString *out, char *str, scratch_
- char * correct_dimension_units(char *original) {
- char *result;
- int i;
--
-+ size_t result_len;
-+
- result = strdup(original);
--
-+ result_len = strlen(result);
-+
- for (i = 0; result[i]; i++)
- result[i] = tolower(result[i]);
-
-- if (strstr(&result[strlen(result)-2],"px")) {
-- result[strlen(result)-2] = '\0';
-- strcat(result, "pt");
-- }
-+ if (strstr(&result[result_len-2],"px"))
-+ result[result_len-1] = 't';
-
- return result;
- }
Index: patches/patch-parse_utilities_c
===================================================================
RCS file: patches/patch-parse_utilities_c
diff -N patches/patch-parse_utilities_c
--- patches/patch-parse_utilities_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-parse_utilities_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-ifdef out pragmas that don't work under OpenBSD.  Use arc4random(3).
-
---- parse_utilities.c.orig Mon Sep 22 12:57:41 2014
-+++ parse_utilities.c Wed Jan  7 16:02:19 2015
-@@ -22,7 +22,9 @@
- #include "parser.h"
- #include <libgen.h>
-
-+#ifndef __OpenBSD__
- #pragma mark - Parse Tree
-+#endif /* __OpenBSD__ */
-
- /* Create a new node in the parse tree */
- node * mk_node(int key) {
-@@ -219,7 +221,9 @@ void append_list(node *new, node *list) {
- }
- }
-
-+#ifndef __OpenBSD__
- #pragma mark - Parser Data
-+#endif /* __OpenBSD__ */
-
- /* Create parser data - this is where you stash stuff to communicate
- into and out of the parser */
-@@ -250,7 +254,9 @@ void free_parser_data(parser_data *data) {
- }
-
- /* mk_scratch_pad -- store stuff here while exporting the result tree */
-+#ifndef HAVE_ARC4RANDOM
- void ran_start(long seed);
-+#endif
- scratch_pad * mk_scratch_pad(unsigned long extensions) {
- scratch_pad *result = (scratch_pad *)malloc(sizeof(scratch_pad));
- result->extensions = extensions;
-@@ -277,6 +283,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->table_alignment = NULL;
- result->table_column = 0;
-
-+#ifndef HAVE_ARC4RANDOM
- if (extensions & EXT_RANDOM_FOOT) {
-    srand((int)time(NULL));
- result->random_seed_base = rand() % 32000;
-@@ -285,6 +292,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
- result->random_seed_base = 0;
- }
- ran_start(310952L);
-+#endif /* !HAVE_ARC4RANDOM */
-
- result->lyx_para_type = PARA;             /* CRC - Simple paragraph */
- result->lyx_level = 0;                    /* CRC - out outside level */
Index: patches/patch-parser_leg
===================================================================
RCS file: patches/patch-parser_leg
diff -N patches/patch-parser_leg
--- patches/patch-parser_leg 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-$OpenBSD: patch-parser_leg,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from sprintf(3) to snprintf(3)
-
---- parser.leg.orig Mon Mar  9 18:52:39 2015
-+++ parser.leg Sat Mar 21 15:44:10 2015
-@@ -562,8 +562,10 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
-
- AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
- {
-- char *mailto = malloc(strlen(yytext) + 8);
-- sprintf(mailto, "mailto:%s", yytext);
-+ size_t mailto_len = strlen(yytext) + 8;
-+ char *mailto = malloc(mailto_len);
-+ assert(mailto);
-+ assert(snprintf(mailto,mailto_len,"mailto:%s",yytext) < mailto_len);
- $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
- free(mailto);
- }
Index: patches/patch-src_html_c
===================================================================
RCS file: patches/patch-src_html_c
diff -N patches/patch-src_html_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_html_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+
+Use srand_deterministic(3) if available.
+--- src/html.c.orig Fri Aug  5 09:08:36 2016
++++ src/html.c Thu Sep 15 15:35:50 2016
+@@ -115,7 +115,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ scratch->footnote_para_counter --;
+ if (scratch->footnote_para_counter == 0) {
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + scratch->footnote_to_print);
++#else
+ srand(scratch->random_seed_base + scratch->footnote_to_print);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = scratch->footnote_to_print;
+@@ -604,7 +608,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ temp_node = node_for_count(scratch->used_notes, lev);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -658,7 +666,11 @@ void print_html_node(GString *out, node *n, scratch_pa
+ fprintf(stderr, "matching cite found - %d\n",lev);
+ #endif
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + lev);
++#else
+ srand(scratch->random_seed_base + lev);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = lev;
+@@ -951,7 +963,11 @@ void print_html_endnotes(GString *out, scratch_pad *sc
+ pad(out, 1, scratch);
+
+ if (scratch->extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(scratch->random_seed_base + counter);
++#else
+ srand(scratch->random_seed_base + counter);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ random = rand() % 99999 + 1;
+ } else {
+ random = counter;
Index: patches/patch-src_latex_c
===================================================================
RCS file: patches/patch-src_latex_c
diff -N patches/patch-src_latex_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_latex_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,28 @@
+$OpenBSD$
+
+Switch from strcat(3) to safer idiom, ensure bogus input doesn't result
+in out of bounds pointer.
+--- src/latex.c.orig Sat Oct  1 11:12:24 2016
++++ src/latex.c Sat Oct  1 11:23:02 2016
+@@ -1219,16 +1219,16 @@ void print_latex_url(GString *out, char *str, scratch_
+ char * correct_dimension_units(char *original) {
+ char *result;
+ int i;
++ size_t result_len;
+
+ result = strdup(original);
++ result_len = strlen(result);
+
+ for (i = 0; result[i]; i++)
+ result[i] = tolower(result[i]);
+
+- if (strstr(&result[strlen(result)-2],"px")) {
+- result[strlen(result)-2] = '\0';
+- strcat(result, "pt");
+- }
+-
++ if ((result_len > 1) && strstr(&result[result_len-2],"px"))
++ result[result_len-1] = 't';
++
+ return result;
+ }
Index: patches/patch-src_multimarkdown_c
===================================================================
RCS file: patches/patch-src_multimarkdown_c
diff -N patches/patch-src_multimarkdown_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_multimarkdown_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+Use pledge(2) on OpenBSD.
+--- src/multimarkdown.c.orig Fri Aug  5 09:08:36 2016
++++ src/multimarkdown.c Thu Sep 15 17:28:27 2016
+@@ -58,6 +58,7 @@
+ */
+
+
++#include <errno.h>
+ #include <getopt.h>
+ #include <libgen.h>
+ #include "parser.h"
+@@ -262,6 +263,11 @@ int main(int argc, char **argv)
+ abort();
+ }
+ }
++
++ if (pledge("stdio rpath wpath cpath", NULL) == -1) {
++ fprintf(stderr,"pledge: error #%d\n", errno);
++ exit(EXIT_FAILURE);
++ }
+
+ /* Compatibility mode emulates the behavior of Markdown.pl */
+ if (compatibility_flag) {
Index: patches/patch-src_parse_utilities_c
===================================================================
RCS file: patches/patch-src_parse_utilities_c
diff -N patches/patch-src_parse_utilities_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parse_utilities_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,31 @@
+$OpenBSD$
+
+Use srand_deterministic(3) on OpenBSD
+--- src/parse_utilities.c.orig Fri Aug  5 09:08:36 2016
++++ src/parse_utilities.c Thu Sep 15 15:35:50 2016
+@@ -268,10 +268,18 @@ scratch_pad * mk_scratch_pad(unsigned long extensions)
+ result->inside_footnote = 0;
+
+ if (extensions & EXT_RANDOM_FOOT) {
++#ifdef HAVE_SRAND_DETERMINISTIC
++    srand_deterministic((int)time(NULL));
++#else
+    srand((int)time(NULL));
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = rand() % 32000;
+ } else {
++#ifdef HAVE_SRAND_DETERMINISTIC
++ srand_deterministic(1);
++#else
+ srand(1);
++#endif /* HAVE_SRAND_DETERMINISTIC */
+ result->random_seed_base = 0;
+ }
+ ran_start(310952L);
+@@ -909,4 +917,4 @@ char * my_strndup(const char * source, size_t n) {
+ result[len] = '\0';
+
+ return result;
+-}
+\ No newline at end of file
++}
Index: patches/patch-src_parser_leg
===================================================================
RCS file: patches/patch-src_parser_leg
diff -N patches/patch-src_parser_leg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_parser_leg 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,20 @@
+$OpenBSD$
+
+Switch from sprintf(3) to safer idiom.  Handle errors as elsewhere in code.
+--- src/parser.leg.orig Fri Aug  5 09:08:36 2016
++++ src/parser.leg Sat Oct  1 14:05:54 2016
+@@ -637,8 +637,12 @@ AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>'
+
+ AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
+ {
+- char *mailto = malloc(strlen(yytext) + 8);
+- sprintf(mailto, "mailto:%s", yytext);
++ char *mailto = NULL;
++ if (asprintf(&mailto, "mailto:%s", yytext) == -1) {
++ fprintf(stderr, "error copying mailto link: %s\n",
++ yytext);
++ exit(1);
++ }
+ $$ = mk_link(str(yytext), NULL, mailto, NULL, NULL);
+ free(mailto);
+ }
Index: patches/patch-src_writer_c
===================================================================
RCS file: patches/patch-src_writer_c
diff -N patches/patch-src_writer_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_writer_c 1 Oct 2016 18:11:36 -0000
@@ -0,0 +1,43 @@
+$OpenBSD$
+
+Switch from strcat(3) to a safer idiom, make sure bogus dimension does
+not result in out of bounds pointer.
+--- src/writer.c.orig Sat Oct  1 11:18:59 2016
++++ src/writer.c Sat Oct  1 11:22:21 2016
+@@ -690,6 +690,7 @@ char * dimension_for_attribute(char *querystring, node
+     int i;
+     char *upper;
+     GString *result;
++    size_t dimension_len;
+
+     attribute = node_for_attribute(querystring, list);
+     if (attribute == NULL) return NULL;
+@@ -698,6 +699,7 @@ char * dimension_for_attribute(char *querystring, node
+ #endif
+
+     dimension = strdup(attribute->children->str);
++    dimension_len = strlen(dimension);
+     upper = strdup(attribute->children->str);
+
+     for(i = 0; dimension[ i ]; i++)
+@@ -709,15 +711,14 @@ char * dimension_for_attribute(char *querystring, node
+ fprintf(stderr, "b\n");
+ #endif
+
+-    if (strstr(dimension, "px")) {
+-        ptr = strstr(dimension,"px");
+-        ptr[0] = '\0';
+-        strcat(ptr,"pt");
+-    }
++    ptr = strstr(dimension,"px");
++    if (ptr)
++        ptr[1] = 't';
+
+     result = g_string_new(dimension);
+    
+-    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
++    if ((strcmp(dimension,upper) == 0) && (dimension_len > 0) &&
++        (dimension[dimension_len-1] != '%')) {
+         /* no units */
+         g_string_append_printf(result, "pt");
+     }
Index: patches/patch-writer_c
===================================================================
RCS file: patches/patch-writer_c
diff -N patches/patch-writer_c
--- patches/patch-writer_c 24 Mar 2015 19:16:13 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-$OpenBSD: patch-writer_c,v 1.1.1.1 2015/03/24 19:16:13 okan Exp $
-
-Switch from strcat to a safer idiom.
-
---- writer.c.orig Mon Mar  9 18:52:39 2015
-+++ writer.c Sat Mar 21 15:44:10 2015
-@@ -648,6 +648,7 @@ char * dimension_for_attribute(char *querystring, node
-     int i;
-     char *upper;
-     GString *result;
-+    size_t dimension_len;
-
-     attribute = node_for_attribute(querystring, list);
-     if (attribute == NULL) return NULL;
-@@ -655,6 +656,7 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "a\n");
- #endif
-
-+    dimension_len = strlen(attribute->children->str);
-     dimension = strdup(attribute->children->str);
-     upper = strdup(attribute->children->str);
-
-@@ -667,15 +669,13 @@ char * dimension_for_attribute(char *querystring, node
- fprintf(stderr, "b\n");
- #endif
-
--    if (strstr(dimension, "px")) {
--        ptr = strstr(dimension,"px");
--        ptr[0] = '\0';
--        strcat(ptr,"pt");
--    }
-+    ptr = strstr(dimension, "px");
-+    if (ptr)
-+        ptr[1] = 't';
-
-     result = g_string_new(dimension);
-    
--    if ((strcmp(dimension,upper) == 0) && (dimension[strlen(dimension) -1] != '%')) {
-+    if ((strcmp(dimension,upper) == 0) && (dimension[dimension_len-1] != '%')) {
-         /* no units */
-         g_string_append_printf(result, "pt");
-     }
Reply | Threaded
Open this post in threaded view
|

Re: [update] textproc/multimarkdown

Micah Muer-2


On Mon, Mar 27, 2017, at 11:27, attila wrote:

>
> attila <[hidden email]> writes:
>
> > attila <[hidden email]> writes:
> >
> >> attila <[hidden email]> writes:
> >>
> >>> attila <[hidden email]> writes:
> >>>
> >>>> Michael McConville <[hidden email]> writes:
> >>>>
> >>>>> attila wrote:
> >>>>>> Ping.
> >>>>>>
> >>>>>> Just tested that the diff works against recentish i386 snap (22 May).
> >>>>>> Patch attached.
> >>>>>
> >>>>> I can't comment on all of the changes, but this builds and runs fine for
> >>>>> me.
> >>>>>
> >>>>
> >>>> Attached is an update that brings us from 4.7.1 to 5.4.0, released 8
> >>>> Aug.  It shuffles the patches around because the source tree was
> >>>> rearranged and adds support for tests.  Sadly, the tests don't all
> >>>> pass.  I think I need a t-dep for something LaTeXish but I'm not sure
> >>>> what is best, nor am I sure if that's the only reason for the
> >>>> failures.  If anyone has a spare cycle or two to look at it I'd
> >>>> appreciate it.  If not I'll get back to it by the end of the week.
> >>>>
> >>>> Pax, -A
> >>>
> >>> I finally got back to this.  It turns out there wasn't much standing
> >>> in the way of the tests working other than me.  Attached is a patch
> >>> that brings textproc/multimarkdown up to the latest release (5.4.0
> >>> released 5 Aug).  Notable changes:
> >>>
> >>> * Switched to CMake;
> >>> * Ditched the patches I tried and failed to upstream (strcat/sprintf);
> >>> * Reworked two remaining patches (HAVE_SRAND_DETERMINISTIC) in the hope
> >>>   I might get them upstream;
> >>> * Added pledge;
> >>> * make test now passes all tests.
> >>>
> >>> Tested on amd64.
> >>>
> >>> Comments, feedback most welcome.
> >>>
> >>> Pax, -A
> >>
> >> Ping.
> >
> > I reinstated the strcat/sprintf-related patches but done slightly
> > better.  Tests pass on amd64.  Updated patch attached.
> >
> > Feedback, comments most welcome.
> >
> > Pax, -A
>
> Finally getting back to this.  Version 5.4.0 is still the latest
> stable release (6.0.x exists but is considered beta).  Just tried my
> update on the most recent snap and it passess tests and seems to work
> for me.  Patch attached.
>
> Feedback most welcome.

For what it's worth I've been using this diff (on amd64 -current ) for
almost six months. No issues at all, and I am using multimarkdown almost
every day.

Thanks for your work on the diff!

>
> Pax, -A
> --
> https://haqistan.net/~attila | attila@{stalphonsos.com,haqistan.net}
> pgp: 0x62A729CF | C2CE 2487 03AC 4C2F 101D  09C1 4068 D5D5 62A7 29CF
> Email had 1 attachment:
> + mmd-5.4.0-bbis.patch
>   21k (text/x-patch)

12