discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml [CVS_2015_11_07] Code needs HAVE_ERR guards
@ 2015-11-07  3:00 Peter Bray
  2015-11-07  4:14 ` Peter Bray
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Bray @ 2015-11-07  3:00 UTC (permalink / raw)
  To: discuss

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Greetings,

Ingo has posted a patch to regarding

     mandoc whatis(1): autodetect RE syntax for word boundaries

So I thought I would try compiling mdocml_cvs on Solaris 10 and 11 again.

The "configure" script checks for the presence of "err.h", setting
HAVE_ERR to 0 or 1 based on the check result.

Unlike the HAVE_FTS check the, code that uses '#include <err.h>' does
not wrap this preprocessor directive in a guard.

Two possible simple solutions exist (based on what I have seen so far).

1. Wrap the include directive in a simple '#if HAVE_ERR' and '#endif'.
    Patch included.

2. Take the HAVE_FTS approach and move the declarations from the generated
    config.h to compat_err.h and like fts.h, use a conditional of the form:

#if HAVE_ERR
#  include <err.h>
#else
#  include "compat_err.h"
#fi

I'll leave it to the developers and maintainers to choose the
appropriate solution for their code base.

Regards,

Peter Bray
Sydney, Australia

PS: Discovered on Solaris 10 which does not have <err.h>

[-- Attachment #2: mdocml_cvs_2015_11_07-HAVE_ERR-guards.diff --]
[-- Type: text/plain, Size: 4425 bytes --]

diff -r -U 2 mdocml-cvs_2015_11_07.orig/compat_err.c mdocml-cvs_2015_11_07/compat_err.c
--- mdocml-cvs_2015_11_07.orig/compat_err.c	2015-11-06 16:30:33.000000000 +0000
+++ mdocml-cvs_2015_11_07/compat_err.c	2015-11-07 02:40:13.751774337 +0000
@@ -37,5 +37,7 @@
  */
 
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <errno.h>
 #include <stdarg.h>
Only in mdocml-cvs_2015_11_07: compat_err.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/compat_stringlist.c mdocml-cvs_2015_11_07/compat_stringlist.c
--- mdocml-cvs_2015_11_07.orig/compat_stringlist.c	2015-05-21 00:13:43.000000000 +0000
+++ mdocml-cvs_2015_11_07/compat_stringlist.c	2015-11-07 02:40:13.757923786 +0000
@@ -34,5 +34,7 @@
  */
 
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
Only in mdocml-cvs_2015_11_07: compat_stringlist.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/main.c mdocml-cvs_2015_11_07/main.c
--- mdocml-cvs_2015_11_07.orig/main.c	2015-11-07 00:47:44.000000000 +0000
+++ mdocml-cvs_2015_11_07/main.c	2015-11-07 02:40:13.764627128 +0000
@@ -25,5 +25,7 @@
 #include <assert.h>
 #include <ctype.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <fcntl.h>
 #include <glob.h>
Only in mdocml-cvs_2015_11_07: main.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/mandoc_aux.c mdocml-cvs_2015_11_07/mandoc_aux.c
--- mdocml-cvs_2015_11_07.orig/mandoc_aux.c	2015-11-07 00:47:44.000000000 +0000
+++ mdocml-cvs_2015_11_07/mandoc_aux.c	2015-11-07 02:40:13.770768706 +0000
@@ -20,5 +20,7 @@
 #include <sys/types.h>
 
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <stdarg.h>
 #include <stdlib.h>
Only in mdocml-cvs_2015_11_07: mandoc_aux.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/mandocdb.c mdocml-cvs_2015_11_07/mandocdb.c
--- mdocml-cvs_2015_11_07.orig/mandocdb.c	2015-11-07 00:47:44.000000000 +0000
+++ mdocml-cvs_2015_11_07/mandocdb.c	2015-11-07 02:40:13.778167590 +0000
@@ -24,5 +24,7 @@
 #include <assert.h>
 #include <ctype.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
Only in mdocml-cvs_2015_11_07: mandocdb.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/manpath.c mdocml-cvs_2015_11_07/manpath.c
--- mdocml-cvs_2015_11_07.orig/manpath.c	2015-11-07 00:47:44.000000000 +0000
+++ mdocml-cvs_2015_11_07/manpath.c	2015-11-07 02:40:13.784549032 +0000
@@ -22,5 +22,7 @@
 
 #include <ctype.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <limits.h>
 #include <stdio.h>
Only in mdocml-cvs_2015_11_07: manpath.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/mansearch.c mdocml-cvs_2015_11_07/mansearch.c
--- mdocml-cvs_2015_11_07.orig/mansearch.c	2015-11-07 00:47:44.000000000 +0000
+++ mdocml-cvs_2015_11_07/mansearch.c	2015-11-07 02:40:13.791014961 +0000
@@ -22,5 +22,7 @@
 
 #include <assert.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
Only in mdocml-cvs_2015_11_07: mansearch.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/read.c mdocml-cvs_2015_11_07/read.c
--- mdocml-cvs_2015_11_07.orig/read.c	2015-11-07 00:47:45.000000000 +0000
+++ mdocml-cvs_2015_11_07/read.c	2015-11-07 02:40:13.797540657 +0000
@@ -27,5 +27,7 @@
 #include <assert.h>
 #include <ctype.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
Only in mdocml-cvs_2015_11_07: read.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/soelim.c mdocml-cvs_2015_11_07/soelim.c
--- mdocml-cvs_2015_11_07.orig/soelim.c	2015-05-21 00:18:52.000000000 +0000
+++ mdocml-cvs_2015_11_07/soelim.c	2015-11-07 02:40:13.803657540 +0000
@@ -30,5 +30,7 @@
 
 #include <ctype.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <limits.h>
 #include <stdio.h>
Only in mdocml-cvs_2015_11_07: soelim.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/term_ps.c mdocml-cvs_2015_11_07/term_ps.c
--- mdocml-cvs_2015_11_07.orig/term_ps.c	2015-11-07 00:47:45.000000000 +0000
+++ mdocml-cvs_2015_11_07/term_ps.c	2015-11-07 02:40:13.810363973 +0000
@@ -21,5 +21,7 @@
 
 #include <assert.h>
+#if HAVE_ERR
 #include <err.h>
+#endif
 #include <stdarg.h>
 #include <stdint.h>
Only in mdocml-cvs_2015_11_07: term_ps.c.orig
diff -r -U 2 mdocml-cvs_2015_11_07.orig/test-err.c mdocml-cvs_2015_11_07/test-err.c
--- mdocml-cvs_2015_11_07.orig/test-err.c	2015-10-11 21:12:55.000000000 +0000
+++ mdocml-cvs_2015_11_07/test-err.c	2015-11-07 02:40:13.816369014 +0000
@@ -16,5 +16,7 @@
  */
 
+#if HAVE_ERR
 #include <err.h>
+#endif
 
 int
Only in mdocml-cvs_2015_11_07: test-err.c.orig

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mdocml [CVS_2015_11_07] Code needs HAVE_ERR guards
  2015-11-07  3:00 mdocml [CVS_2015_11_07] Code needs HAVE_ERR guards Peter Bray
@ 2015-11-07  4:14 ` Peter Bray
  2015-11-07 14:26   ` Ingo Schwarze
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Bray @ 2015-11-07  4:14 UTC (permalink / raw)
  To: discuss

All,

Sorry for following up to my own post, but the patch provided included a 
redundant automated edit (I used perl(1) to edit the code for the patch).

Regardless of the solution chosen, 'compat_err.c' should not be 
including <err.h> as we already know we don't have it, because of the 
larger cpp(1) guards (#if HAVE_ERR) around the code.

If using solution 1, delete the '#include <err.h>'
If using solution 2, change the '#include <err.h>' to '#include 
"compat_err.h"'

Regards,

Peter


On  7/11/15 02:00 PM, Peter Bray wrote:
> Greetings,
>
> Ingo has posted a patch to regarding
>
>      mandoc whatis(1): autodetect RE syntax for word boundaries
>
> So I thought I would try compiling mdocml_cvs on Solaris 10 and 11 again.
>
> The "configure" script checks for the presence of "err.h", setting
> HAVE_ERR to 0 or 1 based on the check result.
>
> Unlike the HAVE_FTS check the, code that uses '#include <err.h>' does
> not wrap this preprocessor directive in a guard.
>
> Two possible simple solutions exist (based on what I have seen so far).
>
> 1. Wrap the include directive in a simple '#if HAVE_ERR' and '#endif'.
>     Patch included.
>
> 2. Take the HAVE_FTS approach and move the declarations from the generated
>     config.h to compat_err.h and like fts.h, use a conditional of the form:
>
> #if HAVE_ERR
> #  include <err.h>
> #else
> #  include "compat_err.h"
> #fi
>
> I'll leave it to the developers and maintainers to choose the
> appropriate solution for their code base.
>
> Regards,
>
> Peter Bray
> Sydney, Australia
>
> PS: Discovered on Solaris 10 which does not have <err.h>

--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mdocml [CVS_2015_11_07] Code needs HAVE_ERR guards
  2015-11-07  4:14 ` Peter Bray
@ 2015-11-07 14:26   ` Ingo Schwarze
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Schwarze @ 2015-11-07 14:26 UTC (permalink / raw)
  To: Peter Bray; +Cc: discuss

Hi Peter,

Peter Bray wrote on Sat, Nov 07, 2015 at 03:14:26PM +1100:

> Regardless of the solution chosen, 'compat_err.c' should not be including
> <err.h> as we already know we don't have it, because of the larger cpp(1)
> guards (#if HAVE_ERR) around the code.

Besides, test-err.c should always try to #include <err.h>,
no #if there.

I committed your patch (solution 1).

Having "compat_*.h" only seems useful for cases where the file
contains substantial amounts of code, more than one would like
to put into config.h.

Thanks,
  Ingo
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-07 14:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-07  3:00 mdocml [CVS_2015_11_07] Code needs HAVE_ERR guards Peter Bray
2015-11-07  4:14 ` Peter Bray
2015-11-07 14:26   ` Ingo Schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).