-/* $Id: main.c,v 1.53 2009/10/31 06:10:57 kristaps Exp $ */
+/* $Id: main.c,v 1.57 2009/11/02 08:29:25 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
-/* Account for FreeBSD and Linux in our declarations. */
+/* FIXME: Intel's compiler? LLVM? pcc? */
+
+#if !defined(__GNUC__) || (__GNUC__ < 2)
+# if !defined(lint)
+# define __attribute__(x)
+# endif
+#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */
#ifdef __linux__
extern int getsubopt(char **, char * const *, char **);
extern size_t strlcat(char *, const char *, size_t);
-# ifndef __dead
-# define __dead __attribute__((__noreturn__))
-# endif
-#elif defined(__dead2)
-# ifndef __dead
-# define __dead __dead2
-# endif
#endif
typedef void (*out_mdoc)(void *, const struct mdoc *);
struct man **, struct mdoc **);
static struct man *man_init(struct curparse *);
static struct mdoc *mdoc_init(struct curparse *);
-__dead static void version(void);
-__dead static void usage(void);
+static void version(void) __attribute__((noreturn));
+static void usage(void) __attribute__((noreturn));
-extern char *__progname;
+static const char *progname;
int
struct buf ln, blk;
struct curparse curp;
+ progname = strrchr(argv[0], '/');
+ if (progname == NULL)
+ progname = argv[0];
+ else
+ ++progname;
+
memset(&curp, 0, sizeof(struct curparse));
curp.inttype = INTT_AUTO;
}
-__dead static void
+static void
version(void)
{
- (void)printf("%s %s\n", __progname, VERSION);
+ (void)printf("%s %s\n", progname, VERSION);
exit(EXIT_SUCCESS);
}
-__dead static void
+static void
usage(void)
{
(void)fprintf(stderr, "usage: %s [-V] [-foption...] "
"[-mformat] [-Ooption] [-Toutput] "
- "[-Werr...]\n", __progname);
+ "[-Werr...]\n", progname);
exit(EXIT_FAILURE);
}
else if (0 == strcmp(arg, "an"))
*tflags = INTT_MAN;
else {
- fprintf(stderr, "%s: Bad argument", arg);
+ fprintf(stderr, "%s: Bad argument\n", arg);
return(0);
}
else if (0 == strcmp(arg, "html"))
*tflags = OUTT_HTML;
else {
- fprintf(stderr, "%s: Bad argument", arg);
+ fprintf(stderr, "%s: Bad argument\n", arg);
return(0);
}
*fflags &= ~NO_IGN_ESCAPE;
break;
default:
- fprintf(stderr, "%s: Bad argument", o);
+ fprintf(stderr, "%s: Bad argument\n", o);
return(0);
}
}
*wflags |= WARN_WERR;
break;
default:
- fprintf(stderr, "%s: Bad argument", o);
+ fprintf(stderr, "%s: Bad argument\n", o);
return(0);
}
}