coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-06 11:16:54
Commitecf4694c1114f3191f19a33f595cfe17267e95de
Parent4540c2aed6d37e6f8391b3eb4c9b3cf1db0d32af

pwd: Use libokv error reporting

Diffstat

M src/pwd.c | 20 ++++++++++----------

1 files changed, 10 insertions, 10 deletions

diff --git a/src/pwd.c b/src/pwd.c
index f53e81e..333c682 100644
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -1,4 +1,4 @@
-// pwd.c, version 1.0.0
+// pwd.c, version 1.0.1
 // OMKOV coreutils implementation of POSIX pwd
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -33,22 +33,23 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 */
 
-#include "error.h"
 #include "optget.h"
 
+#include <error.h>
+
 #include <unistd.h>
 
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
+
+#define VERSION "1.0.1"
 
 static int mode = 0;
 
 static void help(void);
 static void version(void);
 
-int main(int argc, char *argv[]) { (void)(argc);
+int main(int ac, char *av[]) { A0 = av[0];
 	lop_t lops[] = {
 		{ "help",    ARG_NUL, 256 },
 		{ "version", ARG_NUL, 257 },
@@ -56,7 +57,7 @@ int main(int argc, char *argv[]) { (void)(argc);
 	};
 
 	opt_t opt = OPTGET_INIT; opt.str = "LP"; opt.lops = lops; int o;
-	while ((o = optget(&opt, argv, 1)) != -1) switch (o) {
+	while ((o = optget(&opt, av, 1)) != -1) switch (o) {
 	case 'L': { mode = 0; break; }
 	case 'P': { mode = 1; break; }
 	case 256: { help(); return 0; }
@@ -67,7 +68,7 @@ int main(int argc, char *argv[]) { (void)(argc);
 pwd:;
 	char *cwd = mode ? getcwd(NULL, 0) : getenv("PWD");
 	if (!cwd && !mode) { mode = 1; goto pwd; }
-	else if (!cwd) { error(1, "%s: %s", argv[0], serrno); }
+	else if (!cwd) { error(1, "%s", av[0]); }
 
 	fputs(cwd, stdout); fputc('\n', stdout);
 
@@ -86,7 +87,7 @@ static void help(void) {
 }
 
 static void version(void) {
-	puts("OMKOV coreutils pwd, version 1.0.0");
+	puts("OMKOV coreutils pwd, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");
 	puts("All rights reserved.");
 	puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");