src/plugins/yajl/iterator.c
/**
 * @brief Forwards to key which is not below the next one
 *
 * Forwards at least forward one element.
 * ksCurrent() will point at the same key as the key which is returned.
 *
 * e.g.
 * user/sw/x
 * user/sw/x/y
 * user/sw/x/y/z1
 *
 * @retval last element if no other found.
 * @retval 0 if there is no other element afterwards (keyset will be
 * rewinded then)
 *
 * @param ks keyset to use
 *
 * @return key after starting position which is not below (to any latter
 * one)
 */
@brief Forwards to key which is not below the next one
Forwards at least forward one element.
ksCurrent() will point at the same key as the key which is returned.



@retval last element if no other found.
@retval 0 if there is no other element afterwards (keyset will be
rewinded then)

@param ks keyset to use

@return key after starting position which is not below (to any latter
one)
@brief Forwards to key which is not below the next one Forwards at least forward one element . ksCurrent () will point at the same key as the key which is returned . @retval last element if no other found . @retval 0 if there is no other element afterwards ( keyset will be rewinded then ) @param ks keyset to use @return key after starting position which is not below ( to any latter one )
Key * elektraNextNotBelow (KeySet * ks)
{
	const Key * previous = ksNext (ks);
	if (!previous)
	{
		ksRewind (ks);
		return 0;
	}
	cursor_t pos;			
	const Key * current = previous; 
	do
	{
		pos = ksGetCursor (ks); 
		previous = current;     
		current = ksNext (ks);  
	} while (current && keyIsBelow (previous, current));
	ksSetCursor (ks, pos);
	return ksCurrent (ks);
}
Key * elektraNextNotBelow ( KeySet * ks ) { const Key * previous = ksNext ( ks ) ; if ( ! previous ) { ksRewind ( ks ) ; return 0 ; } cursor_t pos ; const Key * current = previous ; do { pos = ksGetCursor ( ks ) ; previous = current ; current = ksNext ( ks ) ; } while ( current && keyIsBelow ( previous , current ) ) ; ksSetCursor ( ks , pos ) ; return ksCurrent ( ks ) ; }
@brief Forwards to key which is not below the next one
 Forwards at least forward one element.
@brief Forwards to key which is not below the next one Forwards at least forward one element .
// unitialized variables are ok, because do{}while guarantees initialisation // always one before current // current is same as ksCurrent() // remember candidate // and remember last key // look forward to next key // jump to and return candidate, because next is known to be not // below candidate