I happened to be writing something like this:
int main( int nargs, char **args ) {
int i, j;
if ( i > 0 && NEAR( i-1, j ).dist == INFINITY )
{
NEAR( i-1, j ).dist = 1.0;
NEAR( i-1, j ).X = i;
NEAR( i-1, j ).Y = j;
newWorkPoints.push_back( IPoint( i-1, j ));
}
if ( j > 0 && NEAR( i, j-1 ).dist == INFINITY )
{
NEAR( i, j-1 ).dist = 1.0;
NEAR( i, j-1 ).X = i;
NEAR( i, j-1 ).Y = j;
newWorkPoints.push_back( IPoint( i, j-1 ));
}
if ( i < maxwid && NEAR( i+1, j ).dist == INFINITY )
{
NEAR( i+1, j ).dist = 1.0;
NEAR( i+1, j ).X = i;
NEAR( i+1, j ).Y = j;
newWorkPoints.push_back( IPoint( i+1, j ));
}
if ( j < maxheight && NEAR( i, j+1 ).dist == INFINITY )
{
NEAR( i, j+1 ).dist = 1.0;
NEAR( i, j+1 ).X = i;
NEAR( i, j+1 ).Y = j;
newWorkPoints.push_back( IPoint( i, j+1 ));
}
}
When I wrote it, emacs (22.2.1 of 2010-03-30, Ubuntu) indented it very badly:
int main( int nargs, char **args ) {
int i, j;
if ( i > 0 && NEAR( i-1, j ).dist == INFINITY )
{
NEAR( i-1, j ).dist = 1.0;
NEAR( i-1, j ).X = i;
NEAR( i-1, j ).Y = j;
newWorkPoints.push_back( IPoint( i-1, j ));
}
if ( j > 0 && NEAR( i, j-1 ).dist == INFINITY )
{
NEAR( i, j-1 ).dist = 1.0;
NEAR( i, j-1 ).X = i;
NEAR( i, j-1 ).Y = j;
newWorkPoints.push_back( IPoint( i, j-1 ));
}
if ( i < maxwid && NEAR( i+1, j ).dist == INFINITY )
{
NEAR( i+1, j ).dist = 1.0;
NEAR( i+1, j ).X = i;
NEAR( i+1, j ).Y = j;
newWorkPoints.push_back( IPoint( i+1, j ));
}
if ( j < maxheight && NEAR( i, j+1 ).dist == INFINITY )
{
NEAR( i, j+1 ).dist = 1.0;
NEAR( i, j+1 ).X = i;
NEAR( i, j+1 ).Y = j;
newWorkPoints.push_back( IPoint( i, j+1 ));
}
}
It's the occurence of the < in the expression that's doing it. This seems like an unlikely bug! Am I doing something wrong?