From ae97a89e1a1a9833080dccc81f6cd26784e1b964 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 11 Jan 2001 11:42:17 +0000 Subject: A large update from Manuel Novoa III . --- libc/unistd/getopt.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libc/unistd/getopt.c') diff --git a/libc/unistd/getopt.c b/libc/unistd/getopt.c index 83a9ad69c..a850d9bde 100644 --- a/libc/unistd/getopt.c +++ b/libc/unistd/getopt.c @@ -13,13 +13,18 @@ * and ommision of whitespace between option and arg. */ +/* + * Modified by Manuel Novoa III on 1/5/01 to use weak symbols. + * Programs needing long options will link gnu_getopt instead. + */ + #include #include -int opterr = 1; /* error => print message */ -int optind = 1; /* next argv[] index */ -int optopt = 1; /* Set for unknown arguments */ -char *optarg = NULL; /* option parameter if any */ +int opterr __attribute__ ((__weak__)) = 1; /* error => print message */ +int optind __attribute__ ((__weak__)) = 1; /* next argv[] index */ +int optopt __attribute__ ((__weak__)) = 1; /* Set for unknown arguments */ +char *optarg __attribute__ ((__weak__)) = NULL; /* option parameter if any */ static int Err(name, mess, c) /* returns '?' */ char *name; /* program name argv[0] */ @@ -34,6 +39,9 @@ int c; /* defective option letter */ return '?'; /* erroneous-option marker */ } +extern int getopt (int argc, char *const *argv, const char *optstring) + __attribute__ ((__weak__)); + int getopt (int argc, char *const *argv, const char *optstring) { static int sp = 1; /* position within argument */ -- cgit v1.2.3