* colorize - Read text from standard input stream or file and print
* it colorized through use of ANSI escape sequences
*
- * Copyright (c) 2011-2014 Steven Schubiger
+ * Copyright (c) 2011-2015 Steven Schubiger
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define DEBUG_FILE "debug.txt"
-#define VERSION "0.54"
+#define VERSION "0.55"
typedef enum { false, true } bool;
break;
case BACKGROUND:
vfprintf_fail (formats[FMT_COLOR], tables[BACKGROUND].desc, color, "cannot be bold");
- break;
default: /* never reached */
ABORT_TRACE ();
}
*stream = stdin;
else
{
- FILE *s;
const char *file = file_string;
struct stat sb;
int ret;
errno = 0;
- ret = lstat (file, &sb);
+ ret = stat (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;
+ *stream = open_file (file, "r");
}
*file = file_string;
}