summaryrefslogtreecommitdiff
path: root/devel/id-utils/patches/patch-ak
blob: e4b211313f9a9b136c98e3bc86b123d3f97b9528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$NetBSD: patch-ak,v 1.2 2002/06/21 12:26:32 lukem Exp $

--- src/mkid.c.orig	Tue Jul  9 14:19:09 1996
+++ src/mkid.c
@@ -33,7 +33,6 @@
 #include "hash.h"
 #include "scanners.h"
 #include "error.h"
-#include "xalloca.h"
 #if HAVE_LIMITS_H
 # include <limits.h>
 #endif
@@ -304,12 +303,18 @@
     {
       if (errno == ENOENT)
 	{
-	  char const *dir_name = dirname (file_name);
-	  if (!dir_name || !*dir_name)
-	    dir_name = ".";
+	  char *dir_name = strrchr (file_name, '/');
+	  if (dir_name)
+	    {
+	      while (*--dir_name == '/')
+		;
+	      dir_name++;
+	    }
+	  dir_name = dir_name ? strndup (file_name, dir_name - file_name) : strdup(".");
 	  if (access (dir_name, 06) < 0)
 	    error (1, errno, _("can't create `%s' in `%s'"),
 		   basename (file_name), dir_name);
+	  free (dir_name);
 	}
       else
 	error (1, errno, _("can't modify `%s'"), file_name);
@@ -363,7 +368,7 @@
 	{
 	  if (fstat (fileno (source_FILE), &st) < 0)
 	    {
-	      char *file_name = ALLOCA (char, PATH_MAX);
+	      char file_name[PATH_MAX];
 	      maybe_relative_file_name (file_name, flink, cw_dlink);
 	      error (0, errno, _("can't stat `%s'"), file_name);
 	    }
@@ -372,7 +377,7 @@
 	}
       if (verbose_flag)
 	{
-	  char *file_name = ALLOCA (char, PATH_MAX);
+	  char file_name[PATH_MAX];
 	  maybe_relative_file_name (file_name, flink, cw_dlink);
 	  printf ("%d: %s: %s", member->mf_index, lang->lg_name, file_name);
 	  fflush (stdout);