aboutsummaryrefslogtreecommitdiffstats
path: root/man/man3/newlocale.3
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2025-08-19 17:48:50 +0200
committerAlejandro Colomar <alx@kernel.org>2025-08-20 18:14:03 +0200
commit0e7a39804a3c017a209117fc2243c6cbb543dede (patch)
tree91e0b287d8b826d668c3d8118347f07cc8b8964a /man/man3/newlocale.3
parente2d3f14fe40ad90a1fedf0fcd27e6cc896c49a7a (diff)
downloadman-pages-0e7a39804a3c.tar.gz
man/: EXAMPLES: Use err(3) and errc(3bsd) instead of similar macros
These functions are quite portable. And if one doesn't have them for some reason (but libbsd has been ported to many systems), one can write them easily as macros, anyway. Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man/man3/newlocale.3')
-rw-r--r--man/man3/newlocale.312
1 files changed, 5 insertions, 7 deletions
diff --git a/man/man3/newlocale.3 b/man/man3/newlocale.3
index de23c96a58..fbf8a1d4d9 100644
--- a/man/man3/newlocale.3
+++ b/man/man3/newlocale.3
@@ -275,14 +275,12 @@ Te Paraire, te 07 o Poutū\-te\-rangi, 2014 00:38:44 CET
.\" SRC BEGIN (newlocale.c)
.EX
#define _XOPEN_SOURCE 700
+#include <err.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
\&
-#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \[rs]
- } while (0)
-\&
int
main(int argc, char *argv[])
{
@@ -302,7 +300,7 @@ main(int argc, char *argv[])
\&
loc = newlocale(LC_NUMERIC_MASK, argv[1], (locale_t) 0);
if (loc == (locale_t) 0)
- errExit("newlocale");
+ err(EXIT_FAILURE, "newlocale");
\&
/* If a second command\-line argument was specified, modify the
locale object to take the LC_TIME settings from the locale
@@ -313,7 +311,7 @@ main(int argc, char *argv[])
if (argc > 2) {
nloc = newlocale(LC_TIME_MASK, argv[2], loc);
if (nloc == (locale_t) 0)
- errExit("newlocale");
+ err(EXIT_FAILURE, "newlocale");
loc = nloc;
}
\&
@@ -330,11 +328,11 @@ main(int argc, char *argv[])
t = time(NULL);
tm = localtime(&t);
if (tm == NULL)
- errExit("time");
+ err(EXIT_FAILURE, "time");
\&
s = strftime(buf, sizeof(buf), "%c", tm);
if (s == 0)
- errExit("strftime");
+ err(EXIT_FAILURE, "strftime");
\&
printf("%s\[rs]n", buf);
\&