src/share/jaxws_classes/com/sun/xml/internal/rngom/parse/compact/UCode_UCodeESC_CharStream.java

changeset 286
f50545b5e2f1
child 408
b0610cd08440
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/rngom/parse/compact/UCode_UCodeESC_CharStream.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,594 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +/*
    1.29 + * Copyright (C) 2004-2011
    1.30 + *
    1.31 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.32 + * of this software and associated documentation files (the "Software"), to deal
    1.33 + * in the Software without restriction, including without limitation the rights
    1.34 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    1.35 + * copies of the Software, and to permit persons to whom the Software is
    1.36 + * furnished to do so, subject to the following conditions:
    1.37 + *
    1.38 + * The above copyright notice and this permission notice shall be included in
    1.39 + * all copies or substantial portions of the Software.
    1.40 + *
    1.41 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.42 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.43 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.44 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.45 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    1.46 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    1.47 + * THE SOFTWARE.
    1.48 + */
    1.49 +/* Generated By:JavaCC: Do not edit this line. UCode_UCodeESC_CharStream.java Version 0.7pre6 */
    1.50 +/* The previous line keeps JavaCC quiet. In fact, the JavaCC generated file
    1.51 +   has been edited to fix some bugs. */
    1.52 +package com.sun.xml.internal.rngom.parse.compact;
    1.53 +
    1.54 +import com.sun.xml.internal.rngom.util.Utf16;
    1.55 +import com.sun.xml.internal.rngom.ast.builder.BuildException;
    1.56 +
    1.57 +import java.io.IOException;
    1.58 +
    1.59 +/**
    1.60 + * An implementation of interface CharStream, where the stream is assumed to
    1.61 + * contain 16-bit unicode characters.
    1.62 + */
    1.63 +public final class UCode_UCodeESC_CharStream {
    1.64 +  public static final boolean staticFlag = false;
    1.65 +
    1.66 +  static final int hexval(char c) {
    1.67 +    switch (c) {
    1.68 +    case '0':
    1.69 +      return 0;
    1.70 +    case '1':
    1.71 +      return 1;
    1.72 +    case '2':
    1.73 +      return 2;
    1.74 +    case '3':
    1.75 +      return 3;
    1.76 +    case '4':
    1.77 +      return 4;
    1.78 +    case '5':
    1.79 +      return 5;
    1.80 +    case '6':
    1.81 +      return 6;
    1.82 +    case '7':
    1.83 +      return 7;
    1.84 +    case '8':
    1.85 +      return 8;
    1.86 +    case '9':
    1.87 +      return 9;
    1.88 +
    1.89 +    case 'a':
    1.90 +    case 'A':
    1.91 +      return 10;
    1.92 +    case 'b':
    1.93 +    case 'B':
    1.94 +      return 11;
    1.95 +    case 'c':
    1.96 +    case 'C':
    1.97 +      return 12;
    1.98 +    case 'd':
    1.99 +    case 'D':
   1.100 +      return 13;
   1.101 +    case 'e':
   1.102 +    case 'E':
   1.103 +      return 14;
   1.104 +    case 'f':
   1.105 +    case 'F':
   1.106 +      return 15;
   1.107 +    }
   1.108 +    return -1;
   1.109 +  }
   1.110 +
   1.111 +  public int bufpos = -1;
   1.112 +  int bufsize;
   1.113 +  int available;
   1.114 +  int tokenBegin;
   1.115 +  private int bufline[];
   1.116 +  private int bufcolumn[];
   1.117 +
   1.118 +  private int column = 0;
   1.119 +  private int line = 1;
   1.120 +
   1.121 +  private java.io.Reader inputStream;
   1.122 +  private boolean closed = false;
   1.123 +
   1.124 +  private boolean prevCharIsLF = false;
   1.125 +
   1.126 +  private char[] nextCharBuf;
   1.127 +  private char[] buffer;
   1.128 +  private int maxNextCharInd = 0;
   1.129 +  private int nextCharInd = -1;
   1.130 +  private int inBuf = 0;
   1.131 +
   1.132 +  private final void ExpandBuff(boolean wrapAround) {
   1.133 +    char[] newbuffer = new char[bufsize + 2048];
   1.134 +    int newbufline[] = new int[bufsize + 2048];
   1.135 +    int newbufcolumn[] = new int[bufsize + 2048];
   1.136 +
   1.137 +    if (wrapAround) {
   1.138 +      System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
   1.139 +      System.arraycopy(buffer, 0, newbuffer,
   1.140 +                       bufsize - tokenBegin, bufpos);
   1.141 +      buffer = newbuffer;
   1.142 +
   1.143 +      System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
   1.144 +      System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
   1.145 +      bufline = newbufline;
   1.146 +
   1.147 +      System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
   1.148 +      System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
   1.149 +      bufcolumn = newbufcolumn;
   1.150 +
   1.151 +      bufpos += (bufsize - tokenBegin);
   1.152 +    }
   1.153 +    else {
   1.154 +      System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
   1.155 +      buffer = newbuffer;
   1.156 +
   1.157 +      System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
   1.158 +      bufline = newbufline;
   1.159 +
   1.160 +      System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
   1.161 +      bufcolumn = newbufcolumn;
   1.162 +
   1.163 +      bufpos -= tokenBegin;
   1.164 +    }
   1.165 +
   1.166 +    available = (bufsize += 2048);
   1.167 +    tokenBegin = 0;
   1.168 +  }
   1.169 +
   1.170 +  private final void FillBuff() throws EOFException {
   1.171 +    int i;
   1.172 +    if (maxNextCharInd == 4096)
   1.173 +      maxNextCharInd = nextCharInd = 0;
   1.174 +
   1.175 +    if (closed)
   1.176 +      throw new EOFException();
   1.177 +    try {
   1.178 +      if ((i = inputStream.read(nextCharBuf, maxNextCharInd, 4096 - maxNextCharInd)) == -1) {
   1.179 +        closed = true;
   1.180 +        inputStream.close();
   1.181 +        throw new EOFException();
   1.182 +      }
   1.183 +      else
   1.184 +        maxNextCharInd += i;
   1.185 +    }
   1.186 +    catch (IOException e) {
   1.187 +      throw new BuildException(e);
   1.188 +    }
   1.189 +  }
   1.190 +
   1.191 +  private final char ReadChar() throws EOFException {
   1.192 +    if (++nextCharInd >= maxNextCharInd)
   1.193 +      FillBuff();
   1.194 +
   1.195 +    return nextCharBuf[nextCharInd];
   1.196 +  }
   1.197 +
   1.198 +  private final char PeekChar() throws EOFException {
   1.199 +    char c = ReadChar();
   1.200 +    --nextCharInd;
   1.201 +    return c;
   1.202 +  }
   1.203 +
   1.204 +  public final char BeginToken() throws EOFException {
   1.205 +    if (inBuf > 0) {
   1.206 +      --inBuf;
   1.207 +      return buffer[tokenBegin = (bufpos == bufsize - 1) ? (bufpos = 0)
   1.208 +              : ++bufpos];
   1.209 +    }
   1.210 +
   1.211 +    tokenBegin = 0;
   1.212 +    bufpos = -1;
   1.213 +
   1.214 +    return readChar();
   1.215 +  }
   1.216 +
   1.217 +  private final void AdjustBuffSize() {
   1.218 +    if (available == bufsize) {
   1.219 +      if (tokenBegin > 2048) {
   1.220 +        bufpos = 0;
   1.221 +        available = tokenBegin;
   1.222 +      }
   1.223 +      else
   1.224 +        ExpandBuff(false);
   1.225 +    }
   1.226 +    else if (available > tokenBegin)
   1.227 +      available = bufsize;
   1.228 +    else if ((tokenBegin - available) < 2048)
   1.229 +      ExpandBuff(true);
   1.230 +    else
   1.231 +      available = tokenBegin;
   1.232 +  }
   1.233 +
   1.234 +  private final void UpdateLineColumn(char c) {
   1.235 +    column++;
   1.236 +
   1.237 +    if (prevCharIsLF) {
   1.238 +      prevCharIsLF = false;
   1.239 +      line += (column = 1);
   1.240 +    }
   1.241 +
   1.242 +    switch (c) {
   1.243 +    case NEWLINE_MARKER:
   1.244 +      prevCharIsLF = true;
   1.245 +      break;
   1.246 +    case '\t':
   1.247 +      column--;
   1.248 +      column += (8 - (column & 07));
   1.249 +      break;
   1.250 +    default :
   1.251 +      break;
   1.252 +    }
   1.253 +
   1.254 +    bufline[bufpos] = line;
   1.255 +    bufcolumn[bufpos] = column;
   1.256 +  }
   1.257 +
   1.258 +  private final char NEWLINE_MARKER = '\u0000';
   1.259 +
   1.260 +  public final char readChar() throws EOFException {
   1.261 +    if (inBuf > 0) {
   1.262 +      --inBuf;
   1.263 +      return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos];
   1.264 +    }
   1.265 +
   1.266 +    char c;
   1.267 +    try {
   1.268 +      c = ReadChar();
   1.269 +      switch (c) {
   1.270 +      case '\r':
   1.271 +        c = NEWLINE_MARKER;
   1.272 +        try {
   1.273 +          if (PeekChar() == '\n')
   1.274 +            ReadChar();
   1.275 +        }
   1.276 +        catch (EOFException e) {
   1.277 +        }
   1.278 +        break;
   1.279 +      case '\n':
   1.280 +        c = NEWLINE_MARKER;
   1.281 +        break;
   1.282 +      case '\t':
   1.283 +        break;
   1.284 +      default:
   1.285 +        if (c >= 0x20) {
   1.286 +          if (Utf16.isSurrogate(c)) {
   1.287 +            if (Utf16.isSurrogate2(c))
   1.288 +              throw new EscapeSyntaxException("illegal_surrogate_pair", line, column + 1);
   1.289 +            if (++bufpos == available)
   1.290 +              AdjustBuffSize();
   1.291 +            buffer[bufpos] = c;
   1.292 +            // UpdateLineColumn(c);
   1.293 +            try {
   1.294 +              c = ReadChar();
   1.295 +            }
   1.296 +            catch (EOFException e) {
   1.297 +              throw new EscapeSyntaxException("illegal_surrogate_pair", line, column + 1);
   1.298 +            }
   1.299 +            if (!Utf16.isSurrogate2(c))
   1.300 +              throw new EscapeSyntaxException("illegal_surrogate_pair", line, column + 2);
   1.301 +          }
   1.302 +          break;
   1.303 +        }
   1.304 +        // fall through
   1.305 +      case '\uFFFE':
   1.306 +      case '\uFFFF':
   1.307 +        throw new EscapeSyntaxException("illegal_char_code", line, column + 1);
   1.308 +      }
   1.309 +    }
   1.310 +    catch (EOFException e) {
   1.311 +      if (bufpos == -1) {
   1.312 +        if (++bufpos == available)
   1.313 +          AdjustBuffSize();
   1.314 +        bufline[bufpos] = line;
   1.315 +        bufcolumn[bufpos] = column;
   1.316 +      }
   1.317 +      throw e;
   1.318 +    }
   1.319 +    if (++bufpos == available)
   1.320 +      AdjustBuffSize();
   1.321 +    buffer[bufpos] = c;
   1.322 +    UpdateLineColumn(c);
   1.323 +    try {
   1.324 +      if (c != '\\' || PeekChar() != 'x')
   1.325 +        return c;
   1.326 +    }
   1.327 +    catch (EOFException e) {
   1.328 +      return c;
   1.329 +    }
   1.330 +
   1.331 +    int xCnt = 1;
   1.332 +    for (;;) {
   1.333 +      ReadChar();
   1.334 +      if (++bufpos == available)
   1.335 +        AdjustBuffSize();
   1.336 +      buffer[bufpos] = 'x';
   1.337 +      UpdateLineColumn('x');
   1.338 +      try {
   1.339 +        c = PeekChar();
   1.340 +      }
   1.341 +      catch (EOFException e) {
   1.342 +        backup(xCnt);
   1.343 +        return '\\';
   1.344 +      }
   1.345 +      if (c == '{') {
   1.346 +        ReadChar();
   1.347 +        column++;
   1.348 +        // backup past the 'x's
   1.349 +        bufpos -= xCnt;
   1.350 +        if (bufpos < 0)
   1.351 +          bufpos += bufsize;
   1.352 +        break;
   1.353 +      }
   1.354 +      if (c != 'x') {
   1.355 +        backup(xCnt);
   1.356 +        return '\\';
   1.357 +      }
   1.358 +      xCnt++;
   1.359 +    }
   1.360 +    try {
   1.361 +      int scalarValue = hexval(ReadChar());
   1.362 +      column++;
   1.363 +      if (scalarValue < 0)
   1.364 +        throw new EscapeSyntaxException("illegal_hex_digit", line, column);
   1.365 +      while ((c = ReadChar()) != '}') {
   1.366 +        column++;
   1.367 +        int n = hexval(c);
   1.368 +        if (n < 0)
   1.369 +          throw new EscapeSyntaxException("illegal_hex_digit", line, column);
   1.370 +        scalarValue <<= 4;
   1.371 +        scalarValue |= n;
   1.372 +        if (scalarValue >= 0x110000)
   1.373 +          throw new EscapeSyntaxException("char_code_too_big", line, column);
   1.374 +      }
   1.375 +      column++; // for the '}'
   1.376 +      if (scalarValue <= 0xFFFF) {
   1.377 +        c = (char)scalarValue;
   1.378 +        switch (c) {
   1.379 +        case '\n':
   1.380 +        case '\r':
   1.381 +        case '\t':
   1.382 +          break;
   1.383 +        default:
   1.384 +          if (c >= 0x20 && !Utf16.isSurrogate(c))
   1.385 +            break;
   1.386 +          // fall through
   1.387 +        case '\uFFFE':
   1.388 +        case '\uFFFF':
   1.389 +          throw new EscapeSyntaxException("illegal_char_code_ref", line, column);
   1.390 +        }
   1.391 +        buffer[bufpos] = c;
   1.392 +        return c;
   1.393 +      }
   1.394 +      c = Utf16.surrogate1(scalarValue);
   1.395 +      buffer[bufpos] = c;
   1.396 +      int bufpos1 = bufpos;
   1.397 +      if (++bufpos == bufsize)
   1.398 +        bufpos = 0;
   1.399 +      buffer[bufpos] = Utf16.surrogate2(scalarValue);
   1.400 +      bufline[bufpos] = bufline[bufpos1];
   1.401 +      bufcolumn[bufpos] = bufcolumn[bufpos1];
   1.402 +      backup(1);
   1.403 +      return c;
   1.404 +    }
   1.405 +    catch (EOFException e) {
   1.406 +      throw new EscapeSyntaxException("incomplete_escape", line, column);
   1.407 +    }
   1.408 +  }
   1.409 +
   1.410 +  /**
   1.411 +   * @deprecated
   1.412 +   * @see #getEndColumn
   1.413 +   */
   1.414 +
   1.415 +  public final int getColumn() {
   1.416 +    return bufcolumn[bufpos];
   1.417 +  }
   1.418 +
   1.419 +  /**
   1.420 +   * @deprecated
   1.421 +   * @see #getEndLine
   1.422 +   */
   1.423 +
   1.424 +  public final int getLine() {
   1.425 +    return bufline[bufpos];
   1.426 +  }
   1.427 +
   1.428 +  public final int getEndColumn() {
   1.429 +    return bufcolumn[bufpos];
   1.430 +  }
   1.431 +
   1.432 +  public final int getEndLine() {
   1.433 +    return bufline[bufpos];
   1.434 +  }
   1.435 +
   1.436 +  public final int getBeginColumn() {
   1.437 +    return bufcolumn[tokenBegin];
   1.438 +  }
   1.439 +
   1.440 +  public final int getBeginLine() {
   1.441 +    return bufline[tokenBegin];
   1.442 +  }
   1.443 +
   1.444 +  public final void backup(int amount) {
   1.445 +
   1.446 +    inBuf += amount;
   1.447 +    if ((bufpos -= amount) < 0)
   1.448 +      bufpos += bufsize;
   1.449 +  }
   1.450 +
   1.451 +  public UCode_UCodeESC_CharStream(java.io.Reader dstream,
   1.452 +                                   int startline, int startcolumn, int buffersize) {
   1.453 +    inputStream = dstream;
   1.454 +    line = startline;
   1.455 +    column = startcolumn - 1;
   1.456 +
   1.457 +    available = bufsize = buffersize;
   1.458 +    buffer = new char[buffersize];
   1.459 +    bufline = new int[buffersize];
   1.460 +    bufcolumn = new int[buffersize];
   1.461 +    nextCharBuf = new char[4096];
   1.462 +    skipBOM();
   1.463 +  }
   1.464 +
   1.465 +  public UCode_UCodeESC_CharStream(java.io.Reader dstream,
   1.466 +                                   int startline, int startcolumn) {
   1.467 +    this(dstream, startline, startcolumn, 4096);
   1.468 +  }
   1.469 +
   1.470 +  public void ReInit(java.io.Reader dstream,
   1.471 +                     int startline, int startcolumn, int buffersize) {
   1.472 +    inputStream = dstream;
   1.473 +    closed = false;
   1.474 +    line = startline;
   1.475 +    column = startcolumn - 1;
   1.476 +
   1.477 +    if (buffer == null || buffersize != buffer.length) {
   1.478 +      available = bufsize = buffersize;
   1.479 +      buffer = new char[buffersize];
   1.480 +      bufline = new int[buffersize];
   1.481 +      bufcolumn = new int[buffersize];
   1.482 +      nextCharBuf = new char[4096];
   1.483 +    }
   1.484 +    prevCharIsLF = false;
   1.485 +    tokenBegin = inBuf = maxNextCharInd = 0;
   1.486 +    nextCharInd = bufpos = -1;
   1.487 +    skipBOM();
   1.488 +  }
   1.489 +
   1.490 +  public void ReInit(java.io.Reader dstream,
   1.491 +                     int startline, int startcolumn) {
   1.492 +    ReInit(dstream, startline, startcolumn, 4096);
   1.493 +  }
   1.494 +
   1.495 +  public UCode_UCodeESC_CharStream(java.io.InputStream dstream, int startline,
   1.496 +                                   int startcolumn, int buffersize) {
   1.497 +    this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
   1.498 +  }
   1.499 +
   1.500 +  public UCode_UCodeESC_CharStream(java.io.InputStream dstream, int startline,
   1.501 +                                   int startcolumn) {
   1.502 +    this(dstream, startline, startcolumn, 4096);
   1.503 +  }
   1.504 +
   1.505 +  public void ReInit(java.io.InputStream dstream, int startline,
   1.506 +                     int startcolumn, int buffersize) {
   1.507 +    ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
   1.508 +  }
   1.509 +
   1.510 +  public void ReInit(java.io.InputStream dstream, int startline,
   1.511 +                     int startcolumn) {
   1.512 +    ReInit(dstream, startline, startcolumn, 4096);
   1.513 +  }
   1.514 +
   1.515 +  static private final char BOM = '\ufeff';
   1.516 +
   1.517 +  private void skipBOM() {
   1.518 +    try {
   1.519 +      if (PeekChar() == BOM)
   1.520 +        ReadChar();
   1.521 +    }
   1.522 +    catch (EOFException e) {
   1.523 +    }
   1.524 +  }
   1.525 +
   1.526 +  public final String GetImage() {
   1.527 +    if (bufpos >= tokenBegin)
   1.528 +      return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
   1.529 +    else
   1.530 +      return new String(buffer, tokenBegin, bufsize - tokenBegin) +
   1.531 +              new String(buffer, 0, bufpos + 1);
   1.532 +  }
   1.533 +
   1.534 +  public final char[] GetSuffix(int len) {
   1.535 +    char[] ret = new char[len];
   1.536 +
   1.537 +    if ((bufpos + 1) >= len)
   1.538 +      System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
   1.539 +    else {
   1.540 +      System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
   1.541 +                       len - bufpos - 1);
   1.542 +      System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
   1.543 +    }
   1.544 +
   1.545 +    return ret;
   1.546 +  }
   1.547 +
   1.548 +  public void Done() {
   1.549 +    nextCharBuf = null;
   1.550 +    buffer = null;
   1.551 +    bufline = null;
   1.552 +    bufcolumn = null;
   1.553 +  }
   1.554 +
   1.555 +  /**
   1.556 +   * Method to adjust line and column numbers for the start of a token.<BR>
   1.557 +   */
   1.558 +  public void adjustBeginLineColumn(int newLine, int newCol) {
   1.559 +    int start = tokenBegin;
   1.560 +    int len;
   1.561 +
   1.562 +    if (bufpos >= tokenBegin) {
   1.563 +      len = bufpos - tokenBegin + inBuf + 1;
   1.564 +    }
   1.565 +    else {
   1.566 +      len = bufsize - tokenBegin + bufpos + 1 + inBuf;
   1.567 +    }
   1.568 +
   1.569 +    int i = 0, j = 0, k = 0;
   1.570 +    int nextColDiff = 0, columnDiff = 0;
   1.571 +
   1.572 +    while (i < len &&
   1.573 +            bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
   1.574 +      bufline[j] = newLine;
   1.575 +      nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
   1.576 +      bufcolumn[j] = newCol + columnDiff;
   1.577 +      columnDiff = nextColDiff;
   1.578 +      i++;
   1.579 +    }
   1.580 +
   1.581 +    if (i < len) {
   1.582 +      bufline[j] = newLine++;
   1.583 +      bufcolumn[j] = newCol + columnDiff;
   1.584 +
   1.585 +      while (i++ < len) {
   1.586 +        if (bufline[j = start % bufsize] != bufline[++start % bufsize])
   1.587 +          bufline[j] = newLine++;
   1.588 +        else
   1.589 +          bufline[j] = newLine;
   1.590 +      }
   1.591 +    }
   1.592 +
   1.593 +    line = bufline[j];
   1.594 +    column = bufcolumn[j];
   1.595 +  }
   1.596 +
   1.597 +}

mercurial