home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / kpathsea / absolute.c next >
C/C++ Source or Header  |  2000-01-15  |  2KB  |  62 lines

  1. /* absolute.c: Test if a filename is absolute or explicitly relative.
  2.  
  3. Copyright (C) 1993, 94, 95 Karl Berry.
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  18.  
  19. #include <kpathsea/config.h>
  20.  
  21. #include <kpathsea/absolute.h>
  22. #include <kpathsea/c-pathch.h>
  23.  
  24. /* Sorry this is such a system-dependent mess, but I can't see any way
  25.    to usefully generalize.  */
  26.  
  27. boolean
  28. kpse_absolute_p P2C(const_string, filename,  boolean, relative_ok)
  29. {
  30. #ifdef VMS
  31. #include <string.h>
  32.   return strcspn (filename, "]>:") != strlen (filename);
  33. #else /* not VMS */
  34.   boolean absolute = IS_DIR_SEP (*filename)
  35. #ifdef DOSISH
  36.                      /* Novell allows non-alphanumeric drive letters. */
  37.                      || (*filename && IS_DEVICE_SEP (filename[1]))
  38. #endif /* DOSISH */
  39. #ifdef WIN32
  40.                      /* UNC names */
  41.                      || (*filename == '\\' && filename[1] == '\\')
  42. #endif
  43. #ifdef AMIGA
  44.              /* Colon anywhere means a device.  */
  45.              || strchr (filename, ':')
  46. #endif /* AMIGA */
  47.               ;
  48.   boolean explicit_relative
  49.     = relative_ok
  50. #ifdef AMIGA
  51.       /* Leading / is like `../' on Unix and DOS.  Allow Unix syntax,
  52.          too, though, because of possible patch programs like
  53.          `UnixDirsII' by Martin Scott.  */
  54.       && IS_DIR_SEP (*filename) || 0
  55. #endif /* AMIGA */
  56.       && (*filename == '.' && (IS_DIR_SEP (filename[1])
  57.                          || (filename[1] == '.' && IS_DIR_SEP (filename[2]))));
  58.  
  59.   return absolute || explicit_relative;
  60. #endif /* not VMS */
  61. }
  62.