Make C99 clean

* Clang 16 (and likely GCC 14) will enforce strict C99 semantics
  and break old K&R C declarations and require correct C89
  function prototypes.

Bug: https://bugs.gentoo.org/870952
Clang: https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213/9
This commit is contained in:
David Seifert
2022-10-27 11:08:49 -07:00
committed by david parsons
parent e451aac683
commit 7afa5c6242
24 changed files with 63 additions and 86 deletions
+23 -22
View File
@@ -205,8 +205,8 @@ AC_CHECK_FUNCS () {
B=`echo "$1" | sed -e 's/(.*)//'` B=`echo "$1" | sed -e 's/(.*)//'`
case "$B" in case "$B" in
"$1") F="$1()"; need_proto=1 ;; "$1") F="$1()"; PROTO="$1(void)"; need_proto=1 ;;
*) F="$1" ; unset need_proto ;; *) F="$1" ; unset PROTO; unset need_proto ;;
esac esac
shift shift
@@ -218,11 +218,11 @@ AC_CHECK_FUNCS () {
done done
if [ "$need_proto" ]; then if [ "$need_proto" ]; then
echo "void $F;" >> ngc$$.c echo "void $PROTO;" >> ngc$$.c
fi fi
cat >> ngc$$.c << EOF cat >> ngc$$.c << EOF
int main() int main(void)
{ {
$F; $F;
@@ -263,7 +263,7 @@ AC_CHECK_STRUCT () {
done done
cat >> ngc$$.c << EOF cat >> ngc$$.c << EOF
int main() int main(void)
{ {
struct $struct foo; struct $struct foo;
} }
@@ -298,7 +298,7 @@ AC_CHECK_TYPE () {
done done
cat >> ngc$$.c << EOF cat >> ngc$$.c << EOF
int main() int main(void)
{ {
$type foo; $type foo;
} }
@@ -335,7 +335,7 @@ AC_CHECK_FIELD () {
done done
cat >> ngc$$.c << EOF cat >> ngc$$.c << EOF
int main() int main(void)
{ {
struct $struct foo; struct $struct foo;
@@ -364,8 +364,8 @@ AC_PROG_CC () {
test "$AC_CC" && return 0 test "$AC_CC" && return 0
cat > ngc$$.c << \EOF cat > ngc$$.c << \EOF
extern void say(void*); void say(char*);
int main() int main(void)
{ {
say("hello, sailor"); say("hello, sailor");
} }
@@ -899,7 +899,7 @@ EOF
# AC_C_VOLATILE checks to see if the compiler supports the volatile keyword # AC_C_VOLATILE checks to see if the compiler supports the volatile keyword
# #
AC_C_VOLATILE () { AC_C_VOLATILE () {
echo 'f() { volatile char me=1; }' > ngc$$.c echo 'void f(void) { volatile char me=1; }' > ngc$$.c
LOGN "checking for \"volatile\" keyword" LOGN "checking for \"volatile\" keyword"
if __MAKEDOTO ngc$$.c; then if __MAKEDOTO ngc$$.c; then
@@ -917,7 +917,7 @@ AC_C_VOLATILE () {
# AC_C_INLINE checks to see if compiler supports the inline keyword # AC_C_INLINE checks to see if compiler supports the inline keyword
# #
AC_C_INLINE() { AC_C_INLINE() {
echo 'inline int foo() { return 1; }' > ngc$$.c echo 'inline int foo(void) { return 1; }' > ngc$$.c
LOGN 'Checking for "inline" keyword' LOGN 'Checking for "inline" keyword'
if __MAKEDOTO ngc$$.c; then if __MAKEDOTO ngc$$.c; then
rc=0 rc=0
@@ -956,7 +956,7 @@ AC_WHATIS() {
echo "#include <${x}>" echo "#include <${x}>"
done done
echo "main() { printf(\"${MACRO}=\\\"${__fmt}\\\"\\n\", ${MACRO}); }" ) > _ngc$$.c echo "int main(void) { printf(\"${MACRO}=\\\"${__fmt}\\\"\\n\", ${MACRO}); }" ) > _ngc$$.c
if $AC_CC $AC_CFLAGS -o _ngc$$ _ngc$$.c; then if $AC_CC $AC_CFLAGS -o _ngc$$ _ngc$$.c; then
./_ngc$$ ./_ngc$$
@@ -1037,8 +1037,7 @@ say(char *w, char *v)
} }
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
unsigned long v_long; unsigned long v_long;
unsigned int v_int; unsigned int v_int;
@@ -1227,7 +1226,7 @@ AC_CHECK_FLOCK() {
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
int main() int main(void)
{ {
int x = open("ngc$$.c", O_RDWR, 0666); int x = open("ngc$$.c", O_RDWR, 0666);
int y = open("ngc$$.c", O_RDWR, 0666); int y = open("ngc$$.c", O_RDWR, 0666);
@@ -1281,7 +1280,7 @@ AC_CHECK_RESOLVER () {
#include <arpa/nameser.h> #include <arpa/nameser.h>
#include <resolv.h> #include <resolv.h>
int main() int main(void)
{ {
char bfr[256]; char bfr[256];
@@ -1325,7 +1324,7 @@ AC_CHECK_ALLOCA () {
#else #else
# include <stdlib.h> # include <stdlib.h>
#endif #endif
int main() int main(void)
{ {
alloca(10); alloca(10);
} }
@@ -1361,7 +1360,7 @@ AC_CHECK_BASENAME() {
extern char *basename(char*); extern char *basename(char*);
int main() int main(void)
{ {
char *a = basename("/a/test"); char *a = basename("/a/test");
char *b = basename("/a/nother"); char *b = basename("/a/nother");
@@ -1592,7 +1591,11 @@ AC_PROG_INSTALL () {
fi fi
# see if we can strip binaries # see if we can strip binaries
echo 'main() { puts("hello, sailor!"); }' > ngc$$.c cat > ngc$$.c << EOF
#include <stdio.h>
int main(void) { puts("hello, sailor!"); }
EOF
if $AC_CC -o ngc$$ ngc$$.c; then if $AC_CC -o ngc$$ ngc$$.c; then
if $PROG_INSTALL -s -m 444 ngc$$ inst$$; then if $PROG_INSTALL -s -m 444 ngc$$ inst$$; then
_strip="-s" _strip="-s"
@@ -1747,9 +1750,7 @@ cat > ngc$$.c << \EOF
#include <stdio.h> #include <stdio.h>
int int
main(argc, argv) main(int argc, char **argv)
int argc;
char **argv;
{ {
char *p; char *p;
+1 -2
View File
@@ -134,8 +134,7 @@ if AC_CHECK_HEADERS sys/stat.h && AC_CHECK_FUNCS stat; then
cat > ngc$$.c << EOF cat > ngc$$.c << EOF
#include <sys/stat.h> #include <sys/stat.h>
main(argc, argv) int main(int argc, char **argv)
char **argv;
{ {
struct stat info; struct stat info;
+1 -1
View File
@@ -105,7 +105,7 @@ mkd_init_flags(mkd_flag_t *p)
} }
mkd_flag_t * mkd_flag_t *
mkd_flags() mkd_flags(void)
{ {
mkd_flag_t *p = malloc( sizeof(mkd_flag_t) ); mkd_flag_t *p = malloc( sizeof(mkd_flag_t) );
+1 -2
View File
@@ -638,8 +638,7 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size)
* define a prefix tag instead of just `fn` * define a prefix tag instead of just `fn`
*/ */
static char * static char *
p_or_nothing(p) p_or_nothing(MMIOT *p)
MMIOT *p;
{ {
return p->ref_prefix ? p->ref_prefix : "fn"; return p->ref_prefix ? p->ref_prefix : "fn";
} }
+1 -2
View File
@@ -157,8 +157,7 @@ struct h_opt opts[] = {
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
struct h_opt *ret; struct h_opt *ret;
struct h_context ctx; struct h_context ctx;
+7 -18
View File
@@ -10,10 +10,7 @@
void void
hoptset(ctx, argc, argv) hoptset(struct h_context *ctx, int argc, char **argv)
struct h_context *ctx;
int argc;
char **argv;
{ {
memset(ctx, 0, sizeof *ctx); memset(ctx, 0, sizeof *ctx);
ctx->argc = argc; ctx->argc = argc;
@@ -23,30 +20,26 @@ char **argv;
char * char *
hoptarg(ctx) hoptarg(struct h_context *ctx)
struct h_context *ctx;
{ {
return ctx->optarg; return ctx->optarg;
} }
int int
hoptind(ctx) hoptind(struct h_context *ctx)
struct h_context *ctx;
{ {
return ctx->optind; return ctx->optind;
} }
char char
hoptopt(ctx) hoptopt(struct h_context *ctx)
struct h_context *ctx;
{ {
return ctx->optopt; return ctx->optopt;
} }
int int
hopterr(ctx,val) hopterr(struct h_context *ctx, int val)
struct h_context *ctx;
{ {
int old = ctx->opterr; int old = ctx->opterr;
@@ -56,10 +49,7 @@ struct h_context *ctx;
struct h_opt * struct h_opt *
gethopt(ctx, opts, nropts) gethopt(struct h_context *ctx, struct h_opt *opts, int nropts)
struct h_context *ctx;
struct h_opt *opts;
int nropts;
{ {
int i; int i;
int dashes; int dashes;
@@ -318,8 +308,7 @@ struct h_opt opts[] = {
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
struct h_opt *ret; struct h_opt *ret;
struct h_context ctx; struct h_context ctx;
+1 -1
View File
@@ -3,7 +3,7 @@
#include "tags.h" #include "tags.h"
void void
mkd_with_html5_tags() mkd_with_html5_tags(void)
{ {
static int populated = 0; static int populated = 0;
+1 -3
View File
@@ -30,9 +30,7 @@ struct h_opt opts[] = {
#define NROPTS (sizeof opts / sizeof opts[0]) #define NROPTS (sizeof opts / sizeof opts[0])
int int
main(argc, argv) main(int argc, char **argv)
int argc;
char **argv;
{ {
MMIOT *doc; MMIOT *doc;
char *q; char *q;
+3 -3
View File
@@ -265,8 +265,8 @@ extern Document *mkd_string(const char*, int, mkd_flag_t*);
extern Document *gfm_in(FILE *, mkd_flag_t*); extern Document *gfm_in(FILE *, mkd_flag_t*);
extern Document *gfm_string(const char*,int, mkd_flag_t*); extern Document *gfm_string(const char*,int, mkd_flag_t*);
extern void mkd_initialize(); extern void mkd_initialize(void);
extern void mkd_shlib_destructor(); extern void mkd_shlib_destructor(void);
extern void mkd_ref_prefix(Document*, char*); extern void mkd_ref_prefix(Document*, char*);
@@ -285,7 +285,7 @@ extern void ___mkd_reparse(char *, int, mkd_flag_t*, MMIOT*, char*);
extern void ___mkd_emblock(MMIOT*); extern void ___mkd_emblock(MMIOT*);
extern void ___mkd_tidy(Cstring *); extern void ___mkd_tidy(Cstring *);
extern Document *__mkd_new_Document(); extern Document *__mkd_new_Document(void);
extern void __mkd_enqueue(Document*, Cstring *); extern void __mkd_enqueue(Document*, Cstring *);
extern void __mkd_trim_line(Line *, int); extern void __mkd_trim_line(Line *, int);
+1 -2
View File
@@ -85,8 +85,7 @@ extern char* mkd_h1_title(MMIOT *);
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
char *h; char *h;
char *source = 0, *dest = 0; char *source = 0, *dest = 0;
+1 -1
View File
@@ -20,7 +20,7 @@ typedef ANCHOR(Line) LineAnchor;
/* create a new blank Document /* create a new blank Document
*/ */
Document* Document*
__mkd_new_Document() __mkd_new_Document(void)
{ {
Document *ret = calloc(sizeof(Document), 1); Document *ret = calloc(sizeof(Document), 1);
+4 -4
View File
@@ -47,7 +47,7 @@ typedef void mkd_flag_t;
int mkd_flag_isset(mkd_flag_t*, int); /* check a flag status */ int mkd_flag_isset(mkd_flag_t*, int); /* check a flag status */
mkd_flag_t *mkd_flags(); /* create a flag blob */ mkd_flag_t *mkd_flags(void); /* create a flag blob */
mkd_flag_t *mkd_copy_flags(mkd_flag_t*); /* copy a flag blob */ mkd_flag_t *mkd_copy_flags(mkd_flag_t*); /* copy a flag blob */
void mkd_free_flags(mkd_flag_t*); /* delete a flag blob */ void mkd_free_flags(mkd_flag_t*); /* delete a flag blob */
char *mkd_set_flag_string(mkd_flag_t*, char*); /* set named flags */ char *mkd_set_flag_string(mkd_flag_t*, char*); /* set named flags */
@@ -83,9 +83,9 @@ MMIOT *gfm_string(const char*,int,mkd_flag_t*); /* assemble input from a buffer
void mkd_basename(MMIOT*,char*); void mkd_basename(MMIOT*,char*);
void mkd_initialize(); void mkd_initialize(void);
void mkd_with_html5_tags(); void mkd_with_html5_tags(void);
void mkd_shlib_destructor(); void mkd_shlib_destructor(void);
/* compilation, debugging, cleanup /* compilation, debugging, cleanup
*/ */
+1 -1
View File
@@ -43,7 +43,7 @@ typedef int (*stfu)(const void*,const void*);
/* load in the standard collection of html tags that markdown supports /* load in the standard collection of html tags that markdown supports
*/ */
int int
main() main(void)
{ {
int i; int i;
+1 -2
View File
@@ -33,8 +33,7 @@ notspecial(char *file)
#include <stdio.h> #include <stdio.h>
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
int i; int i;
+2 -2
View File
@@ -21,7 +21,7 @@
static int need_to_initrng = 1; static int need_to_initrng = 1;
void void
mkd_initialize() mkd_initialize(void)
{ {
if ( need_to_initrng ) { if ( need_to_initrng ) {
@@ -32,7 +32,7 @@ mkd_initialize()
void DESTRUCTOR void DESTRUCTOR
mkd_shlib_destructor() mkd_shlib_destructor(void)
{ {
mkd_deallocate_tags(); mkd_deallocate_tags();
} }
+2 -2
View File
@@ -59,7 +59,7 @@ typedef int (*stfu)(const void*,const void*);
/* sort the list of extra html block tags for later searching /* sort the list of extra html block tags for later searching
*/ */
void void
mkd_sort_tags() mkd_sort_tags(void)
{ {
qsort(T(extratags), S(extratags), sizeof(struct kw), (stfu)casort); qsort(T(extratags), S(extratags), sizeof(struct kw), (stfu)casort);
} }
@@ -89,7 +89,7 @@ mkd_search_tags(char *pat, int len)
/* destroy the extratags list (for shared libraries) /* destroy the extratags list (for shared libraries)
*/ */
void void
mkd_deallocate_tags() mkd_deallocate_tags(void)
{ {
if ( S(extratags) > 0 ) if ( S(extratags) > 0 )
DELETE(extratags); DELETE(extratags);
+3 -3
View File
@@ -11,9 +11,9 @@ struct kw {
struct kw* mkd_search_tags(char *, int); struct kw* mkd_search_tags(char *, int);
void mkd_prepare_tags(); void mkd_prepare_tags(void);
void mkd_deallocate_tags(); void mkd_deallocate_tags(void);
void mkd_sort_tags(); void mkd_sort_tags(void);
void mkd_define_tag(char *, int); void mkd_define_tag(char *, int);
#endif #endif
+1 -1
View File
@@ -11,7 +11,7 @@ say(char *what)
int int
main() main(void)
{ {
mkd_flag_t *flags = mkd_flags(); mkd_flag_t *flags = mkd_flags();
+3 -4
View File
@@ -192,7 +192,7 @@ prepare(FILE *input)
} }
static int static int
pull() pull(void)
{ {
return psp < S(inbuf) ? T(inbuf)[psp++] : EOF; return psp < S(inbuf) ? T(inbuf)[psp++] : EOF;
} }
@@ -216,7 +216,7 @@ shift(int shiftwidth)
} }
static int* static int*
cursor() cursor(void)
{ {
return T(inbuf) + psp; return T(inbuf) + psp;
} }
@@ -549,8 +549,7 @@ struct h_opt opts[] = {
#define NROPTS (sizeof opts / sizeof opts[0]) #define NROPTS (sizeof opts / sizeof opts[0])
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
char *template = "page.theme"; char *template = "page.theme";
char *source = "stdin"; char *source = "stdin";
+1 -3
View File
@@ -4,9 +4,7 @@
#include "config.h" #include "config.h"
int int
main(argc, argv) main(int argc, char **argv)
int argc;
char **argv;
{ {
#if HAS_GIT #if HAS_GIT
FILE * pipe; FILE * pipe;
+1 -2
View File
@@ -2,8 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
register int c; register int c;
int xp; int xp;
+1 -2
View File
@@ -4,8 +4,7 @@
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
int nl = 1; int nl = 1;
int i; int i;
+1 -2
View File
@@ -50,8 +50,7 @@ struct h_opt opts[] = {
#define NROPTS (sizeof opts / sizeof opts[0]) #define NROPTS (sizeof opts / sizeof opts[0])
int int
main(argc, argv) main(int argc, char **argv)
char **argv;
{ {
int show_author=0, show_title=0, show_date=0; int show_author=0, show_title=0, show_date=0;
MMIOT *p; MMIOT *p;
+1 -1
View File
@@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
int int
main() main(void)
{ {
register int c; register int c;