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

> Stuart Henderson <[email protected]> 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 | [email protected] | 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 via email to