$NetBSD: patch-ak,v 1.3 2006/08/06 23:10:30 wiz Exp $ --- src/mkid.c.orig 2006-07-22 03:38:03.000000000 +0000 +++ src/mkid.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -40,8 +39,6 @@ #include "scanners.h" #include "iduglobal.h" -char* dirname(char* path); - struct summary { struct token **sum_tokens; @@ -381,11 +378,21 @@ assert_writeable (char const *filename) { if (errno == ENOENT) { - char *dirname = dir_name (filename); - if (access (dirname, 06) < 0) - error (1, errno, _("can't create `%s' in `%s'"), - base_name (filename), dirname); - free(dirname); + char *dir_copy, *dir_name = strrchr (filename, '/'); + if (dir_name) + { + while (*--dir_name == '/') + continue; + dir_name++; + dir_copy = strdup(filename); + dir_copy[dir_name - filename] = '\0'; + } + else + dir_copy = strdup("."); + if (access (dir_copy, 06) < 0) + error (1, errno, _("can't create `%s' in `%s'"), + base_name (filename), dir_copy); + free(dir_copy); } else error (1, errno, _("can't modify `%s'"), filename); @@ -459,7 +466,7 @@ scan_member_file (struct member_file con source_FILE = fopen (flink->fl_name, "r"); if (source_FILE) { - char *file_name = alloca (PATH_MAX); + char file_name[PATH_MAX]; if (statistics_flag) { if (fstat (fileno (source_FILE), &st) < 0)