Skip to content

Commit

Permalink
gfunc: fix build error on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-d committed Nov 14, 2021
1 parent e6db196 commit 658ff71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ if test ${sysconfdir} = '${prefix}/etc'; then
sysconfdir='/etc'
fi

# fix macOS build error
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(long)

AC_CONFIG_FILES([GNUmakefile
po/GNUmakefile
rdup.h
Expand Down
13 changes: 11 additions & 2 deletions gfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
#define SHA1_DIGEST_SIZE 20
#endif /* HAVE_LIBNETTLE */

/* see https://github.com/miekg/rdup/pull/47 for why this is necessary */
#if SIZEOF_OFF_T == SIZEOF_LONG_LONG
#define OFF_T_FORMAT "lld"
#elif SIZEOF_OFF_T == SIZEOF_LONG
#define OFF_T_FORMAT "ld"
#else
#error Unknown sizeof(off_t)
#endif

extern gboolean opt_removed;
extern gboolean opt_modified;
extern gboolean opt_skip;
Expand Down Expand Up @@ -293,11 +302,11 @@ static void entry_print_data(FILE * out, char n, struct rdup *e)
}
/* links */
if (S_ISLNK(e->f_mode) || e->f_lnk == 1) {
fprintf(out, "%jd", e->f_size);
fprintf(out, "%" OFF_T_FORMAT, e->f_size);
break;
}

fprintf(out, "%jd", e->f_size);
fprintf(out, "%" OFF_T_FORMAT, e->f_size);
break;
case 'H': /* sha1 hash */
if (S_ISREG(e->f_mode)) {
Expand Down

0 comments on commit 658ff71

Please sign in to comment.