discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Kazuo Kuroi <kazuo@irixnet.org>
Cc: discuss@mandoc.bsd.lv
Subject: Re: Patching Mandoc for IRIX
Date: Mon, 22 Jun 2020 23:44:06 +0200	[thread overview]
Message-ID: <20200622214406.GD93760@athene.usta.de> (raw)
In-Reply-To: <aa6e83e2-fe72-d7c2-2f66-de849ea9df63@irixnet.org>

Hello,

sorry for taking so long to respond, i was somewhat distracted by other
matters and now found your message while systematically looking for
unanswered messages regarding mandoc.


Kazuo Kuroi wrote on Tue, Jun 02, 2020 at 07:29:52PM -0400:

> I have patched mandoc to work with IRIX, but I have a feeling that the 
> fixes made will require some changes. Let me first explain my goals here:
> 
> I am patching mandoc to work with MIPSPro, the native compiler of IRIX, 

That sounds good and interesting.  I like it when people try to make
software work with native compilers that is intended to be portable,
rather than following a mindless reflex like "oh let's just require
gcc or clang to compile this".

> so I'll have to explain the changes I made to get it to build:
> 
> http://gitea.irixce.org/Raion/Xenopatches/raw/branch/master/mandoc/mandoc.patch 
> 
> Here's the patch file.
> 
> First change is because it doesn't reliably detect the c99 driver, and 
> as the code uses non ANSI-related things, it needs to detect c99. This 
> can probably be disregarded,

Possibly.  I tried to include code in ./configure in the past to
automatically detect the system compiler, but that attempt caused
more grief than benefit.  Few platforms needed it, and more ended
up having trouble with the attempted test.

So for the next release, i decided to simplify things by just
statically setting CC=cc in ./configure and inviting users to
set CC in configure.local to whatever is appropriate on their
platform - but of course only if "cc" is not.

Arguably, given that POSIX defines c99 but not cc, it might be better
to make CC=c99 the default.  Probably, the only reason that i didn't
is somewhat weak:  My main development platform, OpenBSD, provides
a cc(1) command but does not provide a c99(1) command.  Maybe it
should, but oh well.

For now, i suggest you keep CC=c99 in the configure.local file for IRIX.

> as can the CFLAGS reference.

I certainly won't put -O3 into CFLAGS by default, or any other
optimization flag for that matter.  I think operating systems should
have defaults that are appropriate for compiling general purpose
application software that has no special needs, and i consider it
annoying when upstream maintainers tweak compiler flags like that.

However, if there is some compelling reason why IRIX needs -O3,
then you can put that into the configure.local file for IRIX, though
i'm a bit at a loss trying to guess why that could possibly be
needed.

If IRIX needs -mips3, that definitely needs to go into configure.local.
I have no idea right now how i could possibly test for that.

> Next one is in mandoc.h, and it's because MIPSPro doesn't support the 
> __attribute__ block. This could be fixed with a guard for non-GCC 
> compilers, like this:
> #ifdef __GNUC__
> __attribute__((__format__ (__printf__, 4, 5)));
> #endif

Actually, i was already doing that, ./configure wrote something
like that into config.h.  However, some of the *.c files used private
headers using __attribute__ without including config.h first.  I
just fixed that with the first one of the two commits below.
Thanks for reporting the issue!

While there, i also replaced the horrible __GNUC__ version number
test by a proper feature test.  No idea why we didn't have that
in the first place, it really wasn't difficult to write.

> Or something. I would hope that you won't lock it out to GCC or clang, 

Absolutely not, that's not my intention at all.

> because I'm sure there's other compilers this thing chokes on.

Right.  Only it's sometimes hard to get reports from other compilers,
so thanks for what you are reporting.

> The rest are to fix the IRIX printf() implementation, which doesn't 
> allow for %zu as mandoc currently does.

I would strongly recommend that you fix your IRIX libc to support %zu
because that has been required by POSIX for more than a decade

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html

and because not having it, which often results in using format
specifiers for the wrong length, can cause security issues.
Maybe not in mandoc, but in general: i don't doubt that you also
run software on IRIX that is more prone to develop security
vulnerabilities.  Besides, i would be surprised if closing that
particular feature gap in the IRIX libc would cause particularly
large amounts of work.

Given that apart from the the notoriously quirky and extremely
outdated SunOS 5.9 (2002 version), this is the first time i'm hearing
about a system that does not support %zu - even SunOS 5.10 (2009
version) supports that - i'm a bit hesitant to write a feature test
for that, also because using the result of the feature test in the
code would be somewhat intrusive.

So until you come around to fixing your libc, is think carrying
local patches for %zu is the best you can do.  But i suggest you
use the following idiom for these patches:

  mandoc_asprintf(arg, "%llun", (unsigned long long)width);

That should be perfectly safe and perfectly portable, whereas the 

  size_t width = ...;
  mandoc_asprintf(arg, "%un", width);

that you are currently using can potentially be dangerous.
At the very least, depending on the platform, on endianness,
and maybe depending on other aspects of the ABI, it might
silently produce incorrect results.

> You can see my discussion with a 
> colleague on the topic here:
> 
> https://forums.irixnet.org/thread-1946-post-14522.html

Very interesting, please keep me posted on how things work out.
In particular, i would be interested to learn if any of your
manual pages format poorly with mandoc.  But it's also
interesting to follow how your work progresses in general.

Regarding the topics discussed in your forum:

 * Heirloom (not "Heritage") Troff has very high typesetting
   quality in some respects, in some even better than groff,
   for example it has paragraph-at-once filling.  It is also
   somewhat maintained, but AFAIK more or less by a one-man
   team (Carsten Kunze) with a handful of commits in 2019
   and none so far in 2020.  It is not at all an obvious
   choice as a manual page formatter.  I'm not aware of a
   single operating system using it for that purpose.  Carsten
   has invested some work to make it better for manual pages,
   but you should still expect at least occasional compatibility
   issues when using it for manual pages, much more frquently
   than with mandoc or groff.

 * With mandoc, all three options are workable:  installing source
   manuals or preformatted manuals, and in the former case,
   using mandoc as both the formatter and the man(1) implementation,
   as for example OpenBSD and Alpine Linux do it, or using mandoc
   as the formatter but a different man(1) implementation, as for
   example FreeBSD and Illumos do it.
   In OpenBSD, we switched in three steps: first we switched the
   formatter from groff to mandoc in 2010, then we switched from
   installing preformatted to installing source manuals in 2011,
   and finally to the mandoc implementation of man(1) in 2014.
   Alpine Linux has done all that in one single step in 2014.

> I understand if you do not want to upstream all of these changes, but I 
> would hope that we can take some action to prevent someone else from 
> having to go through this. Surely, this is not the only UNIX that would 
> cause this.

In general, i try to upstream patches when it is possible without
causing unreasonable complication.  Often, that work progressed in
multiple steps, slowly and carefully improving support for that
platform, sometimes over years.  For example, in the beginning,
building on Oracle Solaris 11 needed lots of handholding and various
configure.local tweaks.  By now, even the older SunOS 5.10 just
works out of the box.

> Yes, GCC works, but we don't have clang and often times using a GPL 
> compiler isn't only against my own principles when we have perfectly 
> good alternatives, and MIPSPro performs better on IRIX than GCC.

That sounds reasonable.

> If I can be of any assistance or questions in regards to this patch, let 
> me know!

Sure, see above, and keep me posted about how your work is progressing!

Do you have a porting or packaging system in IRIX, in any way similar
to BSD ports, or Linux packages, or MacPorts, or Homebrew, or AUR,
or SlackBuilds, or Cashew?  If so, is there a distinction between
official or unofficial ports/packages?  I'm wondering whether at some
point, it might make sense to list IRIX on

  https://mandoc.bsd.lv/ports.html

but i'm a bit at a loss as to how...

Could you re-test whether compiling mandoc from CVS HEAD on IRIX
now already works a bit better for you, with smaller patches?

Yours,
  Ingo


Log Message:
-----------
Because mandoc_aux.h and mandoc.h use __attribute__, all files that
include mandoc_aux.h or mandoc.h need to include config.h, too.
It is suspected that for example IRIX needs this, or it is likely
to throw errors in these files because the system compiler doesn't
understand __attribute__.
Issue reported by Kazuo Kuroi <kazuo at irixnet dot org>.

Modified Files:
--------------
    mandoc:
        Makefile.depend
        dba_array.c
        dba_read.c
        mandoc_ohash.c
        mandoc_xr.c
        mdoc_markdown.c
        mdoc_state.c
        roff_html.c
        roff_term.c
        roff_validate.c
        term_tab.c

Revision Data
-------------
Index: mdoc_state.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_state.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lmdoc_state.c -Lmdoc_state.c -u -p -r1.16 -r1.17
--- mdoc_state.c
+++ mdoc_state.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -14,6 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <assert.h>
Index: term_tab.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/term_tab.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lterm_tab.c -Lterm_tab.c -u -p -r1.5 -r1.6
--- term_tab.c
+++ term_tab.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -14,6 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <stddef.h>
Index: roff_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_html.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lroff_html.c -Lroff_html.c -u -p -r1.20 -r1.21
--- roff_html.c
+++ roff_html.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014, 2017, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,6 +15,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <assert.h>
Index: mandoc_ohash.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_ohash.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lmandoc_ohash.c -Lmandoc_ohash.c -u -p -r1.2 -r1.3
--- mandoc_ohash.c
+++ mandoc_ohash.c
@@ -1,4 +1,4 @@
-/*	$Id$	*/
+/* $Id$	*/
 /*
  * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -14,6 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdint.h>
Index: mdoc_markdown.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_markdown.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lmdoc_markdown.c -Lmdoc_markdown.c -u -p -r1.35 -r1.36
--- mdoc_markdown.c
+++ mdoc_markdown.c
@@ -16,6 +16,8 @@
  *
  * Markdown formatter for mdoc(7) used by mandoc(1).
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <assert.h>
Index: dba_read.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/dba_read.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Ldba_read.c -Ldba_read.c -u -p -r1.4 -r1.5
--- dba_read.c
+++ dba_read.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -19,6 +19,8 @@
  * The interface is defined in "dba.h".
  * This file is seperate from dba.c because this also uses "dbm.h".
  */
+#include "config.h"
+
 #include <regex.h>
 #include <stdint.h>
 #include <stdlib.h>
Index: Makefile.depend
===================================================================
RCS file: /home/cvs/mandoc/mandoc/Makefile.depend,v
retrieving revision 1.48
retrieving revision 1.49
diff -LMakefile.depend -LMakefile.depend -u -p -r1.48 -r1.49
--- Makefile.depend
+++ Makefile.depend
@@ -22,8 +22,8 @@ compat_strsep.o: compat_strsep.c config.
 compat_strtonum.o: compat_strtonum.c config.h
 compat_vasprintf.o: compat_vasprintf.c config.h
 dba.o: dba.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mansearch.h dba_write.h dba_array.h dba.h
-dba_array.o: dba_array.c mandoc_aux.h dba_write.h dba_array.h
-dba_read.o: dba_read.c mandoc_aux.h mansearch.h dba_array.h dba.h dbm.h
+dba_array.o: dba_array.c config.h mandoc_aux.h dba_write.h dba_array.h
+dba_read.o: dba_read.c config.h mandoc_aux.h mansearch.h dba_array.h dba.h dbm.h
 dba_write.o: dba_write.c config.h dba_write.h
 dbm.o: dbm.c config.h mansearch.h dbm_map.h dbm.h
 dbm_map.o: dbm_map.c config.h mansearch.h dbm_map.h dbm.h
@@ -42,8 +42,8 @@ man_validate.o: man_validate.c config.h 
 mandoc.o: mandoc.c config.h mandoc_aux.h mandoc.h roff.h libmandoc.h roff_int.h
 mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h
 mandoc_msg.o: mandoc_msg.c config.h mandoc.h
-mandoc_ohash.o: mandoc_ohash.c mandoc_aux.h mandoc_ohash.h compat_ohash.h
-mandoc_xr.o: mandoc_xr.c mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc_xr.h
+mandoc_ohash.o: mandoc_ohash.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h
+mandoc_xr.o: mandoc_xr.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc_xr.h
 mandocd.o: mandocd.c config.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h
 mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h manconf.h mansearch.h dba_array.h dba.h
 manpath.o: manpath.c config.h mandoc_aux.h mandoc.h manconf.h
@@ -53,8 +53,8 @@ mdoc_argv.o: mdoc_argv.c config.h mandoc
 mdoc_html.o: mdoc_html.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h html.h main.h
 mdoc_macro.o: mdoc_macro.c config.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
 mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h out.h main.h
-mdoc_markdown.o: mdoc_markdown.c mandoc_aux.h mandoc.h roff.h mdoc.h main.h
-mdoc_state.o: mdoc_state.c mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
+mdoc_markdown.o: mdoc_markdown.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h main.h
+mdoc_state.o: mdoc_state.c config.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
 mdoc_term.o: mdoc_term.c config.h mandoc_aux.h roff.h mdoc.h out.h term.h term_tag.h main.h
 mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h tag.h
 msec.o: msec.c config.h mandoc.h libmandoc.h msec.in
@@ -62,9 +62,9 @@ out.o: out.c config.h mandoc_aux.h tbl.h
 preconv.o: preconv.c config.h mandoc.h roff.h mandoc_parse.h libmandoc.h
 read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h tag.h
 roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mandoc_parse.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in
-roff_html.o: roff_html.c mandoc.h roff.h out.h html.h
-roff_term.o: roff_term.c mandoc.h roff.h out.h term.h
-roff_validate.o: roff_validate.c mandoc.h roff.h libmandoc.h roff_int.h
+roff_html.o: roff_html.c config.h mandoc.h roff.h out.h html.h
+roff_term.o: roff_term.c config.h mandoc.h roff.h out.h term.h
+roff_validate.o: roff_validate.c config.h mandoc.h roff.h libmandoc.h roff_int.h
 soelim.o: soelim.c config.h compat_stringlist.h
 st.o: st.c config.h mandoc.h roff.h libmdoc.h
 tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h roff.h mdoc.h roff_int.h tag.h
@@ -77,6 +77,6 @@ tbl_term.o: tbl_term.c config.h mandoc.h
 term.o: term.c config.h mandoc.h mandoc_aux.h out.h term.h main.h
 term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h manconf.h main.h
 term_ps.o: term_ps.c config.h mandoc_aux.h out.h term.h manconf.h main.h
-term_tab.o: term_tab.c mandoc_aux.h out.h term.h
+term_tab.o: term_tab.c config.h mandoc_aux.h out.h term.h
 term_tag.o: term_tag.c config.h mandoc.h roff.h roff_int.h tag.h term_tag.h
 tree.o: tree.c config.h mandoc.h roff.h mdoc.h man.h tbl.h eqn.h main.h
Index: dba_array.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/dba_array.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -Ldba_array.c -Ldba_array.c -u -p -r1.1 -r1.2
--- dba_array.c
+++ dba_array.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -17,6 +17,8 @@
  * Allocation-based arrays for the mandoc database, for read-write access.
  * The interface is defined in "dba_array.h".
  */
+#include "config.h"
+
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
Index: mandoc_xr.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_xr.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lmandoc_xr.c -Lmandoc_xr.c -u -p -r1.3 -r1.4
--- mandoc_xr.c
+++ mandoc_xr.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -14,6 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <assert.h>
Index: roff_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_validate.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lroff_validate.c -Lroff_validate.c -u -p -r1.19 -r1.20
--- roff_validate.c
+++ roff_validate.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2010, 2017, 2018, 2020 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -14,6 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <assert.h>
Index: roff_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_term.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lroff_term.c -Lroff_term.c -u -p -r1.19 -r1.20
--- roff_term.c
+++ roff_term.c
@@ -1,4 +1,4 @@
-/*	$Id$ */
+/* $Id$ */
 /*
  * Copyright (c) 2010,2014,2015,2017-2019 Ingo Schwarze <schwarze@openbsd.org>
  *
@@ -14,6 +14,8 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+#include "config.h"
+
 #include <sys/types.h>
 
 #include <assert.h>


Log Message:
-----------
Provide a real feature test for __attribute__().
Looking at version numbers like __GNUC__ is always a bad idea.
Believe it or not, this even makes ./configure shorter by one line.

Modified Files:
--------------
    mandoc:
        Makefile
        configure
        configure.local.example

Added Files:
-----------
    mandoc:
        test-attribute.c

Revision Data
-------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/Makefile,v
retrieving revision 1.534
retrieving revision 1.535
diff -LMakefile -LMakefile -u -p -r1.534 -r1.535
--- Makefile
+++ Makefile
@@ -19,7 +19,8 @@ VERSION = 1.14.5
 
 # === LIST OF FILES ====================================================
 
-TESTSRCS	 = test-be32toh.c \
+TESTSRCS	 = test-attribute.c \
+		   test-be32toh.c \
 		   test-cmsg.c \
 		   test-dirent-namlen.c \
 		   test-EFTYPE.c \
--- /dev/null
+++ test-attribute.c
@@ -0,0 +1,48 @@
+/* $Id: test-attribute.c,v 1.1 2020/06/22 20:00:38 schwarze Exp $ */
+/*
+ * Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void	 var_arg(const char *, ...)
+		__attribute__((__format__ (__printf__, 1, 2)));
+void	 no_ret(int)
+		__attribute__((__noreturn__));
+
+void
+var_arg(const char *fmt, ...)
+{
+	va_list	 ap;
+
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+}
+
+void
+no_ret(int i)
+{
+	exit(i);
+}
+
+int
+main(void)
+{
+	var_arg("Test output: %d\n", 42);
+	no_ret(0);
+}
Index: configure.local.example
===================================================================
RCS file: /home/cvs/mandoc/mandoc/configure.local.example,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lconfigure.local.example -Lconfigure.local.example -u -p -r1.37 -r1.38
--- configure.local.example
+++ configure.local.example
@@ -288,6 +288,7 @@ CFLAGS="-g"
 # and will be regarded as failed) or 1 (test will not be run and will
 # be regarded as successful).
 
+HAVE_ATTRIBUTE=0
 HAVE_DIRENT_NAMLEN=0
 HAVE_ENDIAN=0
 HAVE_EFTYPE=0
Index: configure
===================================================================
RCS file: /home/cvs/mandoc/mandoc/configure,v
retrieving revision 1.75
retrieving revision 1.76
diff -Lconfigure -Lconfigure -u -p -r1.75 -r1.76
--- configure
+++ configure
@@ -55,6 +55,7 @@ BUILD_CGI=0
 BUILD_CATMAN=0
 INSTALL_LIBMANDOC=0
 
+HAVE_ATTRIBUTE=
 HAVE_CMSG=
 HAVE_DIRENT_NAMLEN=
 HAVE_EFTYPE=
@@ -294,6 +295,7 @@ fi
 # --- tests for config.h  ----------------------------------------------
 
 # --- library functions ---
+runtest attribute	ATTRIBUTE	|| true
 runtest cmsg		CMSG		"" "-D_XPG4_2" || true
 runtest dirent-namlen	DIRENT_NAMLEN	|| true
 runtest be32toh		ENDIAN		|| true
@@ -422,10 +424,6 @@ cat << __HEREDOC__
 #error "Do not use C++.  See the INSTALL file."
 #endif
 
-#if !defined(__GNUC__) || (__GNUC__ < 4)
-#define __attribute__(x)
-#endif
-
 __HEREDOC__
 
 [ ${NEED_GNU_SOURCE} -eq 0 ] || echo "#define _GNU_SOURCE"
@@ -447,6 +445,7 @@ echo "#define OSENUM ${OSENUM}"
 [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
 [ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
 [ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
+[ ${HAVE_ATTRIBUTE} -eq 0 ] && echo "#define __attribute__(x)"
 [ ${HAVE_EFTYPE} -eq 0 ] && echo "#define EFTYPE EINVAL"
 [ ${HAVE_O_DIRECTORY} -eq 0 ] && echo "#define O_DIRECTORY 0"
 [ ${HAVE_PATH_MAX} -eq 0 ] && echo "#define PATH_MAX 4096"
--
 To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv


  reply	other threads:[~2020-06-22 21:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02 23:29 Kazuo Kuroi
2020-06-22 21:44 ` Ingo Schwarze [this message]
2020-06-22 22:09   ` Kazuo Kuroi
2020-08-27 18:09     ` Ingo Schwarze
2020-08-28 19:40       ` Kazuo Kuroi
2020-08-31 14:12         ` Ingo Schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200622214406.GD93760@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=discuss@mandoc.bsd.lv \
    --cc=kazuo@irixnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).