private static final int[] findLineAndColumn(final int idx,final String message){
  int[] val={-1,-1,message.length()};
  int beginIndex=message.indexOf("line ",idx);
  int offset=5;
  if (beginIndex != idx) {
    beginIndex=-1;
  }
  if (beginIndex == -1) {
    beginIndex=message.indexOf(" line ",idx);
    offset=6;
  }
  if (beginIndex != -1) {
    beginIndex=beginIndex + offset;
    while ((beginIndex < message.length()) && !Character.isDigit(message.charAt(beginIndex))) {
      beginIndex++;
    }
    int endIndex=beginIndex + 1;
    while ((endIndex < message.length()) && Character.isDigit(message.charAt(endIndex))) {
      endIndex++;
    }
    if (beginIndex < message.length()) {
      try {
        val[0]=Integer.parseInt(message.substring(beginIndex,endIndex));
      }
 catch (      Exception e) {
        val[0]=-1;
      }
      beginIndex=message.indexOf(" column ",endIndex);
      int colOffset=0;
      if (beginIndex != -1) {
        colOffset=8;
      }
      int otherIndex=message.indexOf(" col ",endIndex);
      if ((otherIndex != -1) && ((beginIndex == -1) || (otherIndex < beginIndex))) {
        beginIndex=otherIndex;
        colOffset=5;
      }
      if (beginIndex != -1) {
        beginIndex=beginIndex + colOffset;
        while ((beginIndex < message.length()) && !Character.isDigit(message.charAt(beginIndex))) {
          beginIndex++;
        }
        endIndex=beginIndex + 1;
        while ((endIndex < message.length()) && Character.isDigit(message.charAt(endIndex))) {
          endIndex++;
        }
        if (beginIndex < message.length()) {
          try {
            val[1]=Integer.parseInt(message.substring(beginIndex,endIndex));
          }
 catch (          Exception e) {
            val[1]=-1;
          }
          val[2]=endIndex;
        }
      }
    }
  }
  return val;
}

private static final int [ ] findLineAndColumn ( final int idx , final String message ) { int [ ] val = { - 1 , - 1 , message . length ( ) } ; int beginIndex = message . indexOf ( "line " , idx ) ; int offset = 5 ; if ( beginIndex != idx ) { beginIndex = - 1 ; } if ( beginIndex == - 1 ) { beginIndex = message . indexOf ( " line " , idx ) ; offset = 6 ; } if ( beginIndex != - 1 ) { beginIndex = beginIndex + offset ; while ( ( beginIndex < message . length ( ) ) && ! Character . isDigit ( message . charAt ( beginIndex ) ) ) { beginIndex ++ ; } int endIndex = beginIndex + 1 ; while ( ( endIndex < message . length ( ) ) && Character . isDigit ( message . charAt ( endIndex ) ) ) { endIndex ++ ; } if ( beginIndex < message . length ( ) ) { try { val [ 0 ] = Integer . parseInt ( message . substring ( beginIndex , endIndex ) ) ; } catch ( Exception e ) { val [ 0 ] = - 1 ; } beginIndex = message . indexOf ( " column " , endIndex ) ; int colOffset = 0 ; if ( beginIndex != - 1 ) { colOffset = 8 ; } int otherIndex = message . indexOf ( " col " , endIndex ) ; if ( ( otherIndex != - 1 ) && ( ( beginIndex == - 1 ) || ( otherIndex < beginIndex ) ) ) { beginIndex = otherIndex ; colOffset = 5 ; } if ( beginIndex != - 1 ) { beginIndex = beginIndex + colOffset ; while ( ( beginIndex < message . length ( ) ) && ! Character . isDigit ( message . charAt ( beginIndex ) ) ) { beginIndex ++ ; } endIndex = beginIndex + 1 ; while ( ( endIndex < message . length ( ) ) && Character . isDigit ( message . charAt ( endIndex ) ) ) { endIndex ++ ; } if ( beginIndex < message . length ( ) ) { try { val [ 1 ] = Integer . parseInt ( message . substring ( beginIndex , endIndex ) ) ; } catch ( Exception e ) { val [ 1 ] = - 1 ; } val [ 2 ] = endIndex ; } } } } return val ; }
looks for line and column number in str starting at idx , and returns a 3 - element array val with val [ 0 ] = the line number and val [ 1 ] = the column number , and val [ 2 ] the index at the end of the column number . it returns - 1 for a number it doesn ' t find , and may leave val [ 3 ] off the end of the array . it works ( but of course finds nothing if idx > = str . length ( ) . this is a kludge that assumes that the line number is preceded either by " line " or by " line " that begins the error message , and that the column number is preceded by either " column " or " col " . bug found on 17 oct 2010 : on some errors , sany returns an error message with location line 2147483647 , col 2147483647 to line - 2147483648 , col - 2147483648 one such error is caused by by def foo . x ' in a proof . such a line or column number produces a java . lang . numberformatexception when integer . parseint is called to parse it . perhaps this should be fixed in sany . however , even if that were to be fixed , it seems like a good idea to catch the exception here in case there are other cases in which sany produces a malformed location . so this was done by ll on 17 oct 2010 . the fix is to return values of - 1 when an exception is thrown , hoping that the comment is accurate and the return value of - 1 is expected by the caller .
