]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/, po/: date_to_str(): Move function to header, and make inline
authorAlejandro Colomar <alx@kernel.org>
Mon, 29 Jan 2024 14:11:04 +0000 (15:11 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 14 Mar 2024 21:30:46 +0000 (16:30 -0500)
BTW, there's no translatable string in there.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/prototypes.h
lib/time/day_to_str.c [new file with mode: 0644]
lib/time/day_to_str.h [moved from lib/date_to_str.c with 73% similarity]
po/POTFILES.in
src/chage.c
src/passwd.c
src/usermod.c

index 86c6be73d774d498525349996e970f0bc817d357..58d9c14278fa5ca69c79f1beba81aad2e96b6a0d 100644 (file)
@@ -53,7 +53,6 @@ libshadow_la_SOURCES = \
        console.c \
        copydir.c \
        csrand.c \
-       date_to_str.c \
        defines.h \
        encrypt.c \
        env.c \
@@ -159,6 +158,8 @@ libshadow_la_SOURCES = \
        subordinateio.h \
        subordinateio.c \
        sulog.c \
+       time/day_to_str.c \
+       time/day_to_str.h \
        ttytype.c \
        tz.c \
        ulimit.c \
index ff4f7f9963a561a0081a6cac8a984e4d6c57643f..0838884ba4b24dbc3b0cf2497c89fc88c0d5d376 100644 (file)
@@ -108,9 +108,6 @@ extern int copy_tree (const char *src_root, const char *dst_root,
                       uid_t old_uid, uid_t new_uid,
                       gid_t old_gid, gid_t new_gid);
 
-/* date_to_str.c */
-extern void date_to_str (size_t size, char buf[size], long date);
-
 /* encrypt.c */
 extern /*@exposed@*//*@null@*/char *pw_encrypt (const char *, const char *);
 
diff --git a/lib/time/day_to_str.c b/lib/time/day_to_str.c
new file mode 100644 (file)
index 0000000..4acfe90
--- /dev/null
@@ -0,0 +1,10 @@
+// SPDX-FileCopyrightText: 2021-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include <config.h>
+
+#include "time/day_to_str.h"
+
+
+extern inline void date_to_str(size_t size, char buf[size], long date);
similarity index 73%
rename from lib/date_to_str.c
rename to lib/time/day_to_str.h
index cbba0e464c952781f13a50eaab1c6328260632e3..65601c96de5fc4ba3ab28566606b545422f65086 100644 (file)
@@ -4,18 +4,21 @@
  */
 
 
+#ifndef SHADOW_INCLUDE_LIB_TIME_DAY_TO_STR_H_
+#define SHADOW_INCLUDE_LIB_TIME_DAY_TO_STR_H_
+
+
 #include <config.h>
 
-#include <string.h>
 #include <time.h>
 
-#ident "$Id$"
-
 #include "string/strtcpy.h"
-#include "prototypes.h"
 
 
-void
+inline void date_to_str(size_t size, char buf[size], long date);
+
+
+inline void
 date_to_str(size_t size, char buf[size], long date)
 {
        time_t           t;
@@ -36,3 +39,6 @@ date_to_str(size_t size, char buf[size], long date)
        if (strftime(buf, size, "%Y-%m-%d", tm) == 0)
                (void) strtcpy(buf, "future", size);
 }
+
+
+#endif  // include guard
index d49a546066b19c5f82d9bc53a6224b3841773ab4..ce610d1ab61a7cfd862115f7a0c400304cffc249 100644 (file)
@@ -13,7 +13,6 @@ lib/cleanup_user.c
 lib/commonio.c
 lib/console.c
 lib/copydir.c
-lib/date_to_str.c
 lib/encrypt.c
 lib/env.c
 lib/failure.c
index c29ef99e54c43a8d236a6011e079f724799ddeb0..5788a190a6d8f77e02f1ac238ce84ffc8e761e4d 100644 (file)
 #include <pwd.h>
 
 #include "alloc.h"
-#include "prototypes.h"
 #include "defines.h"
 #include "memzero.h"
+#include "prototypes.h"
 #include "pwio.h"
 #include "shadowio.h"
 #include "shadowlog.h"
 #include "string/sprintf.h"
 #include "string/strtcpy.h"
+#include "time/day_to_str.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
+
 #ifdef WITH_TCB
 #include "tcbfuncs.h"
 #endif
-/*@-exitarg@*/
-#include "exitcodes.h"
 
 
 /*
index 5a42193710befba66876deaf7cf2405b8e5de211..1b797892a977d1e6e6d73e6205852da4dc560391 100644 (file)
@@ -33,6 +33,8 @@
 #include "shadowio.h"
 #include "shadowlog.h"
 #include "string/strtcpy.h"
+#include "time/day_to_str.h"
+
 
 /*
  * exit status values
index 7f0393b657c57cecb0371840afe8d28f998d048c..63fb996d1994044b06d24302ded16d3474d7c6a2 100644 (file)
@@ -59,6 +59,7 @@
 #endif
 #include "shadowlog.h"
 #include "string/sprintf.h"
+#include "time/day_to_str.h"
 
 
 /*