aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2023-07-04 04:39:00 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2023-07-04 04:39:00 +0000
commit4ef3964b5f85f162c3a1bef5eeb5f18c253f08ad (patch)
tree9050aa6f254d2bb6e58819118c7632d7d8b762eb
parent81a37995c757b4e3ad8a5c699864197fd1ebdcf5 (diff)
downloadsrc-4ef3964b5f85f162c3a1bef5eeb5f18c253f08ad.tar.gz
src-4ef3964b5f85f162c3a1bef5eeb5f18c253f08ad.zip
bin/date: Upgrade calculations (take 2)
Use uint64_t instead of long, as this type is not correct for platforms like i386 or armv7. Pointed out by: imp
-rw-r--r--bin/date/vary.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/bin/date/vary.c b/bin/date/vary.c
index 6f3c59950ecf..a067489bb728 100644
--- a/bin/date/vary.c
+++ b/bin/date/vary.c
@@ -29,12 +29,13 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <time.h>
+#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "vary.h"
struct trans {
- long val;
+ int64_t val;
const char *str;
};
@@ -52,7 +53,7 @@ static struct trans trans_wday[] = {
};
static char digits[] = "0123456789";
-static int adjhour(struct tm *, char, long, int);
+static int adjhour(struct tm *, char, int64_t, int);
static int
domktime(struct tm *t, char type)
@@ -125,7 +126,7 @@ daysinmonth(const struct tm *t)
static int
-adjyear(struct tm *t, char type, long val, int mk)
+adjyear(struct tm *t, char type, int64_t val, int mk)
{
switch (type) {
case '+':
@@ -146,7 +147,7 @@ adjyear(struct tm *t, char type, long val, int mk)
}
static int
-adjmon(struct tm *t, char type, long val, int istext, int mk)
+adjmon(struct tm *t, char type, int64_t val, int istext, int mk)
{
int lmdays;
@@ -206,7 +207,7 @@ adjmon(struct tm *t, char type, long val, int istext, int mk)
}
static int
-adjday(struct tm *t, char type, long val, int mk)
+adjday(struct tm *t, char type, int64_t val, int mk)
{
int lmdays;
@@ -250,7 +251,7 @@ adjday(struct tm *t, char type, long val, int mk)
}
static int
-adjwday(struct tm *t, char type, long val, int istext, int mk)
+adjwday(struct tm *t, char type, int64_t val, int istext, int mk)
{
if (val < 0)
return 0;
@@ -286,7 +287,7 @@ adjwday(struct tm *t, char type, long val, int istext, int mk)
}
static int
-adjhour(struct tm *t, char type, long val, int mk)
+adjhour(struct tm *t, char type, int64_t val, int mk)
{
if (val < 0)
return 0;
@@ -331,7 +332,7 @@ adjhour(struct tm *t, char type, long val, int mk)
}
static int
-adjmin(struct tm *t, char type, long val, int mk)
+adjmin(struct tm *t, char type, int64_t val, int mk)
{
if (val < 0)
return 0;
@@ -372,7 +373,7 @@ adjmin(struct tm *t, char type, long val, int mk)
}
static int
-adjsec(struct tm *t, char type, long val, int mk)
+adjsec(struct tm *t, char type, int64_t val, int mk)
{
if (val < 0)
return 0;
@@ -419,7 +420,7 @@ vary_apply(const struct vary *v, struct tm *t)
char which;
char *arg;
size_t len;
- long val;
+ int64_t val;
for (; v; v = v->next) {
type = *v->arg;