coreutils

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

AuthorJamozed <[email protected]>
Date2020-07-06 10:45:39
Commitee7158012a05bbc508a355030c726bc9201b7d82
Parent32c7dc05245ef2cfbcd29c75003fb41161f27a23

link: Use libokv error reporting

Diffstat

M src/link.c | 21 ++++++++++-----------

1 files changed, 10 insertions, 11 deletions

diff --git a/src/link.c b/src/link.c
index 21e071a..7049b9d 100644
--- a/src/link.c
+++ b/src/link.c
@@ -1,4 +1,4 @@
-// link.c, version 1.0.0
+// link.c, version 1.0.1
 // OMKOV coreutils implementation of POSIX link
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -33,19 +33,20 @@ 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 <string.h>
+
+#define VERSION "1.0.1"
 
 static void help(void);
 static void version(void);
 
-int main(int argc, char *argv[]) {
+int main(int ac, char *av[]) { A0 = av[0];
 	lop_t lops[] = {
 		{ "help",    ARG_NUL, 256 },
 		{ "version", ARG_NUL, 257 },
@@ -53,15 +54,15 @@ int main(int argc, char *argv[]) {
 	};
 
 	opt_t opt = OPTGET_INIT; opt.str = ""; opt.lops = lops; int o;
-	while ((o = optget(&opt, argv, 1)) != -1) switch (o) {
+	while ((o = optget(&opt, av, 1)) != -1) switch (o) {
 	case 256: { help(); return 0; }
 	case 257: { version(); return 0; }
 	default: { return 1; }
 	}
 
-	if (argc <= 2) { error(1, "%s: missing operand", argv[0]); }
+	if (ac <= 2) { error(1, "missing operand"); }
 
-	if (link(argv[1], argv[2])) { error(1, "%s: %s", argv[0], serrno); }
+	if (link(av[1], av[2])) { error(1, "%s: %s", av[1], serr()); }
 
 	return 0;
 }
@@ -76,7 +77,7 @@ static void help(void) {
 }
 
 static void version(void) {
-	puts("OMKOV coreutils link, version 1.0.0");
+	puts("OMKOV coreutils link, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");
 	puts("All rights reserved.");
 	puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");