getdate: correctly specify error number
authorA. Wilcox <AWilcox@Wilcox-Tech.com>
Fri, 9 Jun 2017 05:26:18 +0000 (00:26 -0500)
committerRich Felker <dalias@aerifal.cx>
Wed, 14 Jun 2017 23:50:58 +0000 (19:50 -0400)
POSIX defines getdate error #5 as:
"An I/O error is encountered while reading the template file."

POSIX defines getdate error #7 as:
"There is no line in the template that matches the input."

This change correctly disambiguates between the two error conditions.

src/time/getdate.c

index 89f2169..420cd8e 100644 (file)
@@ -37,7 +37,8 @@ struct tm *getdate(const char *s)
                }
        }
 
-       getdate_err = 7;
+       if (ferror(f)) getdate_err = 5;
+       else getdate_err = 7;
 out:
        if (f) fclose(f);
        pthread_setcancelstate(cs, 0);