Fixing the ARG macros and adding nice.

Thanks "Galos, David" <galosd83@students.rowan.edu>!
This commit is contained in:
Christoph Lohmann
2013-05-29 20:52:39 +02:00
parent f648c7fa71
commit c9aac796c8
3 changed files with 58 additions and 22 deletions

24
util.h
View File

@@ -1,5 +1,7 @@
/* See LICENSE file for copyright and license details. */
#include "arg.h"
#define UTF8_POINT(c) (((c) & 0xc0) != 0x80)
#define MIN(x,y) ((x) < (y) ? (x) : (y))
@@ -7,28 +9,6 @@
#define LEN(x) (sizeof (x) / sizeof *(x))
#define ARGBEGIN \
{ \
if(!argv0) \
argv0 = argv[0]; \
for(argc--, argv++; argv[0] && argv[0][0] == '-' && argv[0][1] != '\0'; argc--, argv++) { \
if(argv[0][1] == '-' && argv[0][2] == '\0') { /* -- signifies end of flags */ \
argc--; argv++; \
break; \
} \
for(argv[0]++; *argv[0] != '\0'; argv[0]++) \
switch(*argv[0])
#define ARGEND \
} \
}
#define ARGC() (*argv[0])
#define ARGF() (*argv[0] ? argv[0] \
: argv[1] ? (argc--, *++argv) : NULL)
#define EARGF(x) (*argv[0] ? argv[0] \
: argv[1] ? (argc--, *++argv) : ((x), abort(), NULL))
extern char *argv0;
char *agetcwd(void);