[hackers] [sbase] ed: use arg.h || Quentin Rameau

From: <git_AT_suckless.org>
Date: Wed, 16 Dec 2015 10:52:41 +0100 (CET)

commit d1bef890ea45a8aa492d0a1914c02110f982da28
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Tue Dec 15 15:45:16 2015 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Wed Dec 16 09:52:35 2015 +0000

    ed: use arg.h

diff --git a/ed.c b/ed.c
index 032bc78..bde2c55 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -13,6 +13,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "arg.h"
+
 #define REGEXSIZE 100
 #define LINESIZE 80
 #define NUMLINES 32
_AT_@ -1332,27 +1334,20 @@ sighup(int dummy)
 int
 main(int argc, char *argv[])
 {
- char *p;
+ ARGBEGIN {
+ case 'p':
+ prompt = EARGF(usage());
+ optprompt = 1;
+ break;
+ case 's':
+ optdiag = 0;
+ break;
+ default:
+ usage();
+ } ARGEND
 
- while (*++argv) {
- if (argv[0][0] != '-')
- break;
- for (p = argv[0] + 1; *p; ++p) {
- switch (*p) {
- case 's':
- optdiag = 0;
- break;
- case 'p':
- if (!*++argv)
- usage();
- prompt = *argv;
- optprompt = 1;
- break;
- default:
- usage();
- }
- }
- }
+ if (argc > 1)
+ usage();
 
         signal(SIGINT, sigintr);
         signal(SIGHUP, sighup);
Received on Wed Dec 16 2015 - 10:52:41 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 16 2015 - 11:00:25 CET