projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
canonicalize: fix C89 compilation
[gnulib.git]
/
lib
/
rpmatch.c
diff --git
a/lib/rpmatch.c
b/lib/rpmatch.c
index
68c7442
..
f065036
100644
(file)
--- a/
lib/rpmatch.c
+++ b/
lib/rpmatch.c
@@
-1,7
+1,7
@@
/* Determine whether string value is affirmation or negative response
according to current locale's data.
/* Determine whether string value is affirmation or negative response
according to current locale's data.
- Copyright (C) 1996, 1998, 2000, 2002
, 2003, 2006-2008
Free Software
+ Copyright (C) 1996, 1998, 2000, 2002
-2003, 2006-2012
Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@
-19,9
+19,11
@@
#include <config.h>
#include <config.h>
+/* Specification. */
+#include <stdlib.h>
+
#include <stdbool.h>
#include <stddef.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdlib.h>
#if ENABLE_NLS
# include <sys/types.h>
#if ENABLE_NLS
# include <sys/types.h>
@@
-41,7
+43,7
@@
The resulting string may only be used until the next nl_langinfo call. */
static const char *
localized_pattern (const char *english_pattern, nl_item nl_index,
The resulting string may only be used until the next nl_langinfo call. */
static const char *
localized_pattern (const char *english_pattern, nl_item nl_index,
- bool posixly_correct)
+
bool posixly_correct)
{
const char *translated_pattern;
{
const char *translated_pattern;
@@
-63,7
+65,7
@@
localized_pattern (const char *english_pattern, nl_item nl_index,
translated_pattern = nl_langinfo (nl_index);
/* Check against a broken system return value. */
if (translated_pattern != NULL && translated_pattern[0] != '\0')
translated_pattern = nl_langinfo (nl_index);
/* Check against a broken system return value. */
if (translated_pattern != NULL && translated_pattern[0] != '\0')
- return translated_pattern;
+
return translated_pattern;
}
/* Look in the gnulib message catalog. */
}
/* Look in the gnulib message catalog. */
@@
-71,11
+73,11
@@
localized_pattern (const char *english_pattern, nl_item nl_index,
if (translated_pattern == english_pattern)
{
/* The gnulib message catalog provides no translation.
if (translated_pattern == english_pattern)
{
/* The gnulib message catalog provides no translation.
- Try the system's message catalog. */
+
Try the system's message catalog. */
translated_pattern = nl_langinfo (nl_index);
/* Check against a broken system return value. */
if (translated_pattern != NULL && translated_pattern[0] != '\0')
translated_pattern = nl_langinfo (nl_index);
/* Check against a broken system return value. */
if (translated_pattern != NULL && translated_pattern[0] != '\0')
- return translated_pattern;
+
return translated_pattern;
/* Fall back to English. */
translated_pattern = english_pattern;
}
/* Fall back to English. */
translated_pattern = english_pattern;
}
@@
-95,20
+97,20
@@
try (const char *response, const char *pattern, char **lastp, regex_t *re)
/* The pattern has changed. */
if (*lastp != NULL)
/* The pattern has changed. */
if (*lastp != NULL)
- {
- /* Free the old compiled pattern. */
- regfree (re);
- free (*lastp);
- *lastp = NULL;
- }
+
{
+
/* Free the old compiled pattern. */
+
regfree (re);
+
free (*lastp);
+
*lastp = NULL;
+
}
/* Put the PATTERN into safe memory before calling regcomp.
/* Put the PATTERN into safe memory before calling regcomp.
- (regcomp may call nl_langinfo, overwriting PATTERN's storage. */
+
(regcomp may call nl_langinfo, overwriting PATTERN's storage. */
safe_pattern = strdup (pattern);
if (safe_pattern == NULL)
safe_pattern = strdup (pattern);
if (safe_pattern == NULL)
- return -1;
+
return -1;
/* Compile the pattern and cache it for future runs. */
if (regcomp (re, safe_pattern, REG_EXTENDED) != 0)
/* Compile the pattern and cache it for future runs. */
if (regcomp (re, safe_pattern, REG_EXTENDED) != 0)
- return -1;
+
return -1;
*lastp = safe_pattern;
}
*lastp = safe_pattern;
}
@@
-118,9
+120,6
@@
try (const char *response, const char *pattern, char **lastp, regex_t *re)
#endif
#endif
-/* Test a user response to a question.
- Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
-
int
rpmatch (const char *response)
{
int
rpmatch (const char *response)
{
@@
-169,6
+168,6
@@
rpmatch (const char *response)
#else
/* Test against "^[yY]" and "^[nN]", hardcoded to avoid requiring regex */
return (*response == 'y' || *response == 'Y' ? 1
#else
/* Test against "^[yY]" and "^[nN]", hardcoded to avoid requiring regex */
return (*response == 'y' || *response == 'Y' ? 1
- : *response == 'n' || *response == 'N' ? 0 : -1);
+
: *response == 'n' || *response == 'N' ? 0 : -1);
#endif
}
#endif
}