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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [libiberty/] [filename_cmp.c] - Diff between revs 834 and 842

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 834 Rev 842
/* File name comparison routine.
/* File name comparison routine.
 
 
   Copyright (C) 2007 Free Software Foundation, Inc.
   Copyright (C) 2007 Free Software Foundation, Inc.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   the Free Software Foundation; either version 2, or (at your option)
   any later version.
   any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   along with this program; if not, write to the Free Software Foundation,
   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config.h"
#endif
#endif
 
 
#ifdef HAVE_STRING_H
#ifdef HAVE_STRING_H
#include <string.h>
#include <string.h>
#endif
#endif
 
 
#include "filenames.h"
#include "filenames.h"
#include "safe-ctype.h"
#include "safe-ctype.h"
 
 
/*
/*
 
 
@deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})
@deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})
 
 
Return zero if the two file names @var{s1} and @var{s2} are equivalent.
Return zero if the two file names @var{s1} and @var{s2} are equivalent.
If not equivalent, the returned value is similar to what @code{strcmp}
If not equivalent, the returned value is similar to what @code{strcmp}
would return.  In other words, it returns a negative value if @var{s1}
would return.  In other words, it returns a negative value if @var{s1}
is less than @var{s2}, or a positive value if @var{s2} is greater than
is less than @var{s2}, or a positive value if @var{s2} is greater than
@var{s2}.
@var{s2}.
 
 
This function does not normalize file names.  As a result, this function
This function does not normalize file names.  As a result, this function
will treat filenames that are spelled differently as different even in
will treat filenames that are spelled differently as different even in
the case when the two filenames point to the same underlying file.
the case when the two filenames point to the same underlying file.
However, it does handle the fact that on DOS-like file systems, forward
However, it does handle the fact that on DOS-like file systems, forward
and backward slashes are equal.
and backward slashes are equal.
 
 
@end deftypefn
@end deftypefn
 
 
*/
*/
 
 
int
int
filename_cmp (const char *s1, const char *s2)
filename_cmp (const char *s1, const char *s2)
{
{
#ifndef HAVE_DOS_BASED_FILE_SYSTEM
#ifndef HAVE_DOS_BASED_FILE_SYSTEM
  return strcmp(s1, s2);
  return strcmp(s1, s2);
#else
#else
  for (;;)
  for (;;)
    {
    {
      int c1 = TOLOWER (*s1);
      int c1 = TOLOWER (*s1);
      int c2 = TOLOWER (*s2);
      int c2 = TOLOWER (*s2);
 
 
      /* On DOS-based file systems, the '/' and the '\' are equivalent.  */
      /* On DOS-based file systems, the '/' and the '\' are equivalent.  */
      if (c1 == '/')
      if (c1 == '/')
        c1 = '\\';
        c1 = '\\';
      if (c2 == '/')
      if (c2 == '/')
        c2 = '\\';
        c2 = '\\';
 
 
      if (c1 != c2)
      if (c1 != c2)
        return (c1 - c2);
        return (c1 - c2);
 
 
      if (c1 == '\0')
      if (c1 == '\0')
        return 0;
        return 0;
 
 
      s1++;
      s1++;
      s2++;
      s2++;
    }
    }
#endif
#endif
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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