-rw-r--r-- | qmake/tools/qgdict.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/qmake/tools/qgdict.cpp b/qmake/tools/qgdict.cpp index c431ff8..3d49fc7 100644 --- a/qmake/tools/qgdict.cpp +++ b/qmake/tools/qgdict.cpp | |||
@@ -159,97 +159,100 @@ int QGDict::hashKeyAscii( const char *key ) | |||
159 | reference to the stream. | 159 | reference to the stream. |
160 | 160 | ||
161 | The default implementation sets \a item to 0. | 161 | The default implementation sets \a item to 0. |
162 | 162 | ||
163 | \sa write() | 163 | \sa write() |
164 | */ | 164 | */ |
165 | 165 | ||
166 | QDataStream& QGDict::read( QDataStream &s, QPtrCollection::Item &item ) | 166 | QDataStream& QGDict::read( QDataStream &s, QPtrCollection::Item &item ) |
167 | { | 167 | { |
168 | item = 0; | 168 | item = 0; |
169 | return s; | 169 | return s; |
170 | } | 170 | } |
171 | 171 | ||
172 | /*! | 172 | /*! |
173 | \overload | 173 | \overload |
174 | Writes a collection/dictionary item to the stream \a s and returns a | 174 | Writes a collection/dictionary item to the stream \a s and returns a |
175 | reference to the stream. | 175 | reference to the stream. |
176 | 176 | ||
177 | \sa read() | 177 | \sa read() |
178 | */ | 178 | */ |
179 | 179 | ||
180 | QDataStream& QGDict::write( QDataStream &s, QPtrCollection::Item ) const | 180 | QDataStream& QGDict::write( QDataStream &s, QPtrCollection::Item ) const |
181 | { | 181 | { |
182 | return s; | 182 | return s; |
183 | } | 183 | } |
184 | #endif //QT_NO_DATASTREAM | 184 | #endif //QT_NO_DATASTREAM |
185 | 185 | ||
186 | /***************************************************************************** | 186 | /***************************************************************************** |
187 | QGDict member functions | 187 | QGDict member functions |
188 | *****************************************************************************/ | 188 | *****************************************************************************/ |
189 | 189 | ||
190 | /*! | 190 | /*! |
191 | Constructs a dictionary. | 191 | Constructs a dictionary. |
192 | 192 | ||
193 | \a len is the initial size of the dictionary. | 193 | \a len is the initial size of the dictionary. |
194 | The key type is \a kt which may be \c StringKey, \c AsciiKey, | 194 | The key type is \a kt which may be \c StringKey, \c AsciiKey, |
195 | \c IntKey or \c PtrKey. The case-sensitivity of lookups is set with | 195 | \c IntKey or \c PtrKey. The case-sensitivity of lookups is set with |
196 | \a caseSensitive. Keys are copied if \a copyKeys is TRUE. | 196 | \a caseSensitive. Keys are copied if \a copyKeys is TRUE. |
197 | */ | 197 | */ |
198 | 198 | ||
199 | QGDict::QGDict( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) | 199 | QGDict::QGDict( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) |
200 | { | 200 | { |
201 | init( len, kt, caseSensitive, copyKeys ); | 201 | init( len, kt, caseSensitive, copyKeys ); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void QGDict::init( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) | 205 | void QGDict::init( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) |
206 | { | 206 | { |
207 | vec = new QBaseBucket *[vlen = len]; // allocate hash table | 207 | vlen = len; |
208 | if ( vlen == 0 ) | ||
209 | vlen = 17; | ||
210 | vec = new QBaseBucket *[vlen]; | ||
208 | Q_CHECK_PTR( vec ); | 211 | Q_CHECK_PTR( vec ); |
209 | memset( (char*)vec, 0, vlen*sizeof(QBaseBucket*) ); | 212 | memset( (char*)vec, 0, vlen*sizeof(QBaseBucket*) ); |
210 | numItems = 0; | 213 | numItems = 0; |
211 | iterators = 0; | 214 | iterators = 0; |
212 | // The caseSensitive and copyKey options don't make sense for | 215 | // The caseSensitive and copyKey options don't make sense for |
213 | // all dict types. | 216 | // all dict types. |
214 | switch ( (keytype = (uint)kt) ) { | 217 | switch ( (keytype = (uint)kt) ) { |
215 | case StringKey: | 218 | case StringKey: |
216 | cases = caseSensitive; | 219 | cases = caseSensitive; |
217 | copyk = FALSE; | 220 | copyk = FALSE; |
218 | break; | 221 | break; |
219 | case AsciiKey: | 222 | case AsciiKey: |
220 | cases = caseSensitive; | 223 | cases = caseSensitive; |
221 | copyk = copyKeys; | 224 | copyk = copyKeys; |
222 | break; | 225 | break; |
223 | default: | 226 | default: |
224 | cases = FALSE; | 227 | cases = FALSE; |
225 | copyk = FALSE; | 228 | copyk = FALSE; |
226 | break; | 229 | break; |
227 | } | 230 | } |
228 | } | 231 | } |
229 | 232 | ||
230 | 233 | ||
231 | /*! | 234 | /*! |
232 | Constructs a copy of \a dict. | 235 | Constructs a copy of \a dict. |
233 | */ | 236 | */ |
234 | 237 | ||
235 | QGDict::QGDict( const QGDict & dict ) | 238 | QGDict::QGDict( const QGDict & dict ) |
236 | : QPtrCollection( dict ) | 239 | : QPtrCollection( dict ) |
237 | { | 240 | { |
238 | init( dict.vlen, (KeyType)dict.keytype, dict.cases, dict.copyk ); | 241 | init( dict.vlen, (KeyType)dict.keytype, dict.cases, dict.copyk ); |
239 | QGDictIterator it( dict ); | 242 | QGDictIterator it( dict ); |
240 | while ( it.get() ) { // copy from other dict | 243 | while ( it.get() ) { // copy from other dict |
241 | switch ( keytype ) { | 244 | switch ( keytype ) { |
242 | case StringKey: | 245 | case StringKey: |
243 | look_string( it.getKeyString(), it.get(), op_insert ); | 246 | look_string( it.getKeyString(), it.get(), op_insert ); |
244 | break; | 247 | break; |
245 | case AsciiKey: | 248 | case AsciiKey: |
246 | look_ascii( it.getKeyAscii(), it.get(), op_insert ); | 249 | look_ascii( it.getKeyAscii(), it.get(), op_insert ); |
247 | break; | 250 | break; |
248 | case IntKey: | 251 | case IntKey: |
249 | look_int( it.getKeyInt(), it.get(), op_insert ); | 252 | look_int( it.getKeyInt(), it.get(), op_insert ); |
250 | break; | 253 | break; |
251 | case PtrKey: | 254 | case PtrKey: |
252 | look_ptr( it.getKeyPtr(), it.get(), op_insert ); | 255 | look_ptr( it.getKeyPtr(), it.get(), op_insert ); |
253 | break; | 256 | break; |
254 | } | 257 | } |
255 | ++it; | 258 | ++it; |