shithub: npe

Download patch

ref: 8acdd715b95e8db6822e3d865c93a07ef9a6c266
parent: 537d4c5c119be15eec734bc443074a8d90b9c202
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Aug 18 20:22:37 EDT 2023

npe: add strerror_r

--- a/include/npe/string.h
+++ b/include/npe/string.h
@@ -3,6 +3,7 @@
 
 #include <npe.h>
 
-char *strerror(int);
+char *strerror(int errnum);
+int strerror_r(int errnum, char *buf, size_t buflen);
 
 #endif
--- a/include/npe/unistd.h
+++ b/include/npe/unistd.h
@@ -57,4 +57,8 @@
 void usleep(useconds_t us);
 int isatty(int fd);
 
+int getopt(int argc, char *argv[], char *optstring);
+extern char *optarg;
+extern int optind, opterr, optopt;
+
 #endif
--- a/libnpe/mkfile
+++ b/libnpe/mkfile
@@ -7,10 +7,12 @@
 	_iconv.h\
 	_dirent.h\
 	_npe.h\
+	_parg.h\
 
 OFILES=\
 	_main.$O\
 	_npe.$O\
+	_parg.$O\
 	acosh.$O\
 	basename.$O\
 	cbrtf.$O\
@@ -19,6 +21,8 @@
 	dirname.$O\
 	div.$O\
 	fstat.$O\
+	getopt.$O\
+	getopt_long.$O\
 	exp2.$O\
 	fmax.$O\
 	fstatat.$O\
@@ -56,6 +60,7 @@
 	sigemptyset.$O\
 	stat.$O\
 	strerror.$O\
+	strerror_r.$O\
 	strftime.$O\
 	trunc.$O\
 	unlink.$O\
--- /dev/null
+++ b/libnpe/strerror_r.c
@@ -1,0 +1,9 @@
+#include <string.h>
+
+int
+strerror_r(int errnum, char *buf, size_t buflen)
+{
+	USED(errnum);
+	rerrstr(buf, buflen);
+	return 0;
+}