summaryrefslogtreecommitdiff
path: root/src/pathchk.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-08-22 18:56:06 +0200
committerJim Meyering <meyering@redhat.com>2009-08-25 09:21:00 +0200
commit5e778f7c8d1ecf3d8f11385db013af2ba026e2a5 (patch)
treee460d471f37f0dce1ba06f60f88114d1a65326c4 /src/pathchk.c
parent2bc0f3caaafeb240cdcfd050b7ad1fe0ad14addf (diff)
downloadcoreutils-5e778f7c8d1ecf3d8f11385db013af2ba026e2a5.tar.xz
global: convert indentation-TABs to spaces
Transformed via this shell code: t=$'\t' git ls-files \ | grep -vE '(^|/)((GNU)?[Mm]akefile|ChangeLog)|\.(am|mk)$' \ | grep -vE 'tests/pr/|help2man' \ | xargs grep -lE "^ *$t" \ | xargs perl -MText::Tabs -ni -le \ '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
Diffstat (limited to 'src/pathchk.c')
-rw-r--r--src/pathchk.c256
1 files changed, 128 insertions, 128 deletions
diff --git a/src/pathchk.c b/src/pathchk.c
index 526134507..04b70a389 100644
--- a/src/pathchk.c
+++ b/src/pathchk.c
@@ -91,7 +91,7 @@ usage (int status)
{
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
- program_name);
+ program_name);
else
{
printf (_("Usage: %s [OPTION]... NAME...\n"), program_name);
@@ -128,27 +128,27 @@ main (int argc, char **argv)
while ((optc = getopt_long (argc, argv, "+pP", longopts, NULL)) != -1)
{
switch (optc)
- {
- case PORTABILITY_OPTION:
- check_basic_portability = true;
- check_extra_portability = true;
- break;
+ {
+ case PORTABILITY_OPTION:
+ check_basic_portability = true;
+ check_extra_portability = true;
+ break;
- case 'p':
- check_basic_portability = true;
- break;
+ case 'p':
+ check_basic_portability = true;
+ break;
- case 'P':
- check_extra_portability = true;
- break;
+ case 'P':
+ check_extra_portability = true;
+ break;
- case_GETOPT_HELP_CHAR;
+ case_GETOPT_HELP_CHAR;
- case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
- default:
- usage (EXIT_FAILURE);
- }
+ default:
+ usage (EXIT_FAILURE);
+ }
}
if (optind == argc)
@@ -159,7 +159,7 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
ok &= validate_file_name (argv[optind],
- check_basic_portability, check_extra_portability);
+ check_basic_portability, check_extra_portability);
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
@@ -175,9 +175,9 @@ no_leading_hyphen (char const *file)
for (p = file; (p = strchr (p, '-')); p++)
if (p == file || p[-1] == '/')
{
- error (0, 0, _("leading `-' in a component of file name %s"),
- quote (file));
- return false;
+ error (0, 0, _("leading `-' in a component of file name %s"),
+ quote (file));
+ return false;
}
return true;
@@ -190,10 +190,10 @@ static bool
portable_chars_only (char const *file, size_t filelen)
{
size_t validlen = strspn (file,
- ("/"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789._-"));
+ ("/"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789._-"));
char const *invalid = file + validlen;
if (*invalid)
@@ -201,10 +201,10 @@ portable_chars_only (char const *file, size_t filelen)
DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate);
error (0, 0,
- _("nonportable character %s in file name %s"),
- quotearg_n_style_mem (1, locale_quoting_style, invalid,
- (charlen <= MB_LEN_MAX ? charlen : 1)),
- quote_n (0, file));
+ _("nonportable character %s in file name %s"),
+ quotearg_n_style_mem (1, locale_quoting_style, invalid,
+ (charlen <= MB_LEN_MAX ? charlen : 1)),
+ quote_n (0, file));
return false;
}
@@ -254,7 +254,7 @@ component_len (char const *f)
static bool
validate_file_name (char *file, bool check_basic_portability,
- bool check_extra_portability)
+ bool check_extra_portability)
{
size_t filelen = strlen (file);
@@ -274,9 +274,9 @@ validate_file_name (char *file, bool check_basic_portability,
&& filelen == 0)
{
/* Fail, since empty names are not portable. As of
- 2005-01-06 POSIX does not address whether "pathchk -p ''"
- should (or is allowed to) fail, so this is not a
- conformance violation. */
+ 2005-01-06 POSIX does not address whether "pathchk -p ''"
+ should (or is allowed to) fail, so this is not a
+ conformance violation. */
error (0, 0, _("empty file name"));
return false;
}
@@ -284,23 +284,23 @@ validate_file_name (char *file, bool check_basic_portability,
if (check_basic_portability)
{
if (! portable_chars_only (file, filelen))
- return false;
+ return false;
}
else
{
/* Check whether a file name component is in a directory that
- is not searchable, or has some other serious problem.
- POSIX does not allow "" as a file name, but some non-POSIX
- hosts do (as an alias for "."), so allow "" if lstat does. */
+ is not searchable, or has some other serious problem.
+ POSIX does not allow "" as a file name, but some non-POSIX
+ hosts do (as an alias for "."), so allow "" if lstat does. */
struct stat st;
if (lstat (file, &st) == 0)
- file_exists = true;
+ file_exists = true;
else if (errno != ENOENT || filelen == 0)
- {
- error (0, errno, "%s", file);
- return false;
- }
+ {
+ error (0, errno, "%s", file);
+ return false;
+ }
}
if (check_basic_portability
@@ -309,31 +309,31 @@ validate_file_name (char *file, bool check_basic_portability,
size_t maxsize;
if (check_basic_portability)
- maxsize = _POSIX_PATH_MAX;
+ maxsize = _POSIX_PATH_MAX;
else
- {
- long int size;
- char const *dir = (*file == '/' ? "/" : ".");
- errno = 0;
- size = pathconf (dir, _PC_PATH_MAX);
- if (size < 0 && errno != 0)
- {
- error (0, errno,
- _("%s: unable to determine maximum file name length"),
- dir);
- return false;
- }
- maxsize = MIN (size, SSIZE_MAX);
- }
+ {
+ long int size;
+ char const *dir = (*file == '/' ? "/" : ".");
+ errno = 0;
+ size = pathconf (dir, _PC_PATH_MAX);
+ if (size < 0 && errno != 0)
+ {
+ error (0, errno,
+ _("%s: unable to determine maximum file name length"),
+ dir);
+ return false;
+ }
+ maxsize = MIN (size, SSIZE_MAX);
+ }
if (maxsize <= filelen)
- {
- unsigned long int len = filelen;
- unsigned long int maxlen = maxsize - 1;
- error (0, 0, _("limit %lu exceeded by length %lu of file name %s"),
- maxlen, len, quote (file));
- return false;
- }
+ {
+ unsigned long int len = filelen;
+ unsigned long int maxlen = maxsize - 1;
+ error (0, 0, _("limit %lu exceeded by length %lu of file name %s"),
+ maxlen, len, quote (file));
+ return false;
+ }
}
/* Check whether pathconf (..., _PC_NAME_MAX) can be avoided, i.e.,
@@ -345,17 +345,17 @@ validate_file_name (char *file, bool check_basic_portability,
if (! check_component_lengths && ! file_exists)
{
for (start = file; *(start = component_start (start)); )
- {
- size_t length = component_len (start);
+ {
+ size_t length = component_len (start);
- if (NAME_MAX_MINIMUM < length)
- {
- check_component_lengths = true;
- break;
- }
+ if (NAME_MAX_MINIMUM < length)
+ {
+ check_component_lengths = true;
+ break;
+ }
- start += length;
- }
+ start += length;
+ }
}
if (check_component_lengths)
@@ -370,61 +370,61 @@ validate_file_name (char *file, bool check_basic_portability,
size_t known_name_max = (check_basic_portability ? _POSIX_NAME_MAX : 0);
for (start = file; *(start = component_start (start)); )
- {
- size_t length;
-
- if (known_name_max)
- name_max = known_name_max;
- else
- {
- long int len;
- char const *dir = (start == file ? "." : file);
- char c = *start;
- errno = 0;
- *start = '\0';
- len = pathconf (dir, _PC_NAME_MAX);
- *start = c;
- if (0 <= len)
- name_max = MIN (len, SSIZE_MAX);
- else
- switch (errno)
- {
- case 0:
- /* There is no limit. */
- name_max = SIZE_MAX;
- break;
-
- case ENOENT:
- /* DIR does not exist; use its parent's maximum. */
- known_name_max = name_max;
- break;
-
- default:
- *start = '\0';
- error (0, errno, "%s", dir);
- *start = c;
- return false;
- }
- }
-
- length = component_len (start);
-
- if (name_max < length)
- {
- unsigned long int len = length;
- unsigned long int maxlen = name_max;
- char c = start[len];
- start[len] = '\0';
- error (0, 0,
- _("limit %lu exceeded by length %lu "
- "of file name component %s"),
- maxlen, len, quote (start));
- start[len] = c;
- return false;
- }
-
- start += length;
- }
+ {
+ size_t length;
+
+ if (known_name_max)
+ name_max = known_name_max;
+ else
+ {
+ long int len;
+ char const *dir = (start == file ? "." : file);
+ char c = *start;
+ errno = 0;
+ *start = '\0';
+ len = pathconf (dir, _PC_NAME_MAX);
+ *start = c;
+ if (0 <= len)
+ name_max = MIN (len, SSIZE_MAX);
+ else
+ switch (errno)
+ {
+ case 0:
+ /* There is no limit. */
+ name_max = SIZE_MAX;
+ break;
+
+ case ENOENT:
+ /* DIR does not exist; use its parent's maximum. */
+ known_name_max = name_max;
+ break;
+
+ default:
+ *start = '\0';
+ error (0, errno, "%s", dir);
+ *start = c;
+ return false;
+ }
+ }
+
+ length = component_len (start);
+
+ if (name_max < length)
+ {
+ unsigned long int len = length;
+ unsigned long int maxlen = name_max;
+ char c = start[len];
+ start[len] = '\0';
+ error (0, 0,
+ _("limit %lu exceeded by length %lu "
+ "of file name component %s"),
+ maxlen, len, quote (start));
+ start[len] = c;
+ return false;
+ }
+
+ start += length;
+ }
}
return true;