Skip to content

Commit

Permalink
lib/string/strftime.[ch]: STRFTIME(): Add macro
Browse files Browse the repository at this point in the history
This macro makes sure that the first argument is an array, and
calculates its size.

Reviewed-by: "Serge E. Hallyn" <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Mar 23, 2024
1 parent 0b3d017 commit b3affb2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ libshadow_la_SOURCES = \
string/stpecpy.h \
string/stpeprintf.c \
string/stpeprintf.h \
string/strftime.c \
string/strftime.h \
string/strncpy.h \
string/strtcpy.c \
string/strtcpy.h \
Expand Down
7 changes: 7 additions & 0 deletions lib/string/strftime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause


#include <config.h>

#include "strftime.h"
19 changes: 19 additions & 0 deletions lib/string/strftime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause


#ifndef SHADOW_INCLUDE_LIB_STRFTIME_H_
#define SHADOW_INCLUDE_LIB_STRFTIME_H_


#include <config.h>

#include <time.h>

#include "sizeof.h"


#define STRFTIME(dst, fmt, ...) strftime(dst, NITEMS(dst), fmt, __VA_ARGS__)


#endif // include guard

0 comments on commit b3affb2

Please sign in to comment.