Changeset 287 for trunk/src/gmake/hash.h
- Timestamp:
- May 17, 2005, 1:34:55 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/hash.h
r53 r287 83 83 /* hash and comparison macros for case-sensitive string keys. */ 84 84 85 #if 0 85 86 #define STRING_HASH_1(KEY, RESULT) do { \ 86 87 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ … … 88 89 (RESULT) += (*_key_ << (_key_[1] & 0xf)); \ 89 90 } while (0) 91 #else 92 #define STRING_HASH_1(KEY, RESULT) do { \ 93 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 94 unsigned int _ch_ = *_key_; \ 95 while (_ch_) \ 96 { \ 97 unsigned char _ch2_ = *++_key_; \ 98 (RESULT) += (_ch_ << (_ch2_ & 0xf)); \ 99 _ch_ = _ch2_; \ 100 } \ 101 } while (0) 102 #endif 90 103 #define return_STRING_HASH_1(KEY) do { \ 91 104 unsigned long _result_ = 0; \ … … 94 107 } while (0) 95 108 109 #if 0 96 110 #define STRING_HASH_2(KEY, RESULT) do { \ 97 111 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ … … 99 113 (RESULT) += (*_key_ << (_key_[1] & 0x7)); \ 100 114 } while (0) 115 #else 116 #define STRING_HASH_2(KEY, RESULT) do { \ 117 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 118 unsigned int _ch_ = *_key_; \ 119 while (_ch_) \ 120 { \ 121 unsigned char _ch2_ = *++_key_; \ 122 (RESULT) += (_ch_ << (_ch2_ & 0x7)); \ 123 _ch_ = _ch2_; \ 124 } \ 125 } while (0) 126 #endif 101 127 #define return_STRING_HASH_2(KEY) do { \ 102 128 unsigned long _result_ = 0; \ … … 112 138 } while (0) 113 139 114 115 #define STRING_N_HASH_1(KEY, N, RESULT) do { \140 #if 0 141 #define _STRING_N_HASH_1(KEY, N, RESULT) do { \ 116 142 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ 117 143 int _n_ = (N); \ … … 121 147 (RESULT) += *++_key_; \ 122 148 } while (0) 149 #else 150 #define STRING_N_HASH_1(KEY, N, RESULT) do { \ 151 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 152 unsigned int _ch_ = *_key_; \ 153 int _n_ = (N); \ 154 if (_n_) \ 155 { \ 156 for (;;) \ 157 { \ 158 unsigned char _ch2_; \ 159 if (!--_n_) \ 160 { \ 161 (RESULT) += _ch_; \ 162 break; \ 163 } \ 164 _ch2_ = *++_key_; \ 165 (RESULT) += (_ch_ << (_ch2_ & 0xf)); \ 166 _ch_ = _ch2_; \ 167 if (!_ch_) break; \ 168 } \ 169 } \ 170 else \ 171 (RESULT) += _ch_; \ 172 } while (0) 173 #endif 123 174 #define return_STRING_N_HASH_1(KEY, N) do { \ 124 175 unsigned long _result_ = 0; \ … … 127 178 } while (0) 128 179 180 #if 0 129 181 #define STRING_N_HASH_2(KEY, N, RESULT) do { \ 130 182 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ … … 135 187 (RESULT) += *++_key_; \ 136 188 } while (0) 189 #else 190 #define STRING_N_HASH_2(KEY, N, RESULT) do { \ 191 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 192 unsigned int _ch_ = *_key_; \ 193 int _n_ = (N); \ 194 if (_n_) \ 195 { \ 196 for (;;) \ 197 { \ 198 unsigned char _ch2_; \ 199 if (!--_n_) \ 200 { \ 201 (RESULT) += _ch_; \ 202 break; \ 203 } \ 204 _ch2_ = *++_key_; \ 205 (RESULT) += (_ch_ << (_ch2_ & 0x7)); \ 206 _ch_ = _ch2_; \ 207 if (!_ch_) break; \ 208 } \ 209 } \ 210 else \ 211 (RESULT) += _ch_; \ 212 } while (0) 213 #endif 137 214 #define return_STRING_N_HASH_2(KEY, N) do { \ 138 215 unsigned long _result_ = 0; \ … … 152 229 /* hash and comparison macros for case-insensitive string _key_s. */ 153 230 231 #if 1 /* testme */ 154 232 #define ISTRING_HASH_1(KEY, RESULT) do { \ 155 233 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ … … 157 235 (RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0xf)); \ 158 236 } while (0) 237 #else 238 #define ISTRING_HASH_1(KEY, RESULT) do { \ 239 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 240 unsigned int _ch_ = *_key_; 241 while (_ch_) \ 242 { \ 243 unsigned _ch2_ = *++_key_; \ 244 (RESULT) += ((isupper (_ch_) ? tolower (_ch_) : _ch_) << (_ch2_ & 0xf)); \ 245 _ch_ = _ch2_; \ 246 } \ 247 } while (0) 248 #endif 159 249 #define return_ISTRING_HASH_1(KEY) do { \ 160 250 unsigned long _result_ = 0; \ … … 163 253 } while (0) 164 254 255 #if 1 /* testme */ 165 256 #define ISTRING_HASH_2(KEY, RESULT) do { \ 166 257 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ … … 168 259 (RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0x7)); \ 169 260 } while (0) 261 #else 262 #define ISTRING_HASH_2(KEY, RESULT) do { \ 263 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 264 unsigned int _ch_ = *_key_; 265 while (_ch_) \ 266 { \ 267 unsigned _ch2_ = *++_key_; \ 268 (RESULT) += ((isupper (_ch_) ? tolower (_ch_) : _ch_) << (_ch2_ & 0x7)); \ 269 _ch_ = _ch2_; \ 270 } \ 271 } while (0) 272 #endif 170 273 #define return_ISTRING_HASH_2(KEY) do { \ 171 274 unsigned long _result_ = 0; \
Note:
See TracChangeset
for help on using the changeset viewer.