Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jul 2023 04:40:17 GMT
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 4ef3964b5f85 - main - bin/date: Upgrade calculations (take 2)
Message-ID:  <202307040440.3644eHqf051107@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by pfg:

URL: https://cgit.FreeBSD.org/src/commit/?id=4ef3964b5f85f162c3a1bef5eeb5f18c253f08ad

commit 4ef3964b5f85f162c3a1bef5eeb5f18c253f08ad
Author:     Pedro F. Giffuni <pfg@FreeBSD.org>
AuthorDate: 2023-07-04 04:39:00 +0000
Commit:     Pedro F. Giffuni <pfg@FreeBSD.org>
CommitDate: 2023-07-04 04:39:00 +0000

    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
---
 bin/date/vary.c | 21 +++++++++++----------
 1 file 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307040440.3644eHqf051107>