Piotr Pawel Stefaniak 63c3f22696 indent(1): improve predictability of lexi()
lexi() reads the input stream and categorizes the next token. indent will
sometimes buffer up a sequence of tokens in order rearrange them. That is
needed for properly cuddling else or placing braces correctly according to
the chosen style (KNF vs Allman) when comments are around. The loop that
buffers tokens up uses lexi() to decide if it's time to stop buffering. Then
the temporary buffer is used to feed lexi() the same tokens again, this time
for normal processing.

The problem is that lexi() apart from recognizing the token, can change
a lot of information about the current state, for example ps.last_nl,
ps.keyword, buf_ptr. It also abandons leading whitespace, which is needed
mainly for comment-related considerations. So the call to lexi() while
tokens are buffered up and categorized can change the state before they're
read again for normal processing which may easily result in changing
interpretation of the current state and lead to incorrect output.

To work around the problems:
1) copy the whitespace into the save_com buffer so that it will be read
again when processed
2) trick lexi() into modifying a temporary copy of the parser state instead
of the original.
2018-06-03 14:13:11 +00:00
..
2018-06-01 22:57:19 +00:00
2017-10-31 00:07:04 +00:00
2018-01-29 14:15:44 +00:00
2017-10-31 00:07:04 +00:00
2018-05-19 00:26:00 +00:00
2018-01-24 14:24:17 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2018-05-02 01:32:34 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2018-04-13 18:04:51 +00:00
2017-10-31 00:07:04 +00:00
2018-04-25 18:56:27 +00:00
2017-10-31 00:07:04 +00:00
2017-12-01 21:44:23 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2018-04-10 14:44:07 +00:00
2017-10-31 00:07:04 +00:00
2018-03-02 23:31:55 +00:00
2017-11-20 08:52:33 +00:00
2017-10-31 00:07:04 +00:00
2018-04-25 15:39:36 +00:00
2018-04-13 09:04:31 +00:00
2018-01-06 15:52:28 +00:00
2017-12-28 05:33:49 +00:00
2017-10-31 00:07:04 +00:00
2018-01-30 09:59:52 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2017-12-01 03:22:40 +00:00
2017-10-31 00:07:04 +00:00
2018-02-07 20:36:37 +00:00
2017-12-05 07:11:56 +00:00
2018-05-11 00:01:43 +00:00
2017-10-31 00:07:04 +00:00
2017-12-28 05:33:39 +00:00
2017-12-06 02:47:46 +00:00
2018-05-04 14:39:32 +00:00
2018-03-29 02:13:58 +00:00
2018-04-28 12:24:05 +00:00
2018-05-02 01:17:08 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2018-05-23 01:20:31 +00:00
2017-06-16 06:29:21 +00:00
2017-06-16 06:29:21 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00
2017-10-31 00:07:04 +00:00