| [3444] | 1 | /* argmatch.c -- find a match for a string in an array
|
|---|
| 2 |
|
|---|
| 3 | Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003 Free Software
|
|---|
| 4 | Foundation, Inc.
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program; if not, write to the Free Software Foundation,
|
|---|
| 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 19 |
|
|---|
| 20 | /* Written by David MacKenzie <[email protected]>
|
|---|
| 21 | Modified by Akim Demaille <[email protected]> */
|
|---|
| 22 |
|
|---|
| 23 | #if HAVE_CONFIG_H
|
|---|
| 24 | # include <config.h>
|
|---|
| 25 | #endif
|
|---|
| 26 |
|
|---|
| 27 | /* Specification. */
|
|---|
| 28 | #include "argmatch.h"
|
|---|
| 29 |
|
|---|
| 30 | #include <stdio.h>
|
|---|
| 31 | #include <stdlib.h>
|
|---|
| 32 | #include <string.h>
|
|---|
| 33 |
|
|---|
| 34 | #include "gettext.h"
|
|---|
| 35 | #define _(msgid) gettext (msgid)
|
|---|
| 36 |
|
|---|
| 37 | #include "error.h"
|
|---|
| 38 | #include "quotearg.h"
|
|---|
| 39 | #include "quote.h"
|
|---|
| 40 | #include "unlocked-io.h"
|
|---|
| 41 |
|
|---|
| 42 | /* When reporting an invalid argument, show nonprinting characters
|
|---|
| 43 | by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
|---|
| 44 | literal_quoting_style. */
|
|---|
| 45 | #ifndef ARGMATCH_QUOTING_STYLE
|
|---|
| 46 | # define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
|---|
| 47 | #endif
|
|---|
| 48 |
|
|---|
| 49 | #ifndef EXIT_FAILURE
|
|---|
| 50 | # define EXIT_FAILURE 1
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 | /* Non failing version of argmatch call this function after failing. */
|
|---|
| 54 | #ifndef ARGMATCH_DIE
|
|---|
| 55 | # define ARGMATCH_DIE exit (EXIT_FAILURE)
|
|---|
| 56 | #endif
|
|---|
| 57 |
|
|---|
| 58 | #ifdef ARGMATCH_DIE_DECL
|
|---|
| 59 | ARGMATCH_DIE_DECL;
|
|---|
| 60 | #endif
|
|---|
| 61 |
|
|---|
| 62 | static void
|
|---|
| 63 | __argmatch_die (void)
|
|---|
| 64 | {
|
|---|
| 65 | ARGMATCH_DIE;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | /* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
|---|
| 69 | Default to __argmatch_die, but allow caller to change this at run-time. */
|
|---|
| 70 | argmatch_exit_fn argmatch_die = __argmatch_die;
|
|---|
| |
|---|