View | Details | Return to bug 48306
Collapse All | Expand All

(-)libiberty/make-relative-prefix.c.jj (-5 / +18 lines)
Lines 1-6 Link Here
1
/* Relative (relocatable) prefix support.
1
/* Relative (relocatable) prefix support.
2
   Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
2
   Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3
   1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
3
   1999, 2000, 2001, 2002, 2006, 2011 Free Software Foundation, Inc.
4
4
5
This file is part of libiberty.
5
This file is part of libiberty.
6
6
Lines 58-63 relative prefix can be found, return @co Link Here
58
#ifdef HAVE_UNISTD_H
58
#ifdef HAVE_UNISTD_H
59
#include <unistd.h>
59
#include <unistd.h>
60
#endif
60
#endif
61
#ifdef HAVE_SYS_STAT_H
62
#include <sys/stat.h>
63
#endif
61
64
62
#include <string.h>
65
#include <string.h>
63
66
Lines 248-254 make_relative_prefix_1 (const char *prog Link Here
248
	  if (prefixlen < 2)
251
	  if (prefixlen < 2)
249
	    prefixlen = 2;
252
	    prefixlen = 2;
250
253
251
	  nstore = (char *) alloca (prefixlen + strlen (progname) + 1);
254
	  nstore = (char *) alloca (prefixlen + strlen (progname) + 1
255
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
256
				    + strlen (HOST_EXECUTABLE_SUFFIX)
257
#endif
258
				    );
252
259
253
	  startp = endp = temp;
260
	  startp = endp = temp;
254
	  while (1)
261
	  while (1)
Lines 263-269 make_relative_prefix_1 (const char *prog Link Here
263
		    }
270
		    }
264
		  else
271
		  else
265
		    {
272
		    {
266
		      strncpy (nstore, startp, endp - startp);
273
		      memcpy (nstore, startp, endp - startp);
267
		      if (! IS_DIR_SEPARATOR (endp[-1]))
274
		      if (! IS_DIR_SEPARATOR (endp[-1]))
268
			{
275
			{
269
			  nstore[endp - startp] = DIR_SEPARATOR;
276
			  nstore[endp - startp] = DIR_SEPARATOR;
Lines 279-286 make_relative_prefix_1 (const char *prog Link Here
279
#endif
286
#endif
280
		      )
287
		      )
281
		    {
288
		    {
282
		      progname = nstore;
289
#if defined (HAVE_SYS_STAT_H) && defined (S_ISREG)
283
		      break;
290
		      struct stat st;
291
		      if (stat (nstore, &st) >= 0 && S_ISREG (st.st_mode))
292
#endif
293
			{
294
			  progname = nstore;
295
			  break;
296
			}
284
		    }
297
		    }
285
298
286
		  if (*endp == 0)
299
		  if (*endp == 0)

Return to bug 48306