if_diff/src/idfLocation.cxx
//============================================================================
// idf_compare_locations(const locationStruct *, const locationStruct *,
//                       boolean ignore_omissions, int &order)
//----------------------------------------------------------------------------
// Compare two locations, determining their trichotomous order.
// Returns false if they are not comparable due to one being line/column
// and the other byte position, etc.
// Sets 'order' to compare with 0 as l1 compares with l2.
// The ordering of the start of the range overrides any considerations of
// the ordering of the end.
// !!! Currently, if the starts are equal then the ordering is decided
// directly by the end positions. But this isn't necessarily what's
// appropriate.
//
// Call this only for purposes of matching nodes.  When it's time to
// report differences in positions, you need to report file name differences
// rather than fudge them.
//
// If ignore_omissions is true, then a location that omits length
// will compare equal to a location that has a length.
//============================================================================
idf_compare_locations(const locationStruct *, const locationStruct *,
boolean ignore_omissions, int ℴ)

Compare two locations, determining their trichotomous order.
Returns false if they are not comparable due to one being line/column
and the other byte position, etc.
Sets 'order' to compare with 0 as l1 compares with l2.
The ordering of the start of the range overrides any considerations of
the ordering of the end.
Currently, if the starts are equal then the ordering is decided
directly by the end positions. But this isn't necessarily what's
appropriate.

Call this only for purposes of matching nodes.  When it's time to
report differences in positions, you need to report file name differences
rather than fudge them.

If ignore_omissions is true, then a location that omits length
will compare equal to a location that has a length.
idf_compare_locations ( const locationStruct * const locationStruct * boolean ignore_omissions int ℴ ) Compare two locations determining their trichotomous order . Returns false if they are not comparable due to one being line / column and the other byte position etc . Sets ' order ' to compare with 0 as l1 compares with l2 . The ordering of the start of the range overrides any considerations of the ordering of the end . Currently if the starts are equal then the ordering is decided directly by the end positions . But this isn ' t necessarily what ' s appropriate . Call this only for purposes of matching nodes . When it ' s time to report differences in positions you need to report file name differences rather than fudge them . If ignore_omissions is true then a location that omits length will compare equal to a location that has a length .
boolean idf_compare_locations(const locationStruct *l1,
      	      	      	      const locationStruct *l2,
      	      	      	      boolean ignore_omissions, int &order)
{
  if (l1 == NULL || l2 == NULL) {
    return false;
  }
  if (!idf_filename_match(l1->filename, l2->filename)) {
    return false;
  }
  if (l1->start_line < 0 || l2->start_line < 0) {
    return false;
  }
  if ((l1->start_line == 0) != (l2->start_line == 0)) {
    return false;
  }
  if (l1->start_line != l2->start_line) {
    order = l1->start_line < l2->start_line ? -1 : 1;
    return true;
  }
  if (l1->start_column != l2->start_column) {
    order = l1->start_column < l2->start_column ? -1 : 1;
    return true;
  }
  if (ignore_omissions) {
    if (   (l1->end_line == 0 && l1->end_column == 0)
      	|| (l2->end_line == 0 && l2->end_column == 0)) {
      order = 0;
      return true;
    }
  }
  if ((l1->end_line == 0) != (l2->end_line == 0)) {
    if (idf_compare_zero_end_line(*l1, *l2, order)) {
      return true;
    }
    else if (idf_compare_zero_end_line(*l2, *l1, order)) {
      order = -order;
      return true;
    }
    return false;
  }
  if (l1->end_line != l2->end_line) {
    order = l1->end_line < l2->end_line ? -1 : 1;
    return true;
  }
  order = l1->end_column < l2->end_column ? -1 :
	  l1->end_column == l2->end_column ? 0 : 1;
  return true;
}
boolean idf_compare_locations ( const locationStruct * l1 , const locationStruct * l2 , boolean ignore_omissions , int & order ) { if ( l1 == NULL || l2 == NULL ) { return false ; } if ( ! idf_filename_match ( l1 -> filename , l2 -> filename ) ) { return false ; } if ( l1 -> start_line < 0 || l2 -> start_line < 0 ) { return false ; } if ( ( l1 -> start_line == 0 ) != ( l2 -> start_line == 0 ) ) { return false ; } if ( l1 -> start_line != l2 -> start_line ) { order = l1 -> start_line < l2 -> start_line ? -1 : 1 ; return true ; } if ( l1 -> start_column != l2 -> start_column ) { order = l1 -> start_column < l2 -> start_column ? -1 : 1 ; return true ; } if ( ignore_omissions ) { if ( ( l1 -> end_line == 0 && l1 -> end_column == 0 ) || ( l2 -> end_line == 0 && l2 -> end_column == 0 ) ) { order = 0 ; return true ; } } if ( ( l1 -> end_line == 0 ) != ( l2 -> end_line == 0 ) ) { if ( idf_compare_zero_end_line ( * l1 , * l2 , order ) ) { return true ; } else if ( idf_compare_zero_end_line ( * l2 , * l1 , order ) ) { order = - order ; return true ; } return false ; } if ( l1 -> end_line != l2 -> end_line ) { order = l1 -> end_line < l2 -> end_line ? -1 : 1 ; return true ; } order = l1 -> end_column < l2 -> end_column ? -1 : l1 -> end_column == l2 -> end_column ? 0 : 1 ; return true ; }
idf_compare_locations(const locationStruct *, const locationStruct *,
boolean ignore_omissions, int &order)
idf_compare_locations ( const locationStruct * const locationStruct * boolean ignore_omissions int &order )
// The IF parser's locationStruct reflects the syntax that has been parsed. // The locationStruct contains //   start_line                                        sl //   start_column                                          sc //   end_line                                                  el //   end_column                                                    ec //                                                     //   bytestart                               s         0   s   0   0 //   bytemap ::= bytestart bytelen           s l       0   s   0   l //   linecolstart                            s/s       s   s   0   0 //   linecolmap ::= linecolstart bytelen     s/s l     s   s   0   l //   linecolmap ::= linecolstart linecolend  s/s e/e   s   s   e   e