| 111 | Read each file in 'file_list', in order. */ |
| 112 | |
| 113 | static void |
| 114 | unexpand (void) |
| 115 | { |
| 116 | /* Input stream. */ |
| 117 | FILE *fp = next_file (NULL); |
| 118 | |
| 119 | /* The array of pending blanks. In non-POSIX locales, blanks can |
| 120 | include characters other than spaces, so the blanks must be |
| 121 | stored, not merely counted. */ |
| 122 | char *pending_blank; |
| 123 | |
| 124 | if (!fp) |
| 125 | return; |
| 126 | |
| 127 | static char line_in[IO_BUFSIZE]; |
| 128 | mbbuf_t mbbuf; |
| 129 | mbbuf_init (&mbbuf, line_in, sizeof line_in, fp); |
| 130 | |
| 131 | /* The worst case is a non-blank character, then one blank, then a |
| 132 | tab stop, then MAX_COLUMN_WIDTH - 1 blanks, then a non-blank; so |
| 133 | allocate MAX_COLUMN_WIDTH bytes to store the blanks. */ |
| 134 | pending_blank = ximalloc (max_column_width * sizeof (char) * MB_LEN_MAX); |
| 135 | |
| 136 | while (true) |
| 137 | { |
| 138 | /* Input character, or EOF. */ |
| 139 | mcel_t g; |
| 140 | |
| 141 | /* If true, perform translations. */ |
| 142 | bool convert = true; |
| 143 | |
| 144 | |
| 145 | /* The following variables have valid values only when CONVERT |
| 146 | is true: */ |
| 147 | |
| 148 | /* Column of next input character. */ |
| 149 | colno column = 0; |
| 150 | |
| 151 | /* Column the next input tab stop is on. */ |
| 152 | colno next_tab_column = 0; |
| 153 | |
| 154 | /* Index in TAB_LIST of next tab stop to examine. */ |
| 155 | idx_t tab_index = 0; |
| 156 | |
| 157 | /* If true, the first pending blank came just before a tab stop. */ |
| 158 | bool one_blank_before_tab_stop = false; |
| 159 | |
| 160 | /* If true, the previous input character was a blank. This is |
| 161 | initially true, since initial strings of blanks are treated |
| 162 | as if the line was preceded by a blank. */ |
| 163 | bool prev_blank = true; |
| 164 | |
| 165 | /* Number of pending columns of blanks. */ |
| 166 | idx_t pending = 0; |
| 167 | |
| 168 | |
| 169 | /* Convert a line of text. */ |
| 170 |
no test coverage detected