if (cat == WS) { thisIndent = 1; state = IN_INDENT; } else { state = IN_TEXT; }
lineOffsets.putEnd(); break; } lineOffsets.putStart(p); if (cat == WS) { thisIndent = 1; state = IN_INDENT;
    private void scan() {        int indent = Integer.MAX_VALUE;        int l = content.length;        int p = 0;        int cat;        int state = IN_PRELUDE;        int thisIndent = 0;        int whiteSpaceStart = 0;        while (p <= l) {            if (p == l)                cat = NL;            else                cat = category(content[p]);            switch (state) {            case IN_PRELUDE:                if (cat == NORM) {                    lineOffsets.putStart(p);                    state = IN_TEXT;                } else if (cat == NL)                    state = IN_NL;                break;            case IN_NL:                if (cat != NL) {                    lineOffsets.putStart(p);                    if (cat == WS) {                        thisIndent = 1;                        state = IN_INDENT;                    } else {                        state = IN_TEXT;                    }                } else {                    lineOffsets.putStart(p);                    lineOffsets.putEnd(p);                }                break;            case IN_INDENT:                if (cat == NORM) {                    indent = Math.min(indent, thisIndent);                    state = IN_TEXT;                } else if (cat == WS) {                    thisIndent++;                } else if (cat == NL) {                    lineOffsets.putEnd(lineOffsets.getStart(lineOffsets.size()));                    state = IN_NL;                }                break;            case IN_TEXT:                if (cat == WS) {                    whiteSpaceStart = p;                    state = IN_WHITE_SPACE;                } else if (cat == NL) {                    lineOffsets.putEnd(p);                    state = IN_NL;                }                break;            case IN_WHITE_SPACE:                if (cat == NORM) {                    state = IN_TEXT;                } else if (cat == NL) {                    lineOffsets.putEnd(whiteSpaceStart);                    state = IN_NL;                }                break;            }            p++;        }        for (int i = 0; i < lineOffsets.size(); i++) {            System.out.println(lineOffsets.getStart(i) + ":" + lineOffsets.getEnd(i));        }        for (int i = 0; i < lineOffsets.size(); i++) {            System.out.println(new String(content, lineOffsets.getStart(i),                                             lineOffsets.getEnd(i) - lineOffsets.getStart(i)));        }        if (indent != Integer.MAX_VALUE && indent > 0) {            lineOffsets.setIndent(indent);            System.out.println("min indent: " + indent);        }        System.out.println("final state: " + state);    }