home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / kpathsea / absolute.c < prev    next >
C/C++ Source or Header  |  1994-02-01  |  2KB  |  52 lines

  1. /* absolute.c: Test if a filename is absolute or explicitly relative.
  2.  
  3. Copyright (C) 1993 Karl Berry.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program 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
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include <kpathsea/config.h>
  20.  
  21. #include <kpathsea/absolute.h>
  22. #include <kpathsea/c-pathch.h>
  23.  
  24. #ifdef DOS
  25. #include <kpathsea/c-ctype.h> /* For ISALPHA */
  26. #endif /* DOS */
  27.  
  28.  
  29. /* Sorry this is such a system-dependent mess, but I can't see any way
  30.    to usefully generalize.  */
  31.  
  32. boolean
  33. kpse_absolute_p P1C(string, filename)
  34. {
  35. #ifdef VMS
  36. #include <string.h>
  37.   return strcspn (filename, "]>:") != strlen (filename);
  38. #else /* not VMS */
  39.   boolean absolute = IS_DIR_SEP (*filename)
  40. #ifdef DOS
  41.                       || ISALPHA (*filename) && filename[1] == ':'
  42. #endif /* DOS */
  43.               ;
  44.   boolean explicit_relative
  45.     = (*filename == '.'
  46.        && (IS_DIR_SEP (filename[1])
  47.            || (filename[1] == '.' && IS_DIR_SEP (filename[2]))));
  48.  
  49.   return absolute || explicit_relative;
  50. #endif /* not VMS */
  51. }
  52.