Closed alejandro-colomar closed 5 months ago
v2 changes:
$ git range-diff master gh/day2str day2str
1: 741fc096 = 1: 741fc096 src/chage.c: Unify long overflow checks in print_day_as_date()
2: d5d9194e = 2: d5d9194e lib/: Saturate addition to avoid overflow
3: 20bb258f < -: -------- lib/, src/, po/: date_to_str(): Move function to header, and make inline
-: -------- > 3: 3bd301e4 lib/, src/, po/: date_to_str(): Move function to header, and make inline
4: 46362e76 ! 4: b636afcf lib/day_to_str.h: DAY_TO_STR(): Add macro
@@ Metadata
Author: Alejandro Colomar <alx@kernel.org>
## Commit message ##
- lib/day_to_str.h: DAY_TO_STR(): Add macro
+ lib/time/day_to_str.h: DAY_TO_STR(): Add macro
This macro ensures that the buffer is an array, and calculates the size.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
- ## lib/day_to_str.h ##
+ ## lib/time/day_to_str.h ##
@@
#include <time.h>
5: fd9ca675 = 5: 7416616a src/: Use DAY_TO_STR() instead of its pattern
6: ce086de9 = 6: 47e450c3 src/passwd.c: print_status(): Fix typo (bogus use of the comma operator)
7: 1a73b4d1 ! 7: f77a1143 lib/day_to_str.[ch]: day_to_str(): Accept a day instead of a date, and rename function
@@ Metadata
Author: Alejandro Colomar <alx@kernel.org>
## Commit message ##
- lib/day_to_str.[ch]: day_to_str(): Accept a day instead of a date, and rename function
+ lib/time/day_to_str.[ch]: day_to_str(): Accept a day instead of a date, and rename function
It was always being called with 'day * DAY', so do that internally and
simplify. This grabs some code from print_day_as_date().
@@ Commit message
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
- ## lib/day_to_str.c ##
+ ## lib/time/day_to_str.c ##
@@
// SPDX-FileCopyrightText: 2021-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2024, Tobias Stoeckmann <tobias@stoeckmann.org>
@@ lib/day_to_str.c
@@
- #include "day_to_str.h"
+ #include "time/day_to_str.h"
-extern inline void date_to_str(size_t size, char buf[size], long date);
+extern inline void day_to_str(size_t size, char buf[size], long day);
- ## lib/day_to_str.h ##
+ ## lib/time/day_to_str.h ##
@@
-/*
- * SPDX-FileCopyrightText: 2021-2023, Alejandro Colomar <alx@kernel.org>
@@ lib/day_to_str.h
+// SPDX-License-Identifier: BSD-3-Clause
- #ifndef SHADOW_INCLUDE_LIB_DAY_TO_STR_H_
+ #ifndef SHADOW_INCLUDE_LIB_TIME_DAY_TO_STR_H_
@@
#include "string/strtcpy.h"
8: d7b2729e ! 8: e058ebdc lib/, src/: Call gmtime_r(3) instead of gmtime(3)
@@ Commit message
Signed-off-by: Alejandro Colomar <alx@kernel.org>
- ## lib/day_to_str.h ##
-@@ lib/day_to_str.h: inline void day_to_str(size_t size, char buf[size], long day);
+ ## lib/time/day_to_str.h ##
+@@ lib/time/day_to_str.h: inline void day_to_str(size_t size, char buf[size], long day);
inline void
day_to_str(size_t size, char buf[size], long day)
{
@@ lib/day_to_str.h: inline void day_to_str(size_t size, char buf[size], long day);
if (day < 0) {
strtcpy(buf, "never", size);
-@@ lib/day_to_str.h: day_to_str(size_t size, char buf[size], long day)
+@@ lib/time/day_to_str.h: day_to_str(size_t size, char buf[size], long day)
return;
}
v3 changes:
$ git range-diff alx/master..gh/day2str shadow/master..day2str
1: 741fc096 < -: -------- src/chage.c: Unify long overflow checks in print_day_as_date()
2: d5d9194e < -: -------- lib/: Saturate addition to avoid overflow
3: 3bd301e4 = 1: 2c05a34f lib/, src/, po/: date_to_str(): Move function to header, and make inline
4: b636afcf = 2: 16c2bcb9 lib/time/day_to_str.h: DAY_TO_STR(): Add macro
5: 7416616a = 3: e8da3365 src/: Use DAY_TO_STR() instead of its pattern
6: 47e450c3 = 4: 77a1b196 src/passwd.c: print_status(): Fix typo (bogus use of the comma operator)
7: f77a1143 = 5: 540711ee lib/time/day_to_str.[ch]: day_to_str(): Accept a day instead of a date, and rename function
8: e058ebdc = 6: 3c07d2dd lib/, src/: Call gmtime_r(3) instead of gmtime(3)
v3b changes:
$ git range-diff gh/master..gh/day2str alx/master..day2str
1: 2c05a34f = 1: c4cdcdf5 lib/, src/, po/: date_to_str(): Move function to header, and make inline
2: 16c2bcb9 = 2: 3f86cf8e lib/time/day_to_str.h: DAY_TO_STR(): Add macro
3: e8da3365 = 3: ac9eba28 src/: Use DAY_TO_STR() instead of its pattern
4: 77a1b196 = 4: 38707801 src/passwd.c: print_status(): Fix typo (bogus use of the comma operator)
5: 540711ee = 5: 80af7302 lib/time/day_to_str.[ch]: day_to_str(): Accept a day instead of a date, and rename function
6: 3c07d2dd = 6: 739dada8 lib/, src/: Call gmtime_r(3) instead of gmtime(3)
v3c changes:
$ git range-diff 89c4da43..739dada8 alx/master..7dff7a10
1: c4cdcdf5 = 1: ab8faec6 lib/, src/, po/: date_to_str(): Move function to header, and make inline
2: 3f86cf8e = 2: 1a3670b8 lib/time/day_to_str.h: DAY_TO_STR(): Add macro
3: ac9eba28 = 3: e78b0bea src/: Use DAY_TO_STR() instead of its pattern
4: 38707801 = 4: c1617eb9 src/passwd.c: print_status(): Fix typo (bogus use of the comma operator)
5: 80af7302 = 5: 7f222bb0 lib/time/day_to_str.[ch]: day_to_str(): Accept a day instead of a date, and rename function
6: 739dada8 = 6: 7dff7a10 lib/, src/: Call gmtime_r(3) instead of gmtime(3)