OLD | NEW |
1 /* File name comparison routine. | 1 /* File name comparison routine. |
2 | 2 |
3 Copyright (C) 2007 Free Software Foundation, Inc. | 3 Copyright (C) 2007 Free Software Foundation, Inc. |
4 | 4 |
5 This program is free software; you can redistribute it and/or modify | 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 | 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) | 7 the Free Software Foundation; either version 2, or (at your option) |
8 any later version. | 8 any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | 10 This program is distributed in the hope that it will be useful, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 if (c1 == '\0' || c1 != c2) | 135 if (c1 == '\0' || c1 != c2) |
136 return (c1 - c2); | 136 return (c1 - c2); |
137 | 137 |
138 s1++; | 138 s1++; |
139 s2++; | 139 s2++; |
140 } | 140 } |
141 return 0; | 141 return 0; |
142 #endif | 142 #endif |
143 } | 143 } |
| 144 |
| 145 /* |
| 146 |
| 147 @deftypefn Extension hashval_t filename_hash (const void *@var{s}) |
| 148 |
| 149 Return the hash value for file name @var{s} that will be compared |
| 150 using filename_cmp. |
| 151 This function is for use with hashtab.c hash tables. |
| 152 |
| 153 @end deftypefn |
| 154 |
| 155 */ |
| 156 |
| 157 hashval_t |
| 158 filename_hash (const void *s) |
| 159 { |
| 160 /* The cast is for -Wc++-compat. */ |
| 161 const unsigned char *str = (const unsigned char *) s; |
| 162 hashval_t r = 0; |
| 163 unsigned char c; |
| 164 |
| 165 while ((c = *str++) != 0) |
| 166 { |
| 167 if (c == '\\') |
| 168 c = '/'; |
| 169 c = TOLOWER (c); |
| 170 r = r * 67 + c - 113; |
| 171 } |
| 172 |
| 173 return r; |
| 174 } |
| 175 |
| 176 /* |
| 177 |
| 178 @deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2}
) |
| 179 |
| 180 Return non-zero if file names @var{s1} and @var{s2} are equivalent. |
| 181 This function is for use with hashtab.c hash tables. |
| 182 |
| 183 @end deftypefn |
| 184 |
| 185 */ |
| 186 |
| 187 int |
| 188 filename_eq (const void *s1, const void *s2) |
| 189 { |
| 190 /* The casts are for -Wc++-compat. */ |
| 191 return filename_cmp ((const char *) s1, (const char *) s2) == 0; |
| 192 } |
OLD | NEW |