-
- assert (color_names[FOREGROUND]);
-
- if (color_names[BACKGROUND])
- {
- unsigned int i;
- unsigned int color_sets[2][2] = { { FOREGROUND, BACKGROUND }, { BACKGROUND, FOREGROUND } };
- for (i = 0; i < 2; i++)
- {
- unsigned int color1 = color_sets[i][0];
- unsigned int color2 = color_sets[i][1];
- if (CHECK_COLORS_RANDOM (color1, color2))
- vfprintf_fail (formats[FMT_RANDOM], tables[color1].desc, color_names[color1]->orig, "cannot be combined with", color_names[color2]->orig);
- }
- }
-
- find_color_entries (color_names, colors);
- free_color_names (color_names);
-
- if (!colors[FOREGROUND]->code && colors[BACKGROUND] && colors[BACKGROUND]->code)
- {
- struct color_name color_name;
- color_name.name = color_name.orig = "default";
-
- find_color_entry (&color_name, FOREGROUND, colors);
- }
-
- process_file_arg (file_string, file, stream);
-}
-
-static void
-process_file_arg (const char *file_string, const char **file, FILE **stream)
-{
- if (file_string)
- {
- if (streq (file_string, "-"))
- *stream = stdin;
- else
- {
- FILE *s;
- const char *file = file_string;
- struct stat sb;
- int errno, ret;
-
- errno = 0;
- ret = lstat (file, &sb);
-
- if (ret == -1)
- vfprintf_fail (formats[FMT_FILE], file, strerror (errno));
-
- if (!VALID_FILE_TYPE (sb.st_mode))
- vfprintf_fail (formats[FMT_TYPE], file, "unrecognized type", get_file_type (sb.st_mode));
-
- errno = 0;
-
- s = fopen (file, "r");
- if (!s)
- vfprintf_fail (formats[FMT_FILE], file, strerror (errno));
- *stream = s;
- }
- *file = file_string;
- }
- else
- {
- *stream = stdin;
- *file = "stdin";
- }
-
- assert (*stream);
- assert (*file);