]> git.refcnt.org Git - colorize.git/commitdiff
Reuse file opening function
authorSteven Schubiger <stsc@refcnt.org>
Sun, 25 Jan 2015 15:54:10 +0000 (16:54 +0100)
committerSteven Schubiger <stsc@refcnt.org>
Sun, 25 Jan 2015 15:54:10 +0000 (16:54 +0100)
colorize.c

index 1325fce1f10326f432fa55d0edf2c5cde168dec1..cc89193ac8db8f5c70d283d704c10bd203ac7874 100644 (file)
@@ -666,7 +666,6 @@ process_file_arg (const char *file_string, const char **file, FILE **stream)
           *stream = stdin;
         else
           {
-            FILE *s;
             const char *file = file_string;
             struct stat sb;
             int ret;
@@ -680,12 +679,7 @@ process_file_arg (const char *file_string, const char **file, FILE **stream)
             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;
       }