-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main/tig: fix printing of time_t values on 32 bit arches
See: jonas/tig#1084
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Since musl 1.2 time_t is a 64 bit value, even on 32 bit systems. A | ||
hotfix for printing the value is simply using PRId64 from inttypes.h | ||
in the format string. | ||
|
||
See: https://github.com/jonas/tig/issues/1084 | ||
|
||
diff -upr tig-2.5.2.orig/src/util.c tig-2.5.2/src/util.c | ||
--- tig-2.5.2.orig/src/util.c 2021-02-14 13:03:52.467947432 +0100 | ||
+++ tig-2.5.2/src/util.c 2021-02-14 13:04:22.911283635 +0100 | ||
@@ -11,6 +11,8 @@ | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
+#include <inttypes.h> | ||
+ | ||
#include "tig/tig.h" | ||
#include "tig/util.h" | ||
|
||
@@ -160,12 +162,12 @@ get_relative_date(const struct time *tim | ||
|
||
seconds /= reldate[i].in_seconds; | ||
if (compact) { | ||
- if (!string_nformat(buf, buflen, NULL, "%s%ld%c", | ||
+ if (!string_nformat(buf, buflen, NULL, "%s%"PRId64"%c", | ||
now.tv_sec >= timestamp ? "" : "-", | ||
seconds, reldate[i].compact_symbol)) | ||
return ""; | ||
|
||
- } else if (!string_nformat(buf, buflen, NULL, "%ld %s%s %s", | ||
+ } else if (!string_nformat(buf, buflen, NULL, "%"PRId64" %s%s %s", | ||
seconds, reldate[i].name, | ||
seconds > 1 ? "s" : "", | ||
now.tv_sec >= timestamp ? "ago" : "ahead")) |