OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [libiberty/] [make-relative-prefix.c] - Diff between revs 21 and 166

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 21 Rev 166
Line 1... Line 1...
/* Relative (relocatable) prefix support.
/* Relative (relocatable) prefix support.
   Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
   Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
   1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
   1999, 2000, 2001, 2002, 2006, 2012 Free Software Foundation, Inc.
 
 
This file is part of libiberty.
This file is part of libiberty.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Line 56... Line 56...
#include <stdlib.h>
#include <stdlib.h>
#endif
#endif
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <unistd.h>
#endif
#endif
 
#ifdef HAVE_SYS_STAT_H
 
#include <sys/stat.h>
 
#endif
 
 
#include <string.h>
#include <string.h>
 
 
#include "ansidecl.h"
#include "ansidecl.h"
#include "libiberty.h"
#include "libiberty.h"
Line 243... Line 246...
      temp = getenv ("PATH");
      temp = getenv ("PATH");
      if (temp)
      if (temp)
        {
        {
          char *startp, *endp, *nstore;
          char *startp, *endp, *nstore;
          size_t prefixlen = strlen (temp) + 1;
          size_t prefixlen = strlen (temp) + 1;
 
          size_t len;
          if (prefixlen < 2)
          if (prefixlen < 2)
            prefixlen = 2;
            prefixlen = 2;
 
 
          nstore = (char *) alloca (prefixlen + strlen (progname) + 1);
          len = prefixlen + strlen (progname) + 1;
 
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
 
          len += strlen (HOST_EXECUTABLE_SUFFIX);
 
#endif
 
          nstore = (char *) alloca (len);
 
 
          startp = endp = temp;
          startp = endp = temp;
          while (1)
          while (1)
            {
            {
              if (*endp == PATH_SEPARATOR || *endp == 0)
              if (*endp == PATH_SEPARATOR || *endp == 0)
Line 261... Line 269...
                      nstore[1] = DIR_SEPARATOR;
                      nstore[1] = DIR_SEPARATOR;
                      nstore[2] = '\0';
                      nstore[2] = '\0';
                    }
                    }
                  else
                  else
                    {
                    {
                      strncpy (nstore, startp, endp - startp);
                      memcpy (nstore, startp, endp - startp);
                      if (! IS_DIR_SEPARATOR (endp[-1]))
                      if (! IS_DIR_SEPARATOR (endp[-1]))
                        {
                        {
                          nstore[endp - startp] = DIR_SEPARATOR;
                          nstore[endp - startp] = DIR_SEPARATOR;
                          nstore[endp - startp + 1] = 0;
                          nstore[endp - startp + 1] = 0;
                        }
                        }
Line 277... Line 285...
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
#ifdef HAVE_HOST_EXECUTABLE_SUFFIX
                      || ! access (strcat (nstore, HOST_EXECUTABLE_SUFFIX), X_OK)
                      || ! access (strcat (nstore, HOST_EXECUTABLE_SUFFIX), X_OK)
#endif
#endif
                      )
                      )
                    {
                    {
 
#if defined (HAVE_SYS_STAT_H) && defined (S_ISREG)
 
                      struct stat st;
 
                      if (stat (nstore, &st) >= 0 && S_ISREG (st.st_mode))
 
#endif
 
                        {
                      progname = nstore;
                      progname = nstore;
                      break;
                      break;
                    }
                    }
 
                    }
 
 
                  if (*endp == 0)
                  if (*endp == 0)
                    break;
                    break;
                  endp = startp = endp + 1;
                  endp = startp = endp + 1;
                }
                }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.