aboutsummaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/utility.c b/utility.c
index df2515c2b..03d649757 100644
--- a/utility.c
+++ b/utility.c
@@ -1634,12 +1634,14 @@ extern void print_file(FILE *file)
1634extern int print_file_by_name(char *filename) 1634extern int print_file_by_name(char *filename)
1635{ 1635{
1636 FILE *file; 1636 FILE *file;
1637 file = fopen(filename, "r"); 1637 if ((file = wfopen(filename, "r")) == NULL)
1638 if (file == NULL) { 1638 return FALSE;
1639 print_file(file);
1640 if (errno) {
1639 errorMsg("%s: %s\n", filename, strerror(errno)); 1641 errorMsg("%s: %s\n", filename, strerror(errno));
1642 errno = 0;
1640 return FALSE; 1643 return FALSE;
1641 } 1644 }
1642 print_file(file);
1643 return TRUE; 1645 return TRUE;
1644} 1646}
1645#endif /* BB_CAT */ 1647#endif /* BB_CAT */
@@ -1719,6 +1721,18 @@ void xregcomp(regex_t *preg, const char *regex, int cflags)
1719} 1721}
1720#endif 1722#endif
1721 1723
1724#if defined BB_CAT || defined BB_HEAD
1725FILE *wfopen(const char *path, const char *mode)
1726{
1727 FILE *fp;
1728 if ((fp = fopen(path, mode)) == NULL) {
1729 errorMsg("%s: %s\n", path, strerror(errno));
1730 errno = 0;
1731 }
1732 return fp;
1733}
1734#endif
1735
1722#if defined BB_HOSTNAME || defined BB_LOADACM || defined BB_MORE || defined BB_SED || defined BB_SH || defined BB_UNIQ || defined BB_WC 1736#if defined BB_HOSTNAME || defined BB_LOADACM || defined BB_MORE || defined BB_SED || defined BB_SH || defined BB_UNIQ || defined BB_WC
1723FILE *xfopen(const char *path, const char *mode) 1737FILE *xfopen(const char *path, const char *mode)
1724{ 1738{