Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 25445d9

Browse files
committed
Replace warnx by elog
1 parent 62860f9 commit 25445d9

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

pgut/getopt.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ struct option {
5757
int val;
5858
};
5959

60-
__BEGIN_DECLS
6160
int getopt_long(int, char * const *, const char *,
6261
const struct option *, int *);
6362
int getopt_long_only(int, char * const *, const char *,
@@ -73,6 +72,5 @@ extern int optind, opterr, optopt;
7372
#define _OPTRESET_DECLARED
7473
extern int optreset; /* getopt(3) external variable */
7574
#endif
76-
__END_DECLS
7775

7876
#endif /* !_GETOPT_H_ */

pgut/getopt_long.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,23 @@
5151

5252
#include <sys/cdefs.h>
5353

54-
#include <err.h>
5554
#include <errno.h>
5655
#include "getopt.h"
5756
#include <stdlib.h>
5857
#include <string.h>
5958

59+
#define LOG (-4)
60+
#define INFO (-3)
61+
#define NOTICE (-2)
62+
#define WARNING (-1)
63+
#define ERROR 1
64+
#define FATAL 2
65+
#define PANIC 3
66+
67+
extern void
68+
elog(int elevel, const char *fmt, ...)
69+
__attribute__((format(printf, 2, 3)));
70+
6071
#define GNU_COMPATIBLE /* Be more compatible, configure's use us! */
6172

6273

@@ -245,7 +256,7 @@ parse_long_options(char * const *nargv, const char *options,
245256
if (!exact_match && second_partial_match) {
246257
/* ambiguous abbreviation */
247258
if (PRINT_ERROR)
248-
warnx(ambig,
259+
elog(WARNING, ambig,
249260
#ifdef GNU_COMPATIBLE
250261
current_dash,
251262
#endif
@@ -258,7 +269,7 @@ parse_long_options(char * const *nargv, const char *options,
258269
if (long_options[match].has_arg == no_argument
259270
&& has_equal) {
260271
if (PRINT_ERROR)
261-
warnx(noarg,
272+
elog(WARNING, noarg,
262273
#ifdef GNU_COMPATIBLE
263274
current_dash,
264275
#endif
@@ -296,7 +307,7 @@ parse_long_options(char * const *nargv, const char *options,
296307
* should be generated.
297308
*/
298309
if (PRINT_ERROR)
299-
warnx(recargstring,
310+
elog(WARNING, recargstring,
300311
#ifdef GNU_COMPATIBLE
301312
current_dash,
302313
#endif
@@ -317,7 +328,7 @@ parse_long_options(char * const *nargv, const char *options,
317328
return (-1);
318329
}
319330
if (PRINT_ERROR)
320-
warnx(illoptstring,
331+
elog(WARNING, illoptstring,
321332
#ifdef GNU_COMPATIBLE
322333
current_dash,
323334
#endif
@@ -494,11 +505,11 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
494505
++optind;
495506
#ifdef GNU_COMPATIBLE
496507
if (PRINT_ERROR)
497-
warnx(posixly_correct ? illoptchar : gnuoptchar,
508+
elog(WARNING, posixly_correct ? illoptchar : gnuoptchar,
498509
optchar);
499510
#else
500511
if (PRINT_ERROR)
501-
warnx(illoptchar, optchar);
512+
elog(WARNING, illoptchar, optchar);
502513
#endif
503514
optopt = optchar;
504515
return (BADCH);
@@ -510,7 +521,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
510521
else if (++optind >= nargc) { /* no arg */
511522
place = EMSG;
512523
if (PRINT_ERROR)
513-
warnx(recargchar, optchar);
524+
elog(WARNING, recargchar, optchar);
514525
optopt = optchar;
515526
return (BADARG);
516527
} else /* white space */
@@ -534,7 +545,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options,
534545
if (++optind >= nargc) { /* no arg */
535546
place = EMSG;
536547
if (PRINT_ERROR)
537-
warnx(recargchar, optchar);
548+
elog(WARNING, recargchar, optchar);
538549
optopt = optchar;
539550
return (BADARG);
540551
} else

0 commit comments

Comments
 (0)