- Refactor src/processarc.c.
- Make sure all vsnprintf callers are checking the return value, as the
system version will not ohsite on us.
- - Refactor ARRAY_SIZE (need to push the patch).
- Fix ncursesw headers.
- Consider ferror_fclose function.
extern "C" {
#endif
+/* Language definitions. */
+
+#ifndef sizeof_array
+#define sizeof_array(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
/* Path handling. */
void rtrim_slash_slashdot(char *path);
#include <dpkg.h>
#include <dpkg-db.h>
+#include <dpkg-priv.h>
#include "parsedump.h"
#ifdef HAVE_MMAP
/* Note that aliases are added to the nicknames table in parsehelp.c. */
{ NULL /* sentinel - tells code that list is ended */ }
};
-#define NFIELDS (sizeof(fieldinfos)/sizeof(struct fieldinfo))
-const int nfields= NFIELDS;
+
+const int nfields = sizeof_array(fieldinfos);
int parsedb(const char *filename, enum parsedbflags flags,
struct pkginfo **donep, FILE *warnto, int *warncount) {
struct trigaw *ta;
int lno;
int pdone;
- int fieldencountered[NFIELDS];
+ int fieldencountered[sizeof_array(fieldinfos)];
const struct fieldinfo *fip;
const struct nickname *nick;
char *data, *dataptr, *endptr;
#include <dpkg.h>
#include <dpkg-priv.h>
-#define NCATCHSIGNALS (int)(sizeof(catch_signals) / sizeof(int) - 1)
static int catch_signals[] = { SIGQUIT, SIGINT, 0 };
-static struct sigaction uncatch_signals[NCATCHSIGNALS];
+static struct sigaction uncatch_signals[sizeof_array(catch_signals)];
void
setup_subproc_signals(const char *name)
catchsig.sa_handler = SIG_IGN;
sigemptyset(&catchsig.sa_mask);
catchsig.sa_flags = 0;
- for (i = 0; i < NCATCHSIGNALS; i++)
+ for (i = 0; i < sizeof_array(catch_signals); i++)
if (sigaction(catch_signals[i], &catchsig, &uncatch_signals[i]))
ohshite(_("unable to ignore signal %s before running %.250s"),
strsignal(catch_signals[i]), name);
{
int i;
- for (i = 0; i < NCATCHSIGNALS; i++) {
+ for (i = 0; i < sizeof_array(catch_signals); i++) {
if (sigaction(catch_signals[i], &uncatch_signals[i], NULL)) {
fprintf(stderr, _("error un-catching signal %s: %s\n"),
strsignal(catch_signals[i]), strerror(errno));