if ( index < 0 ) index = 0;
if ( index == 0 ) index = -1;
static int adjust_index( int index, int length ){    if ( index < 0 )        index = length + 1 + index;    if ( index < 0 )        index = 0;    return index;}