Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6473239

Off-by-one bug in tab computation

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      LineTabMapImpl.getPosition() in b99 is implmented as follows:

      public int getPosition(int line, int column) {
      int pos = startPosition[line - FIRSTLINE];
      column -= FIRSTCOLUMN;
      int col = 0;
      while (col < column) {
      pos++;
      if (tabMap.get(pos))
      col = (col / TabInc * TabInc) + TabInc;
      else
      col++;
      }
      return pos;
      }

      but it should be:

      public int getPosition(int line, int column) {
      int pos = startPosition[line - FIRSTLINE];
      column -= FIRSTCOLUMN;
      int col = 0;
      while (col < column) {
      if (tabMap.get(pos++))
      col = (col / TabInc * TabInc) + TabInc;
      else
      col++;
      }
      return pos;
      }

      notice that the current code invokes tabMap.get() with a wrong index.

        Attachments

          Activity

            People

            • Assignee:
              jjg Jonathan Gibbons
              Reporter:
              kkawagucsunw Kohsuke Kawaguchi (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: