src/error.c
static Location
calculateLocation(size_t start, size_t end) {
  size_t line = 1;
  size_t column = 1;
  size_t i;

  for (i = 0; i < start; i++) {
    column++;
    if (errorCtx.buffer[i] == '\n') {
      line++;
      column = 1;
    }
  }

  Location ret;
  size_t line_start;
  for (line_start = start; line_start > 0; line_start--) {
    if (errorCtx.buffer[line_start] == '\n') {
      break;
    }
  }
  ret.line_start = line;
  ret.line_idx = line_start;
  size_t line_end;
  for (line_end = start; line_end < errorCtx.bufferSize; line_end++) {
    if (errorCtx.buffer[line_end] == '\n') {
      break;
    }
  }
  ret.line_end = line;
  ret.line_idx_end = line_end;
  ret.column_start = column;
  ret.column_end = column;
  for (size_t i = start; i < end; i++) {
    ret.column_end++;
    if (errorCtx.buffer[i] == '\n') {
      ret.line_end++;
      ret.column_end = 1;
    }
  }
  return ret;
}
/*
 * This is bad and incomplete
 * It hosts who knows how many bugs
 * I will fix this.
 */
This is bad and incomplete
It hosts who knows how many bugs
I will fix this.
This is bad and incomplete It hosts who knows how many bugs I will fix this .
static Location
calculateLocation(size_t start, size_t end) {
  size_t line = 1;
  size_t column = 1;
  size_t i;
  for (i = 0; i < start; i++) {
    column++;
    if (errorCtx.buffer[i] == '\n') {
      line++;
      column = 1;
    }
  }
  Location ret;
  size_t line_start;
  for (line_start = start; line_start > 0; line_start--) {
    if (errorCtx.buffer[line_start] == '\n') {
      break;
    }
  }
  ret.line_start = line;
  ret.line_idx = line_start;
  size_t line_end;
  for (line_end = start; line_end < errorCtx.bufferSize; line_end++) {
    if (errorCtx.buffer[line_end] == '\n') {
      break;
    }
  }
  ret.line_end = line;
  ret.line_idx_end = line_end;
  ret.column_start = column;
  ret.column_end = column;
  for (size_t i = start; i < end; i++) {
    ret.column_end++;
    if (errorCtx.buffer[i] == '\n') {
      ret.line_end++;
      ret.column_end = 1;
    }
  }
  return ret;
}
static Location calculateLocation ( size_t start , size_t end ) { size_t line = 1 ; size_t column = 1 ; size_t i ; for ( i = 0 ; i < start ; i ++ ) { column ++ ; if ( errorCtx . buffer [ i ] == ' \n ' ) { line ++ ; column = 1 ; } } Location ret ; size_t line_start ; for ( line_start = start ; line_start > 0 ; line_start -- ) { if ( errorCtx . buffer [ line_start ] == ' \n ' ) { break ; } } ret . line_start = line ; ret . line_idx = line_start ; size_t line_end ; for ( line_end = start ; line_end < errorCtx . bufferSize ; line_end ++ ) { if ( errorCtx . buffer [ line_end ] == ' \n ' ) { break ; } } ret . line_end = line ; ret . line_idx_end = line_end ; ret . column_start = column ; ret . column_end = column ; for ( size_t i = start ; i < end ; i ++ ) { ret . column_end ++ ; if ( errorCtx . buffer [ i ] == ' \n ' ) { ret . line_end ++ ; ret . column_end = 1 ; } } return ret ; }
This is bad and incomplete
 It hosts who knows how many bugs
 I will fix this.
This is bad and incomplete It hosts who knows how many bugs I will fix this .