celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erjan Altena (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CELIX-380) PROPERTIES_FOR_EACH macro does not iterate over all keys
Date Tue, 11 Oct 2016 06:55:20 GMT

     [ https://issues.apache.org/jira/browse/CELIX-380?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Erjan Altena updated CELIX-380:
-------------------------------
    Description: 
When using the macro PROPERTIES_FOR_EACH in properties.h always on key is missed.

The macro is defined as:
#define PROPERTIES_FOR_EACH(props, key) \
	for(hash_map_iterator_t iter = hashMapIterator_construct((props)); \
		hashMapIterator_hasNext(&iter); \
		(key) = (const char*)hashMapIterator_nextKey(&iter))

In the first iteration the variable key is not set. 

The solution below works:
#define PROPERTIES_FOR_EACH(props, key) \
	for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);)





  was:
When using the macro PROPERTIES_FOR_EACH in properties.h always on key is missed.

The macro is defined as:
#define PROPERTIES_FOR_EACH(props, key) \
	for(hash_map_iterator_t iter = hashMapIterator_construct((props)); \
		hashMapIterator_hasNext(&iter); \
		(key) = (const char*)hashMapIterator_nextKey(&iter))

In the first iteration the variable key is not set. 

Also there is no hashMapIterator function to get the first value, only the next.

This could work if the  hashMapIterator_construct returns an iterator which is one before
the first value (i.e. index -1) but this seems not be the case.




> PROPERTIES_FOR_EACH macro does not iterate over all  keys
> ---------------------------------------------------------
>
>                 Key: CELIX-380
>                 URL: https://issues.apache.org/jira/browse/CELIX-380
>             Project: Celix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 1.0.0-incubating
>            Reporter: Erjan Altena
>             Fix For: next
>
>
> When using the macro PROPERTIES_FOR_EACH in properties.h always on key is missed.
> The macro is defined as:
> #define PROPERTIES_FOR_EACH(props, key) \
> 	for(hash_map_iterator_t iter = hashMapIterator_construct((props)); \
> 		hashMapIterator_hasNext(&iter); \
> 		(key) = (const char*)hashMapIterator_nextKey(&iter))
> In the first iteration the variable key is not set. 
> The solution below works:
> #define PROPERTIES_FOR_EACH(props, key) \
> 	for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
> hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);)




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message