summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-01-29 14:06:45 +0100
committerJim Meyering <jim@meyering.net>2007-01-29 14:06:45 +0100
commite4eaba04dda577c401a07df0a56db2b03c809ee2 (patch)
treeeb1204690307e94963a38075b7cb4e49f1ce410e /src
parentfc9b328ab4c4c6315179fd6cdf54cfdb823c9222 (diff)
downloadcoreutils-e4eaba04dda577c401a07df0a56db2b03c809ee2.tar.xz
* src/ls.c: Rename three global variables.
(cwd_file): Rename from 'files'. (cwd_n_alloc): Rename from 'nfiles'. (cwd_n_used): Rename from 'files_index'.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/ls.c b/src/ls.c
index fa9a2fad1..4a6d7c1fb 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -268,18 +268,18 @@ static Hash_table *active_dir_set;
/* The table of files in the current directory:
- `files' points to a vector of `struct fileinfo', one per file.
- `nfiles' is the number of elements space has been allocated for.
- `files_index' is the number actually in use. */
+ `cwd_file' points to a vector of `struct fileinfo', one per file.
+ `cwd_n_alloc' is the number of elements space has been allocated for.
+ `cwd_n_used' is the number actually in use. */
/* Address of block containing the files that are described. */
-static struct fileinfo *files; /* FIXME: rename this to e.g. cwd_file */
+static struct fileinfo *cwd_file;
-/* Length of block that `files' points to, measured in files. */
-static size_t nfiles; /* FIXME: rename this to e.g. cwd_n_alloc */
+/* Length of block that `cwd_file' points to, measured in files. */
+static size_t cwd_n_alloc;
-/* Index of first unused in `files'. */
-static size_t files_index; /* FIXME: rename this to e.g. cwd_n_used */
+/* Index of first unused slot in `cwd_file'. */
+static size_t cwd_n_used;
/* Vector of pointers to files, in proper sorted order, and the number
of entries allocated for it. */
@@ -1259,9 +1259,9 @@ main (int argc, char **argv)
obstack_init (&subdired_obstack);
}
- nfiles = 100;
- files = xnmalloc (nfiles, sizeof *files);
- files_index = 0;
+ cwd_n_alloc = 100;
+ cwd_file = xnmalloc (cwd_n_alloc, sizeof *cwd_file);
+ cwd_n_used = 0;
clear_files ();
@@ -1279,19 +1279,19 @@ main (int argc, char **argv)
gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, "");
while (i < argc);
- if (files_index)
+ if (cwd_n_used)
{
sort_files ();
if (!immediate_dirs)
extract_dirs_from_files (NULL, true);
- /* `files_index' might be zero now. */
+ /* `cwd_n_used' might be zero now. */
}
/* In the following if/else blocks, it is sufficient to test `pending_dirs'
(and not pending_dirs->name) because there may be no markers in the queue
at this point. A marker may be enqueued when extract_dirs_from_files is
called with a non-empty string or via print_dir. */
- if (files_index)
+ if (cwd_n_used)
{
print_current_files ();
if (pending_dirs)
@@ -2357,7 +2357,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
}
- /* Read the directory entries, and insert the subfiles into the `files'
+ /* Read the directory entries, and insert the subfiles into the `cwd_file'
table. */
clear_files ();
@@ -2446,7 +2446,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
DIRED_PUTCHAR ('\n');
}
- if (files_index)
+ if (cwd_n_used)
print_current_files ();
}
@@ -2500,7 +2500,7 @@ unsigned_file_size (off_t size)
return size + (size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
}
-/* Enter and remove entries in the table `files'. */
+/* Enter and remove entries in the table `cwd_file'. */
/* Empty the table of files. */
@@ -2509,14 +2509,14 @@ clear_files (void)
{
size_t i;
- for (i = 0; i < files_index; i++)
+ for (i = 0; i < cwd_n_used; i++)
{
struct fileinfo *f = sorted_file[i];
free (f->name);
free (f->linkname);
}
- files_index = 0;
+ cwd_n_used = 0;
#if USE_ACL
any_has_acl = false;
#endif
@@ -2546,13 +2546,13 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
which is not used for command line arguments. */
assert (! command_line_arg || inode == NOT_AN_INODE_NUMBER);
- if (files_index == nfiles)
+ if (cwd_n_used == cwd_n_alloc)
{
- files = xnrealloc (files, nfiles, 2 * sizeof *files);
- nfiles *= 2;
+ cwd_file = xnrealloc (cwd_file, cwd_n_alloc, 2 * sizeof *cwd_file);
+ cwd_n_alloc *= 2;
}
- f = &files[files_index];
+ f = &cwd_file[cwd_n_used];
memset (f, '\0', sizeof *f);
f->stat.st_ino = inode;
f->filetype = type;
@@ -2644,7 +2644,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
return 0;
f->name = xstrdup (name);
- files_index++;
+ cwd_n_used++;
return 0;
}
@@ -2777,7 +2777,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
}
f->name = xstrdup (name);
- files_index++;
+ cwd_n_used++;
return blocks;
}
@@ -2842,7 +2842,7 @@ basename_is_dot_or_dotdot (const char *name)
return dot_or_dotdot (base);
}
-/* Remove any entries from FILES that are for directories,
+/* Remove any entries from CWD_FILE that are for directories,
and queue them to be listed as directories instead.
DIRNAME is the prefix to prepend to each dirname
to make it correct relative to ls's working dir;
@@ -2867,7 +2867,7 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg)
/* Queue the directories last one first, because queueing reverses the
order. */
- for (i = files_index; i-- != 0; )
+ for (i = cwd_n_used; i-- != 0; )
{
struct fileinfo *f = sorted_file[i];
@@ -2891,13 +2891,13 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg)
/* Now delete the directories from the table, compacting all the remaining
entries. */
- for (i = 0, j = 0; i < files_index; i++)
+ for (i = 0, j = 0; i < cwd_n_used; i++)
{
struct fileinfo *f = sorted_file[i];
sorted_file[j] = f;
j += (f->filetype != arg_directory);
}
- files_index = j;
+ cwd_n_used = j;
}
/* Use strcoll to compare strings in this locale. If an error occurs,
@@ -3119,14 +3119,14 @@ static qsortFunc sort_functions[][2][2][2] =
verify (ARRAY_CARDINALITY (sort_functions)
== sort_numtypes + time_numtypes - 1 );
-/* Set up SORTED_FILE to point to the in-use entries in FILES, in order. */
+/* Set up SORTED_FILE to point to the in-use entries in CWD_FILE, in order. */
static void
initialize_ordering_vector (void)
{
size_t i;
- for (i = 0; i < files_index; i++)
- sorted_file[i] = &files[i];
+ for (i = 0; i < cwd_n_used; i++)
+ sorted_file[i] = &cwd_file[i];
}
/* Sort the files now in the table. */
@@ -3136,11 +3136,11 @@ sort_files (void)
{
bool use_strcmp;
- if (sorted_file_alloc < files_index + files_index / 2)
+ if (sorted_file_alloc < cwd_n_used + cwd_n_used / 2)
{
free (sorted_file);
- sorted_file = xnmalloc (files_index, 3 * sizeof *sorted_file);
- sorted_file_alloc = 3 * files_index;
+ sorted_file = xnmalloc (cwd_n_used, 3 * sizeof *sorted_file);
+ sorted_file_alloc = 3 * cwd_n_used;
}
initialize_ordering_vector ();
@@ -3163,7 +3163,7 @@ sort_files (void)
}
/* When sort_type == sort_time, use time_type as subindex. */
- mpsort ((void const **) sorted_file, files_index,
+ mpsort ((void const **) sorted_file, cwd_n_used,
sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)]
[use_strcmp][sort_reverse]
[directories_first]);
@@ -3179,7 +3179,7 @@ print_current_files (void)
switch (format)
{
case one_per_line:
- for (i = 0; i < files_index; i++)
+ for (i = 0; i < cwd_n_used; i++)
{
print_file_name_and_frills (sorted_file[i]);
putchar ('\n');
@@ -3199,7 +3199,7 @@ print_current_files (void)
break;
case long_format:
- for (i = 0; i < files_index; i++)
+ for (i = 0; i < cwd_n_used; i++)
{
print_long_format (sorted_file[i]);
DIRED_PUTCHAR ('\n');
@@ -3994,7 +3994,7 @@ print_many_per_line (void)
/* Calculate the number of rows that will be in each column except possibly
for a short column on the right. */
- size_t rows = files_index / cols + (files_index % cols != 0);
+ size_t rows = cwd_n_used / cols + (cwd_n_used % cols != 0);
for (row = 0; row < rows; row++)
{
@@ -4011,7 +4011,7 @@ print_many_per_line (void)
print_file_name_and_frills (f);
filesno += rows;
- if (filesno >= files_index)
+ if (filesno >= cwd_n_used)
break;
indent (pos + name_length, pos + max_name_length);
@@ -4028,14 +4028,14 @@ print_horizontal (void)
size_t pos = 0;
size_t cols = calculate_columns (false);
struct column_info const *line_fmt = &column_info[cols - 1];
- size_t name_length = length_of_file_name_and_frills (files);
+ size_t name_length = length_of_file_name_and_frills (cwd_file);
size_t max_name_length = line_fmt->col_arr[0];
/* Print first entry. */
- print_file_name_and_frills (files);
+ print_file_name_and_frills (cwd_file);
/* Now the rest. */
- for (filesno = 1; filesno < files_index; ++filesno)
+ for (filesno = 1; filesno < cwd_n_used; ++filesno)
{
struct fileinfo const *f;
size_t col = filesno % cols;
@@ -4066,7 +4066,7 @@ print_with_commas (void)
size_t filesno;
size_t pos = 0;
- for (filesno = 0; filesno < files_index; filesno++)
+ for (filesno = 0; filesno < cwd_n_used; filesno++)
{
struct fileinfo const *f = sorted_file[filesno];
size_t len = length_of_file_name_and_frills (f);
@@ -4148,7 +4148,7 @@ static void
init_column_info (void)
{
size_t i;
- size_t max_cols = MIN (max_idx, files_index);
+ size_t max_cols = MIN (max_idx, cwd_n_used);
/* Currently allocated columns in column_info. */
static size_t column_info_alloc;
@@ -4215,18 +4215,18 @@ init_column_info (void)
static size_t
calculate_columns (bool by_columns)
{
- size_t filesno; /* Index into files. */
+ size_t filesno; /* Index into cwd_file. */
size_t cols; /* Number of files across. */
/* Normally the maximum number of columns is determined by the
screen width. But if few files are available this might limit it
as well. */
- size_t max_cols = MIN (max_idx, files_index);
+ size_t max_cols = MIN (max_idx, cwd_n_used);
init_column_info ();
/* Compute the maximum number of possible columns. */
- for (filesno = 0; filesno < files_index; ++filesno)
+ for (filesno = 0; filesno < cwd_n_used; ++filesno)
{
struct fileinfo const *f = sorted_file[filesno];
size_t name_length = length_of_file_name_and_frills (f);
@@ -4237,7 +4237,7 @@ calculate_columns (bool by_columns)
if (column_info[i].valid_len)
{
size_t idx = (by_columns
- ? filesno / ((files_index + i) / (i + 1))
+ ? filesno / ((cwd_n_used + i) / (i + 1))
: filesno % (i + 1));
size_t real_length = name_length + (idx == i ? 0 : 2);