Skip to content

Commit

Permalink
x11-toolkits/open-motif*: revise AM_FUNC_VOID_SPRINTF
Browse files Browse the repository at this point in the history
The check for whether sprintf() returns void would fail to detect
sprintf() returning int under recent Clang.
Presumably the check meant to see if an error like
"passing 'void' to parameter of incompatible type 'int'"
is generated, but Clang would always generate other errors
having to do with calling sprintf() with too few arguments
and attempting to redeclare sprintf() when it is a builtin macro.
And even if the test program compiles, such as with GCC,
it crashes during the sprintf(".") call.

Revise the test program to not redeclare sprintf(), to call sprintf()
with valid arguments, and to not implicitly declare exit() due to
stdlib.h not being included (which Apple Xcode Clang 12 and later
consider an error rather than a warning).
If sprintf() returns void, then a compiler error similar to
"initializing 'int' with an expression of incompatible type 'void'"
or "void value not ignored as it ought to be" should be generated.
Otherwise if sprintf() returns int, then the test program should
compile and exit with code 0, and the check should properly report
that sprintf() does not return void.

Obtained from:	https://sourceforge.net/p/motif/code/merge-requests/3/
  • Loading branch information
cschuber committed Dec 5, 2023
1 parent ebd4310 commit c1d2da5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x11-toolkits/open-motif-devel/Makefile
@@ -1,6 +1,6 @@
PORTNAME= open-motif
PORTVERSION= ${COMMIT_DATE}
PORTREVISION= 4
PORTREVISION= 5
CATEGORIES= x11-toolkits
PKGNAMESUFFIX= -devel

Expand Down
16 changes: 16 additions & 0 deletions x11-toolkits/open-motif-devel/files/patch-acinclude.m4
@@ -0,0 +1,16 @@
--- acinclude.m4.orig 2023-02-15 16:42:34.000000000 -0800
+++ acinclude.m4 2023-12-04 15:48:14.815249000 -0800
@@ -50,7 +50,12 @@
AC_DEFUN([AM_FUNC_VOID_SPRINTF],
[AC_CACHE_CHECK(whether sprintf returns void, ac_cv_func_void_sprintf,
[AC_TRY_RUN([#include <stdio.h>
-int sprintf(); main() { exit(sprintf(".")); }],
+int main() {
+ char buf[1];
+ int i = sprintf(buf, "");
+ return 0;
+}
+],
ac_cv_func_void_sprintf=no, ac_cv_func_void_sprintf=yes, ac_cv_func_void_sprintf=yes)])
if test $ac_cv_func_void_sprintf = no; then
AC_DEFINE(VOID_SPRINTF,1,
2 changes: 1 addition & 1 deletion x11-toolkits/open-motif/Makefile
@@ -1,6 +1,6 @@
PORTNAME= open-motif
PORTVERSION= 2.3.8
PORTREVISION= 5
PORTREVISION= 6
CATEGORIES= x11-toolkits
# MASTER_SITES= SF/${PORTNAME}/Motif%202.3.4%20Source%20Code/
MASTER_SITES= SF/motif/Motif%20${PORTVERSION}%20Source%20Code/
Expand Down
16 changes: 16 additions & 0 deletions x11-toolkits/open-motif/files/patch-acinclude.m4
@@ -0,0 +1,16 @@
--- acinclude.m4.orig 2017-08-27 19:29:50.000000000 -0700
+++ acinclude.m4 2023-12-04 15:48:12.951361000 -0800
@@ -50,7 +50,12 @@
AC_DEFUN([AM_FUNC_VOID_SPRINTF],
[AC_CACHE_CHECK(whether sprintf returns void, ac_cv_func_void_sprintf,
[AC_TRY_RUN([#include <stdio.h>
-int sprintf(); main() { exit(sprintf(".")); }],
+int main() {
+ char buf[1];
+ int i = sprintf(buf, "");
+ return 0;
+}
+],
ac_cv_func_void_sprintf=no, ac_cv_func_void_sprintf=yes, ac_cv_func_void_sprintf=yes)])
if test $ac_cv_func_void_sprintf = no; then
AC_DEFINE(VOID_SPRINTF,1,

0 comments on commit c1d2da5

Please sign in to comment.