putty/test
Simon Tatham 8d186c3c93 Formatting change to braces around one case of a switch.
Sometimes, within a switch statement, you want to declare local
variables specific to the handler for one particular case. Until now
I've mostly been writing this in the form

    switch (discriminant) {
      case SIMPLE:
        do stuff;
        break;
      case COMPLICATED:
        {
            declare variables;
            do stuff;
        }
        break;
    }

which is ugly because the two pieces of essentially similar code
appear at different indent levels, and also inconvenient because you
have less horizontal space available to write the complicated case
handler in - particuarly undesirable because _complicated_ case
handlers are the ones most likely to need all the space they can get!

After encountering a rather nicer idiom in the LLVM source code, and
after a bit of hackery this morning figuring out how to persuade
Emacs's auto-indent to do what I wanted with it, I've decided to move
to an idiom in which the open brace comes right after the case
statement, and the code within it is indented the same as it would
have been without the brace. Then the whole case handler (including
the break) lives inside those braces, and you get something that looks
more like this:

    switch (discriminant) {
      case SIMPLE:
        do stuff;
        break;
      case COMPLICATED: {
        declare variables;
        do stuff;
        break;
      }
    }

This commit is a big-bang change that reformats all the complicated
case handlers I could find into the new layout. This is particularly
nice in the Pageant main function, in which almost _every_ case
handler had a bundle of variables and was long and complicated. (In
fact that's what motivated me to get round to this.) Some of the
innermost parts of the terminal escape-sequence handling are also
breathing a bit easier now the horizontal pressure on them is
relieved.

(Also, in a few cases, I was able to remove the extra braces
completely, because the only variable local to the case handler was a
loop variable which our new C99 policy allows me to move into the
initialiser clause of its for statement.)

Viewed with whitespace ignored, this is not too disruptive a change.
Downstream patches that conflict with it may need to be reapplied
using --ignore-whitespace or similar.
2020-02-16 11:26:21 +00:00
..
sclog Formatting change to braces around one case of a switch. 2020-02-16 11:26:21 +00:00
agenttest.py New test script 'agenttest.py' for testing Pageant. 2020-01-09 19:57:35 +00:00
agenttestdata.py New test script 'agenttest.py' for testing Pageant. 2020-01-09 19:57:35 +00:00
agenttestgen.py New test script 'agenttest.py' for testing Pageant. 2020-01-09 19:57:35 +00:00
colours.txt Rename the 'testdata' subdirectory to 'test'. 2019-01-03 16:56:02 +00:00
cryptsuite.py sshprng.c: remove pointless pending_output buffer. 2020-01-26 16:37:48 +00:00
desref.py Whitespace rationalisation of entire code base. 2019-09-08 20:29:21 +01:00
display.txt Rename the 'testdata' subdirectory to 'test'. 2019-01-03 16:56:02 +00:00
eccref.py eccref.py: add a couple more methods to ModP. 2019-01-03 16:56:02 +00:00
lattrs.txt Rename the 'testdata' subdirectory to 'test'. 2019-01-03 16:56:02 +00:00
scocols.txt Rename the 'testdata' subdirectory to 'test'. 2019-01-03 16:56:02 +00:00
ssh.py New test script 'agenttest.py' for testing Pageant. 2020-01-09 19:57:35 +00:00
testcrypt.py testcrypt: handle int as a return type. 2020-01-09 19:57:35 +00:00
utf8.txt Rename the 'testdata' subdirectory to 'test'. 2019-01-03 16:56:02 +00:00
vt100.txt Rename the 'testdata' subdirectory to 'test'. 2019-01-03 16:56:02 +00:00