aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjozan <jozan@noemail.net>2020-11-05 21:17:14 +0000
committerjozan <jozan@noemail.net>2020-11-05 21:17:14 +0000
commit3eb14b975e277c0094be80a0e62c8de42bb80f31 (patch)
tree6fce717f638257af249fca5c373299d1edeaf13a
parentCorrectly parsed file names (diff)
downloadunixize-3eb14b975e277c0094be80a0e62c8de42bb80f31.tar.gz
unixize-3eb14b975e277c0094be80a0e62c8de42bb80f31.tar.bz2
unixize-3eb14b975e277c0094be80a0e62c8de42bb80f31.tar.xz
unixize-3eb14b975e277c0094be80a0e62c8de42bb80f31.tar.zst
unixize-3eb14b975e277c0094be80a0e62c8de42bb80f31.zip
Cleaner
FossilOrigin-Name: 03d9d3326460b4854e1c9bf6335c6fefcf4925bd1c0d13c2e1822c74fd6e8964
-rw-r--r--src/c_lfiles.c18
-rw-r--r--src/c_unixize.c7
-rw-r--r--src/u_utils.c14
-rw-r--r--src/u_utils.h1
4 files changed, 20 insertions, 20 deletions
diff --git a/src/c_lfiles.c b/src/c_lfiles.c
index f39c330..c39cd02 100644
--- a/src/c_lfiles.c
+++ b/src/c_lfiles.c
@@ -138,30 +138,18 @@ c_lfiles_gather(void)
head = NULL;
link = NULL;
if (getcwd(path, MAXPATHLEN) == NULL) {
- dprintf(
- STDERR_FILENO,
- "unixize: %s\n",
- strerror(errno)
- );
+ u_dump_errno();
return (NULL);
}
dirp = opendir(path);
if (dirp == NULL) {
- dprintf(
- STDERR_FILENO,
- "unixize: %s\n",
- strerror(errno)
- );
+ u_dump_errno();
return (NULL);
}
while ((dp = readdir(dirp)) != NULL) {
link = c_lfiles_new(dp->d_name, dp->d_type);
if (link == NULL) {
- dprintf(
- STDERR_FILENO,
- "unixize: %s\n",
- strerror(errno)
- );
+ u_dump_errno();
c_lfiles_clear(&link);
return (NULL);
}
diff --git a/src/c_unixize.c b/src/c_unixize.c
index 85f020f..31bae1b 100644
--- a/src/c_unixize.c
+++ b/src/c_unixize.c
@@ -53,6 +53,7 @@
#include "c_lfiles.h"
#include "c_opts.h"
+#include "u_utils.h"
int
main
@@ -65,11 +66,7 @@ main
c_get_opts(&opts, argc, argv);
if (chdir((const char*)opts.dir) == -1) {
- dprintf(
- STDERR_FILENO,
- "unixize: %s\n",
- strerror(errno)
- );
+ u_dump_err();
return (1);
}
og_files = c_lfiles_gather();
diff --git a/src/u_utils.c b/src/u_utils.c
index cfaec25..13cb245 100644
--- a/src/u_utils.c
+++ b/src/u_utils.c
@@ -43,7 +43,11 @@
* 2020-11-05 19:27
*/
+#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
void
u_memdel(void** ptr)
@@ -51,3 +55,13 @@ u_memdel(void** ptr)
free(*ptr);
*ptr = NULL;
}
+
+void
+u_dump_errno(void)
+{
+ dprintf(
+ STDERR_FILENO,
+ "unixize: %s\n",
+ strerror(errno)
+ );
+}
diff --git a/src/u_utils.h b/src/u_utils.h
index b95fa86..a4568a8 100644
--- a/src/u_utils.h
+++ b/src/u_utils.h
@@ -44,3 +44,4 @@
*/
void u_memdel(void**);
+void u_dump_errno(void);