src/or/consdiff.c
static void
trim_slices(smartlist_slice_t *slice1, smartlist_slice_t *slice2)
{
  while (slice1->len>0 && slice2->len>0) {
    const char *line1 = smartlist_get(slice1->list, slice1->offset);
    const char *line2 = smartlist_get(slice2->list, slice2->offset);
    if (strcmp(line1, line2)) {
      break;
    }
    slice1->offset++; slice1->len--;
    slice2->offset++; slice2->len--;
  }

  int i1 = (slice1->offset+slice1->len)-1;
  int i2 = (slice2->offset+slice2->len)-1;

  while (slice1->len>0 && slice2->len>0) {
    const char *line1 = smartlist_get(slice1->list, i1);
    const char *line2 = smartlist_get(slice2->list, i2);
    if (strcmp(line1, line2)) {
      break;
    }
    i1--;
    slice1->len--;
    i2--;
    slice2->len--;
  }
}
/** Helper: Trim any number of lines that are equally at the start or the end
 * of both slices.
 */
Trim any number of lines that are equally at the start or the end
of both slices.
Trim any number of lines that are equally at the start or the end of both slices .
static void
trim_slices(smartlist_slice_t *slice1, smartlist_slice_t *slice2)
{
  while (slice1->len>0 && slice2->len>0) {
    const char *line1 = smartlist_get(slice1->list, slice1->offset);
    const char *line2 = smartlist_get(slice2->list, slice2->offset);
    if (strcmp(line1, line2)) {
      break;
    }
    slice1->offset++; slice1->len--;
    slice2->offset++; slice2->len--;
  }
  int i1 = (slice1->offset+slice1->len)-1;
  int i2 = (slice2->offset+slice2->len)-1;
  while (slice1->len>0 && slice2->len>0) {
    const char *line1 = smartlist_get(slice1->list, i1);
    const char *line2 = smartlist_get(slice2->list, i2);
    if (strcmp(line1, line2)) {
      break;
    }
    i1--;
    slice1->len--;
    i2--;
    slice2->len--;
  }
}
static void trim_slices ( smartlist_slice_t * slice1 , smartlist_slice_t * slice2 ) { while ( slice1 -> len > 0 && slice2 -> len > 0 ) { const char * line1 = smartlist_get ( slice1 -> list , slice1 -> offset ) ; const char * line2 = smartlist_get ( slice2 -> list , slice2 -> offset ) ; if ( strcmp ( line1 , line2 ) ) { break ; } slice1 -> offset ++ ; slice1 -> len -- ; slice2 -> offset ++ ; slice2 -> len -- ; } int i1 = ( slice1 -> offset + slice1 -> len ) - 1 ; int i2 = ( slice2 -> offset + slice2 -> len ) - 1 ; while ( slice1 -> len > 0 && slice2 -> len > 0 ) { const char * line1 = smartlist_get ( slice1 -> list , i1 ) ; const char * line2 = smartlist_get ( slice2 -> list , i2 ) ; if ( strcmp ( line1 , line2 ) ) { break ; } i1 -- ; slice1 -> len -- ; i2 -- ; slice2 -> len -- ; } }
Helper: Trim any number of lines that are equally at the start or the end
 of both slices.
Helper : Trim any number of lines that are equally at the start or the end of both slices .