Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gfunc.c: fix build error on macOS #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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