Skip to content

Commit abbb426

Browse files
committed
gfunc: fix build error on macOS
1 parent e6db196 commit abbb426

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ if test ${sysconfdir} = '${prefix}/etc'; then
122122
sysconfdir='/etc'
123123
fi
124124

125+
# fix macOS build error
126+
AC_CHECK_SIZEOF(off_t)
127+
AC_CHECK_SIZEOF(long long)
128+
AC_CHECK_SIZEOF(long)
129+
125130
AC_CONFIG_FILES([GNUmakefile
126131
po/GNUmakefile
127132
rdup.h

gfunc.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
#define SHA1_DIGEST_SIZE 20
1515
#endif /* HAVE_LIBNETTLE */
1616

17+
#if SIZEOF_OFF_T == SIZEOF_LONG_LONG
18+
#define OFF_T_FORMAT "lld"
19+
#elif SIZEOF_OFF_T == SIZEOF_LONG
20+
#define OFF_T_FORMAT "ld"
21+
#else
22+
#error "Unknown sizeof(off_t)"
23+
#endif
24+
1725
extern gboolean opt_removed;
1826
extern gboolean opt_modified;
1927
extern gboolean opt_skip;
@@ -293,11 +301,11 @@ static void entry_print_data(FILE * out, char n, struct rdup *e)
293301
}
294302
/* links */
295303
if (S_ISLNK(e->f_mode) || e->f_lnk == 1) {
296-
fprintf(out, "%jd", e->f_size);
304+
fprintf(out, "%" OFF_T_FORMAT, e->f_size);
297305
break;
298306
}
299307

300-
fprintf(out, "%jd", e->f_size);
308+
fprintf(out, "%" OFF_T_FORMAT, e->f_size);
301309
break;
302310
case 'H': /* sha1 hash */
303311
if (S_ISREG(e->f_mode)) {

0 commit comments

Comments
 (0)