ExpandTabsReader.java revision 924
922N/A * The contents of this file are subject to the terms of the 922N/A * Common Development and Distribution License (the "License"). 922N/A * You may not use this file except in compliance with the License. 922N/A * language governing permissions and limitations under the License. 922N/A * When distributing Covered Code, include this CDDL HEADER in each 922N/A * If applicable, add the following below this CDDL HEADER, with the 922N/A * fields enclosed by brackets "[]" replaced with your own identifying 922N/A * information: Portions Copyright [yyyy] [name of copyright owner] 922N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 922N/A * Use is subject to license terms. 922N/A * Wrapper around Reader to expand tabs to spaces in the input. 922N/A /** The size of tabs. */ 922N/A * The position on the current line. Used to decide how many spaces to 922N/A * insert to fill up to the next tab stop. 922N/A * Number of spaces to insert (as replacement for a tab) before reading 922N/A * more from the underlying stream. 922N/A * Create a new ExpandTabsReader to expand tabs to spaces. 922N/A * @param in the original input source 922N/A * @param tabSize the size of tabs 922N/A * Wrap a reader in an ExpandTabsReader if the project has custom tab 922N/A * @param in the reader to wrap 922N/A * @return {@code in} if the project doesn't have custom tab settings; 922N/A * otherwise, an {@code ExpandTabsReader} that wraps {@code in} and expands 922N/A * tabs as defined by the project's settings 922N/A // Fill up with spaces up to the next tab stop 922N/A if (c ==
'\n' || c ==
'\r') {
922N/A // Reset position on new line 922N/A return (i >
0 ? i : -
1);
922N/A for (
long l =
0; l < n; l++) {