#endif
/* Return an int indicating the result of comparing two longs. */
-#ifdef INT_16_BITS
+#if SIZEOF_INT == 2
#define longdiff(a, b) ((a) < (b) ? -1 : (a) > (b) ? 1 : 0)
#else
#define longdiff(a, b) ((a) - (b))
#endif
+/* The maximum number of digits required to print an inode number
+ in an unsigned format. */
+#ifndef INODE_DIGITS
+#define INODE_DIGITS 7
+#endif
+
#ifndef STDC_HEADERS
char *ctime ();
time_t time ();
normal /* All others. */
};
-struct file
+struct fileinfo
{
/* The file name. */
char *name;
/* The table of files in the current directory:
- `files' points to a vector of `struct file', one per file.
+ `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. */
/* Address of block containing the files that are described. */
-static struct file *files;
+static struct fileinfo *files;
/* Length of block that `files' points to, measured in files. */
|| print_block_size || print_inode;
nfiles = 100;
- files = (struct file *) xmalloc (sizeof (struct file) * nfiles);
+ files = (struct fileinfo *) xmalloc (sizeof (struct fileinfo) * nfiles);
files_index = 0;
clear_files ();
if (files_index == nfiles)
{
nfiles *= 2;
- files = (struct file *) xrealloc (files, sizeof (struct file) * nfiles);
+ files = (struct fileinfo *) xrealloc (files, sizeof (*files) * nfiles);
}
files[files_index].linkname = 0;
static void
get_link_name (filename, f)
char *filename;
- struct file *f;
+ struct fileinfo *f;
{
char *linkbuf;
register int linksize;
abort ();
}
- qsort (files, files_index, sizeof (struct file), func);
+ qsort (files, files_index, sizeof (struct fileinfo), func);
}
/* Comparison routines for sorting the files. */
static int
compare_ctime (file1, file2)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_ctime, file1->stat.st_ctime);
}
static int
rev_cmp_ctime (file2, file1)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_ctime, file1->stat.st_ctime);
}
static int
compare_mtime (file1, file2)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_mtime, file1->stat.st_mtime);
}
static int
rev_cmp_mtime (file2, file1)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_mtime, file1->stat.st_mtime);
}
static int
compare_atime (file1, file2)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_atime, file1->stat.st_atime);
}
static int
rev_cmp_atime (file2, file1)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_atime, file1->stat.st_atime);
}
static int
compare_size (file1, file2)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_size, file1->stat.st_size);
}
static int
rev_cmp_size (file2, file1)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return longdiff (file2->stat.st_size, file1->stat.st_size);
}
static int
compare_name (file1, file2)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return strcmp (file1->name, file2->name);
}
static int
rev_cmp_name (file2, file1)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
return strcmp (file1->name, file2->name);
}
static int
compare_extension (file1, file2)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
register char *base1, *base2;
register int cmp;
static int
rev_cmp_extension (file2, file1)
- struct file *file1, *file2;
+ struct fileinfo *file1, *file2;
{
register char *base1, *base2;
register int cmp;
static void
print_long_format (f)
- struct file *f;
+ struct fileinfo *f;
{
char modebuf[20];
char timebuf[40];
}
if (print_inode)
- printf ("%6lu ", (unsigned long) f->stat.st_ino);
+ printf ("%*lu ", INODE_DIGITS, (unsigned long) f->stat.st_ino);
if (print_block_size)
printf ("%*u ", block_size_size,
/* The space between the mode and the number of links is the POSIX
"optional alternate access method flag". */
- printf ("%s %3u ", modebuf, f->stat.st_nlink);
+ printf ("%s %3u ", modebuf, (unsigned int) f->stat.st_nlink);
if (numeric_users)
printf ("%-8u ", (unsigned int) f->stat.st_uid);
static void
print_file_name_and_frills (f)
- struct file *f;
+ struct fileinfo *f;
{
if (print_inode)
- printf ("%6lu ", (unsigned long) f->stat.st_ino);
+ printf ("%*lu ", INODE_DIGITS, (unsigned long) f->stat.st_ino);
if (print_block_size)
printf ("%*u ", block_size_size,
static int
length_of_file_name_and_frills (f)
- struct file *f;
+ struct fileinfo *f;
{
register char *p = f->name;
register char c;
register int len = 0;
if (print_inode)
- len += 7;
+ len += INODE_DIGITS + 1;
if (print_block_size)
len += 1 + block_size_size;