From 3a42a09dadcb38e4f3481a4dd8b4c2bad5b6de4b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 3 Aug 2022 20:48:46 +0100 Subject: [PATCH] Formatting: normalise back to 4-space indentation. In several pieces of development recently I've run across the occasional code block in the middle of a function which suddenly switched to 2-space indent from this code base's usual 4. I decided I was tired of it, so I ran the whole code base through a re-indenter, which made a huge mess, and then manually sifted out the changes that actually made sense from that pass. Indeed, this caught quite a few large sections with 2-space indent level, a couple with 8, and a handful of even weirder things like 3 spaces or 12. This commit fixes them all. --- charset/localenc.c | 2 +- charset/mimeenc.c | 2 +- charset/xenc.c | 2 +- cmdgen.c | 200 ++++++++++---------- crypto/blowfish.c | 2 +- import.c | 4 +- otherbackends/supdup.c | 18 +- otherbackends/telnet.c | 2 +- proxy/sshproxy.c | 8 +- proxy/telnet.c | 46 ++--- pscp.c | 4 +- psftp.c | 8 +- putty.h | 4 +- ssh/channel.h | 4 +- ssh/connection1-server.c | 10 +- ssh/connection2.c | 4 +- terminal/terminal.c | 2 +- test/fuzzterm.c | 46 ++--- test/sclog/sclog.c | 28 +-- unix/network.c | 10 +- unix/plink.c | 98 +++++----- windows/dialog.c | 4 +- windows/jump-list.c | 8 +- windows/network.c | 12 +- windows/pageant.c | 58 +++--- windows/puttygen.c | 8 +- windows/utils/security.c | 2 +- windows/window.c | 382 +++++++++++++++++++-------------------- 28 files changed, 489 insertions(+), 489 deletions(-) diff --git a/charset/localenc.c b/charset/localenc.c index 03340d6d..49719fbe 100644 --- a/charset/localenc.c +++ b/charset/localenc.c @@ -103,7 +103,7 @@ int charset_from_localenc(const char *name) p = name; q = localencs[i].name; while (*p || *q) { - if (tolower((unsigned char)*p) != tolower((unsigned char)*q)) + if (tolower((unsigned char)*p) != tolower((unsigned char)*q)) break; p++; q++; } diff --git a/charset/mimeenc.c b/charset/mimeenc.c index 2fec6d26..8a0203b3 100644 --- a/charset/mimeenc.c +++ b/charset/mimeenc.c @@ -207,7 +207,7 @@ int charset_from_mimeenc(const char *name) p = name; q = mimeencs[i].name; while (*p || *q) { - if (tolower((unsigned char)*p) != tolower((unsigned char)*q)) + if (tolower((unsigned char)*p) != tolower((unsigned char)*q)) break; p++; q++; } diff --git a/charset/xenc.c b/charset/xenc.c index 964ca6ff..24592ad1 100644 --- a/charset/xenc.c +++ b/charset/xenc.c @@ -82,7 +82,7 @@ int charset_from_xenc(const char *name) p = name; q = xencs[i].name; while (*p || *q) { - if (tolower((unsigned char)*p) != tolower((unsigned char)*q)) + if (tolower((unsigned char)*p) != tolower((unsigned char)*q)) break; p++; q++; } diff --git a/cmdgen.c b/cmdgen.c index 963464ea..8d82362f 100644 --- a/cmdgen.c +++ b/cmdgen.c @@ -299,73 +299,73 @@ int main(int argc, char **argv) while (*p && *p != '=') p++; /* find end of option */ if (*p == '=') { - *p++ = '\0'; - val = p; + *p++ = '\0'; + val = p; } else val = NULL; if (!strcmp(opt, "-help")) { - if (val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects no argument\n", opt); - } else { - help(); - nogo = true; - } + if (val) { + errs = true; + fprintf(stderr, "puttygen: option `-%s'" + " expects no argument\n", opt); + } else { + help(); + nogo = true; + } } else if (!strcmp(opt, "-version")) { - if (val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects no argument\n", opt); - } else { - showversion(); - nogo = true; - } + if (val) { + errs = true; + fprintf(stderr, "puttygen: option `-%s'" + " expects no argument\n", opt); + } else { + showversion(); + nogo = true; + } } else if (!strcmp(opt, "-pgpfp")) { - if (val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects no argument\n", opt); - } else { - /* support --pgpfp for consistency */ - pgp_fingerprints(); - nogo = true; - } + if (val) { + errs = true; + fprintf(stderr, "puttygen: option `-%s'" + " expects no argument\n", opt); + } else { + /* support --pgpfp for consistency */ + pgp_fingerprints(); + nogo = true; + } } else if (!strcmp(opt, "-old-passphrase")) { - if (!val && argc > 1) - --argc, val = *++argv; - if (!val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects an argument\n", opt); - } else { - old_passphrase = readpassphrase(val); - if (!old_passphrase) + if (!val && argc > 1) + --argc, val = *++argv; + if (!val) { errs = true; - } + fprintf(stderr, "puttygen: option `-%s'" + " expects an argument\n", opt); + } else { + old_passphrase = readpassphrase(val); + if (!old_passphrase) + errs = true; + } } else if (!strcmp(opt, "-new-passphrase")) { - if (!val && argc > 1) - --argc, val = *++argv; - if (!val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects an argument\n", opt); - } else { - new_passphrase = readpassphrase(val); - if (!new_passphrase) + if (!val && argc > 1) + --argc, val = *++argv; + if (!val) { errs = true; - } + fprintf(stderr, "puttygen: option `-%s'" + " expects an argument\n", opt); + } else { + new_passphrase = readpassphrase(val); + if (!new_passphrase) + errs = true; + } } else if (!strcmp(opt, "-random-device")) { - if (!val && argc > 1) - --argc, val = *++argv; - if (!val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects an argument\n", opt); - } else { - random_device = val; - } + if (!val && argc > 1) + --argc, val = *++argv; + if (!val) { + errs = true; + fprintf(stderr, "puttygen: option `-%s'" + " expects an argument\n", opt); + } else { + random_device = val; + } } else if (!strcmp(opt, "-dump")) { outtype = TEXT; } else if (!strcmp(opt, "-cert-info") || @@ -401,15 +401,15 @@ int main(int argc, char **argv) } else if (!strcmp(opt, "-strong-rsa")) { strong_rsa = true; } else if (!strcmp(opt, "-certificate")) { - if (!val && argc > 1) - --argc, val = *++argv; - if (!val) { - errs = true; - fprintf(stderr, "puttygen: option `-%s'" - " expects an argument\n", opt); - } else { - certfile = val; - } + if (!val && argc > 1) + --argc, val = *++argv; + if (!val) { + errs = true; + fprintf(stderr, "puttygen: option `-%s'" + " expects an argument\n", opt); + } else { + certfile = val; + } } else if (!strcmp(opt, "-remove-certificate")) { remove_cert = true; } else if (!strcmp(opt, "-reencrypt")) { @@ -490,9 +490,9 @@ int main(int argc, char **argv) } } } else { - errs = true; - fprintf(stderr, - "puttygen: no such option `-%s'\n", opt); + errs = true; + fprintf(stderr, + "puttygen: no such option `-%s'\n", opt); } p = NULL; break; @@ -1334,29 +1334,29 @@ int main(int argc, char **argv) FILE *fp; if (outfile) { - fp = f_open(outfilename, "w", false); - if (!fp) { - fprintf(stderr, "unable to open output file\n"); - exit(1); - } + fp = f_open(outfilename, "w", false); + if (!fp) { + fprintf(stderr, "unable to open output file\n"); + exit(1); + } } else { - fp = stdout; + fp = stdout; } if (sshver == 1) { - ssh1_write_pubkey(fp, ssh1key); + ssh1_write_pubkey(fp, ssh1key); } else { - if (!ssh2blob) { - assert(ssh2key); - ssh2blob = strbuf_new(); - ssh_key_public_blob(ssh2key->key, BinarySink_UPCAST(ssh2blob)); - } + if (!ssh2blob) { + assert(ssh2key); + ssh2blob = strbuf_new(); + ssh_key_public_blob(ssh2key->key, BinarySink_UPCAST(ssh2blob)); + } - ssh2_write_pubkey(fp, ssh2key ? ssh2key->comment : origcomment, - ssh2blob->s, ssh2blob->len, - (outtype == PUBLIC ? - SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 : - SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH)); + ssh2_write_pubkey(fp, ssh2key ? ssh2key->comment : origcomment, + ssh2blob->s, ssh2blob->len, + (outtype == PUBLIC ? + SSH_KEYTYPE_SSH2_PUBLIC_RFC4716 : + SSH_KEYTYPE_SSH2_PUBLIC_OPENSSH)); } if (outfile) @@ -1370,26 +1370,26 @@ int main(int argc, char **argv) char *fingerprint; if (sshver == 1) { - assert(ssh1key); - fingerprint = rsa_ssh1_fingerprint(ssh1key); + assert(ssh1key); + fingerprint = rsa_ssh1_fingerprint(ssh1key); } else { - if (ssh2key) { - fingerprint = ssh2_fingerprint(ssh2key->key, fptype); - } else { - assert(ssh2blob); - fingerprint = ssh2_fingerprint_blob( - ptrlen_from_strbuf(ssh2blob), fptype); - } + if (ssh2key) { + fingerprint = ssh2_fingerprint(ssh2key->key, fptype); + } else { + assert(ssh2blob); + fingerprint = ssh2_fingerprint_blob( + ptrlen_from_strbuf(ssh2blob), fptype); + } } if (outfile) { - fp = f_open(outfilename, "w", false); - if (!fp) { - fprintf(stderr, "unable to open output file\n"); - exit(1); - } + fp = f_open(outfilename, "w", false); + if (!fp) { + fprintf(stderr, "unable to open output file\n"); + exit(1); + } } else { - fp = stdout; + fp = stdout; } fprintf(fp, "%s\n", fingerprint); if (outfile) diff --git a/crypto/blowfish.c b/crypto/blowfish.c index e8886898..f86cb9a1 100644 --- a/crypto/blowfish.c +++ b/crypto/blowfish.c @@ -430,7 +430,7 @@ static void blowfish_msb_decrypt_cbc(unsigned char *blk, int len, } static void blowfish_msb_sdctr(unsigned char *blk, int len, - BlowfishContext * ctx) + BlowfishContext * ctx) { uint32_t b[2], iv0, iv1, tmp; diff --git a/import.c b/import.c index c62dfb15..926c98a9 100644 --- a/import.c +++ b/import.c @@ -1249,8 +1249,8 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, ret->kdfopts.bcrypt.rounds = get_uint32(opts); if (get_err(opts)) { - errmsg = "failed to parse bcrypt options string"; - goto error; + errmsg = "failed to parse bcrypt options string"; + goto error; } break; } diff --git a/otherbackends/supdup.c b/otherbackends/supdup.c index a272b256..54cfbef9 100644 --- a/otherbackends/supdup.c +++ b/otherbackends/supdup.c @@ -717,15 +717,15 @@ static char *supdup_init(const BackendVtable *x, Seat *seat, *backend_handle = &supdup->backend; switch (conf_get_int(supdup->conf, CONF_supdup_ascii_set)) { - case SUPDUP_CHARSET_ASCII: - supdup->print = print_ascii; - break; - case SUPDUP_CHARSET_ITS: - supdup->print = print_its; - break; - case SUPDUP_CHARSET_WAITS: - supdup->print = print_waits; - break; + case SUPDUP_CHARSET_ASCII: + supdup->print = print_ascii; + break; + case SUPDUP_CHARSET_ITS: + supdup->print = print_its; + break; + case SUPDUP_CHARSET_WAITS: + supdup->print = print_waits; + break; } /* diff --git a/otherbackends/telnet.c b/otherbackends/telnet.c index 1c0f5d68..73e8f0c4 100644 --- a/otherbackends/telnet.c +++ b/otherbackends/telnet.c @@ -452,7 +452,7 @@ static void process_subneg(Telnet *telnet) eval != NULL; eval = conf_get_str_strs(telnet->conf, CONF_environmt, ekey, &ekey)) - bsize += strlen(ekey) + strlen(eval) + 2; + bsize += strlen(ekey) + strlen(eval) + 2; user = get_remote_username(telnet->conf); if (user) bsize += 6 + strlen(user); diff --git a/proxy/sshproxy.c b/proxy/sshproxy.c index 2aed2b6b..165c6c0a 100644 --- a/proxy/sshproxy.c +++ b/proxy/sshproxy.c @@ -431,8 +431,8 @@ static SeatPromptResult sshproxy_confirm_ssh_host_key( } static SeatPromptResult sshproxy_confirm_weak_crypto_primitive( - Seat *seat, const char *algtype, const char *algname, - void (*callback)(void *ctx, SeatPromptResult result), void *ctx) + Seat *seat, const char *algtype, const char *algname, + void (*callback)(void *ctx, SeatPromptResult result), void *ctx) { SshProxy *sp = container_of(seat, SshProxy, seat); @@ -457,8 +457,8 @@ static SeatPromptResult sshproxy_confirm_weak_crypto_primitive( } static SeatPromptResult sshproxy_confirm_weak_cached_hostkey( - Seat *seat, const char *algname, const char *betteralgs, - void (*callback)(void *ctx, SeatPromptResult result), void *ctx) + Seat *seat, const char *algname, const char *betteralgs, + void (*callback)(void *ctx, SeatPromptResult result), void *ctx) { SshProxy *sp = container_of(seat, SshProxy, seat); diff --git a/proxy/telnet.c b/proxy/telnet.c index 242c4025..a2efb7b4 100644 --- a/proxy/telnet.c +++ b/proxy/telnet.c @@ -85,31 +85,31 @@ char *format_telnet_command(SockAddr *addr, int port, Conf *conf, int i = 0; for (;;) { - eo++; - if (fmt[eo] >= '0' && fmt[eo] <= '9') - v += fmt[eo] - '0'; - else if (fmt[eo] >= 'a' && fmt[eo] <= 'f') - v += fmt[eo] - 'a' + 10; - else if (fmt[eo] >= 'A' && fmt[eo] <= 'F') - v += fmt[eo] - 'A' + 10; - else { - /* non hex character, so we abort and just - * send the whole thing unescaped (including \x) - */ - put_byte(buf, '\\'); - eo = so + 1; - break; - } - - /* we only extract two hex characters */ - if (i == 1) { - put_byte(buf, v); eo++; - break; - } + if (fmt[eo] >= '0' && fmt[eo] <= '9') + v += fmt[eo] - '0'; + else if (fmt[eo] >= 'a' && fmt[eo] <= 'f') + v += fmt[eo] - 'a' + 10; + else if (fmt[eo] >= 'A' && fmt[eo] <= 'F') + v += fmt[eo] - 'A' + 10; + else { + /* non hex character, so we abort and just + * send the whole thing unescaped (including \x) + */ + put_byte(buf, '\\'); + eo = so + 1; + break; + } - i++; - v <<= 4; + /* we only extract two hex characters */ + if (i == 1) { + put_byte(buf, v); + eo++; + break; + } + + i++; + v <<= 4; } break; } diff --git a/pscp.c b/pscp.c index 4df8cb95..d6cc1250 100644 --- a/pscp.c +++ b/pscp.c @@ -645,8 +645,8 @@ void scp_sftp_listdir(const char *dirname) dirh = fxp_opendir_recv(pktin, req); if (dirh == NULL) { - tell_user(stderr, "Unable to open %s: %s\n", dirname, fxp_error()); - errs++; + tell_user(stderr, "Unable to open %s: %s\n", dirname, fxp_error()); + errs++; } else { struct list_directory_from_sftp_ctx *ctx = list_directory_from_sftp_new(); diff --git a/psftp.c b/psftp.c index a1600cd9..db57d89d 100644 --- a/psftp.c +++ b/psftp.c @@ -2565,10 +2565,10 @@ static void usage(void) static void version(void) { - char *buildinfo_text = buildinfo("\n"); - printf("psftp: %s\n%s\n", ver, buildinfo_text); - sfree(buildinfo_text); - exit(0); + char *buildinfo_text = buildinfo("\n"); + printf("psftp: %s\n%s\n", ver, buildinfo_text); + sfree(buildinfo_text); + exit(0); } /* diff --git a/putty.h b/putty.h index 364297c3..c5d73e9d 100644 --- a/putty.h +++ b/putty.h @@ -1544,7 +1544,7 @@ const char *nullseat_get_x_display(Seat *seat); bool nullseat_get_windowid(Seat *seat, long *id_out); bool nullseat_get_window_pixel_size(Seat *seat, int *width, int *height); StripCtrlChars *nullseat_stripctrl_new( - Seat *seat, BinarySink *bs_out, SeatInteractionContext sic); + Seat *seat, BinarySink *bs_out, SeatInteractionContext sic); void nullseat_set_trust_status(Seat *seat, bool trusted); bool nullseat_can_set_trust_status_yes(Seat *seat); bool nullseat_can_set_trust_status_no(Seat *seat); @@ -1573,7 +1573,7 @@ SeatPromptResult console_confirm_weak_cached_hostkey( Seat *seat, const char *algname, const char *betteralgs, void (*callback)(void *ctx, SeatPromptResult result), void *ctx); StripCtrlChars *console_stripctrl_new( - Seat *seat, BinarySink *bs_out, SeatInteractionContext sic); + Seat *seat, BinarySink *bs_out, SeatInteractionContext sic); void console_set_trust_status(Seat *seat, bool trusted); bool console_can_set_trust_status(Seat *seat); bool console_has_mixed_input_stream(Seat *seat); diff --git a/ssh/channel.h b/ssh/channel.h index 14dfccb5..d4eb78aa 100644 --- a/ssh/channel.h +++ b/ssh/channel.h @@ -84,10 +84,10 @@ static inline bool chan_want_close(Channel *ch, bool leof, bool reof) static inline bool chan_rcvd_exit_status(Channel *ch, int status) { return ch->vt->rcvd_exit_status(ch, status); } static inline bool chan_rcvd_exit_signal( - Channel *ch, ptrlen sig, bool core, ptrlen msg) + Channel *ch, ptrlen sig, bool core, ptrlen msg) { return ch->vt->rcvd_exit_signal(ch, sig, core, msg); } static inline bool chan_rcvd_exit_signal_numeric( - Channel *ch, int sig, bool core, ptrlen msg) + Channel *ch, int sig, bool core, ptrlen msg) { return ch->vt->rcvd_exit_signal_numeric(ch, sig, core, msg); } static inline bool chan_run_shell(Channel *ch) { return ch->vt->run_shell(ch); } diff --git a/ssh/connection1-server.c b/ssh/connection1-server.c index 1123327c..cc69bdb3 100644 --- a/ssh/connection1-server.c +++ b/ssh/connection1-server.c @@ -113,15 +113,15 @@ bool ssh1_handle_direction_specific_packet( BinarySource_UPCAST(pktin), 1); if (get_err(pktin)) { - ppl_logevent("Unable to decode pty request packet"); - success = false; + ppl_logevent("Unable to decode pty request packet"); + success = false; } else if (!chan_allocate_pty( s->mainchan_chan, termtype, width, height, pixwidth, pixheight, modes)) { - ppl_logevent("Unable to allocate a pty"); - success = false; + ppl_logevent("Unable to allocate a pty"); + success = false; } else { - success = true; + success = true; } pktout = ssh_bpp_new_pktout( diff --git a/ssh/connection2.c b/ssh/connection2.c index ec330927..f2f07b17 100644 --- a/ssh/connection2.c +++ b/ssh/connection2.c @@ -1565,8 +1565,8 @@ static void ssh2_delete_sharing_channel(ConnectionLayer *cl, unsigned localid) } static void ssh2_send_packet_from_downstream( - ConnectionLayer *cl, unsigned id, int type, - const void *data, int datalen, const char *additional_log_text) + ConnectionLayer *cl, unsigned id, int type, + const void *data, int datalen, const char *additional_log_text) { struct ssh2_connection_state *s = container_of(cl, struct ssh2_connection_state, cl); diff --git a/terminal/terminal.c b/terminal/terminal.c index 04109415..b6d97c4b 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -1073,7 +1073,7 @@ static int sblines(Terminal *term) int sblines = count234(term->scrollback); if (term->erase_to_scrollback && term->alt_which && term->alt_screen) { - sblines += term->alt_sblines; + sblines += term->alt_sblines; } return sblines; } diff --git a/test/fuzzterm.c b/test/fuzzterm.c index 8d20bef9..0d4597b1 100644 --- a/test/fuzzterm.c +++ b/test/fuzzterm.c @@ -10,34 +10,34 @@ static const TermWinVtable fuzz_termwin_vt; int main(int argc, char **argv) { - char blk[512]; - size_t len; - Terminal *term; - Conf *conf; - struct unicode_data ucsdata; - TermWin termwin; + char blk[512]; + size_t len; + Terminal *term; + Conf *conf; + struct unicode_data ucsdata; + TermWin termwin; - termwin.vt = &fuzz_termwin_vt; + termwin.vt = &fuzz_termwin_vt; - conf = conf_new(); - do_defaults(NULL, conf); - init_ucs(&ucsdata, conf_get_str(conf, CONF_line_codepage), - conf_get_bool(conf, CONF_utf8_override), - CS_NONE, conf_get_int(conf, CONF_vtmode)); + conf = conf_new(); + do_defaults(NULL, conf); + init_ucs(&ucsdata, conf_get_str(conf, CONF_line_codepage), + conf_get_bool(conf, CONF_utf8_override), + CS_NONE, conf_get_int(conf, CONF_vtmode)); - term = term_init(conf, &ucsdata, &termwin); - term_size(term, 24, 80, 10000); - term->ldisc = NULL; - /* Tell american fuzzy lop that this is a good place to fork. */ + term = term_init(conf, &ucsdata, &termwin); + term_size(term, 24, 80, 10000); + term->ldisc = NULL; + /* Tell american fuzzy lop that this is a good place to fork. */ #ifdef __AFL_HAVE_MANUAL_CONTROL - __AFL_INIT(); + __AFL_INIT(); #endif - while (!feof(stdin)) { - len = fread(blk, 1, sizeof(blk), stdin); - term_data(term, blk, len); - } - term_update(term); - return 0; + while (!feof(stdin)) { + len = fread(blk, 1, sizeof(blk), stdin); + term_data(term, blk, len); + } + term_update(term); + return 0; } /* functions required by terminal.c */ diff --git a/test/sclog/sclog.c b/test/sclog/sclog.c index f12a0280..d8e61a05 100644 --- a/test/sclog/sclog.c +++ b/test/sclog/sclog.c @@ -479,20 +479,20 @@ static dr_emit_flags_t instrument_instr( */ opnd_t shiftcount = instr_get_src(instr, 0); if (!opnd_is_immed(shiftcount)) { - reg_id_t r0; - drreg_status_t st; - st = drreg_reserve_register(drcontext, bb, instr, NULL, &r0); - DR_ASSERT(st == DRREG_SUCCESS); - opnd_t op_r0 = opnd_create_reg(r0); - instr_t *movzx = INSTR_CREATE_movzx(drcontext, op_r0, shiftcount); - instr_set_translation(movzx, instr_get_app_pc(instr)); - instrlist_preinsert(bb, instr, movzx); - instr_format_location(instr, &loc); - dr_insert_clean_call( - drcontext, bb, instr, (void *)log_var_shift, false, - 2, op_r0, OPND_CREATE_INTPTR(loc)); - st = drreg_unreserve_register(drcontext, bb, instr, r0); - DR_ASSERT(st == DRREG_SUCCESS); + reg_id_t r0; + drreg_status_t st; + st = drreg_reserve_register(drcontext, bb, instr, NULL, &r0); + DR_ASSERT(st == DRREG_SUCCESS); + opnd_t op_r0 = opnd_create_reg(r0); + instr_t *movzx = INSTR_CREATE_movzx(drcontext, op_r0, shiftcount); + instr_set_translation(movzx, instr_get_app_pc(instr)); + instrlist_preinsert(bb, instr, movzx); + instr_format_location(instr, &loc); + dr_insert_clean_call( + drcontext, bb, instr, (void *)log_var_shift, false, + 2, op_r0, OPND_CREATE_INTPTR(loc)); + st = drreg_unreserve_register(drcontext, bb, instr, r0); + DR_ASSERT(st == DRREG_SUCCESS); } break; } diff --git a/unix/network.c b/unix/network.c index 1734d61c..e95af9f7 100644 --- a/unix/network.c +++ b/unix/network.c @@ -150,9 +150,9 @@ static int cmpfortree(void *av, void *bv) if (as > bs) return +1; if (a < b) - return -1; + return -1; if (a > b) - return +1; + return +1; return 0; } @@ -655,14 +655,14 @@ static int try_connect(NetSocket *sock) } else { err = errno; if (err != EADDRINUSE) /* failed, for a bad reason */ - break; + break; } if (localport == 0) - break; /* we're only looping once */ + break; /* we're only looping once */ localport--; if (localport == 0) - break; /* we might have got to the end */ + break; /* we might have got to the end */ } if (err) diff --git a/unix/plink.c b/unix/plink.c index a02bbe17..f0c73754 100644 --- a/unix/plink.c +++ b/unix/plink.c @@ -442,57 +442,57 @@ static void from_tty(void *vbuf, unsigned len) p = buf; end = buf + len; while (p < end) { switch (state) { - case NORMAL: - if (*p == '\xff') { - p++; - state = FF; - } else { - q = memchr(p, '\xff', end - p); - if (q == NULL) q = end; - backend_send(backend, p, q - p); - p = q; - } - break; - case FF: - if (*p == '\xff') { - backend_send(backend, p, 1); - p++; - state = NORMAL; - } else if (*p == '\0') { - p++; - state = FF00; - } else abort(); - break; - case FF00: - if (*p == '\0') { - backend_special(backend, SS_BRK, 0); - } else { - /* - * Pretend that PARMRK wasn't set. This involves - * faking what INPCK and IGNPAR would have done if - * we hadn't overridden them. Unfortunately, we - * can't do this entirely correctly because INPCK - * distinguishes between framing and parity - * errors, but PARMRK format represents both in - * the same way. We assume that parity errors are - * more common than framing errors, and hence - * treat all input errors as being subject to - * INPCK. - */ - if (orig_termios.c_iflag & INPCK) { - /* If IGNPAR is set, we throw away the character. */ - if (!(orig_termios.c_iflag & IGNPAR)) { - /* PE/FE get passed on as NUL. */ - *p = 0; - backend_send(backend, p, 1); - } - } else { - /* INPCK not set. Assume we got a parity error. */ - backend_send(backend, p, 1); - } - } + case NORMAL: + if (*p == '\xff') { + p++; + state = FF; + } else { + q = memchr(p, '\xff', end - p); + if (q == NULL) q = end; + backend_send(backend, p, q - p); + p = q; + } + break; + case FF: + if (*p == '\xff') { + backend_send(backend, p, 1); p++; state = NORMAL; + } else if (*p == '\0') { + p++; + state = FF00; + } else abort(); + break; + case FF00: + if (*p == '\0') { + backend_special(backend, SS_BRK, 0); + } else { + /* + * Pretend that PARMRK wasn't set. This involves + * faking what INPCK and IGNPAR would have done if + * we hadn't overridden them. Unfortunately, we + * can't do this entirely correctly because INPCK + * distinguishes between framing and parity + * errors, but PARMRK format represents both in + * the same way. We assume that parity errors are + * more common than framing errors, and hence + * treat all input errors as being subject to + * INPCK. + */ + if (orig_termios.c_iflag & INPCK) { + /* If IGNPAR is set, we throw away the character. */ + if (!(orig_termios.c_iflag & IGNPAR)) { + /* PE/FE get passed on as NUL. */ + *p = 0; + backend_send(backend, p, 1); + } + } else { + /* INPCK not set. Assume we got a parity error. */ + backend_send(backend, p, 1); + } + } + p++; + state = NORMAL; } } } diff --git a/windows/dialog.c b/windows/dialog.c index 85f16348..3666bfbc 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -582,9 +582,9 @@ static INT_PTR GenericMainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, c = strrchr(s->pathname, '/'); if (!c) - c = s->pathname; + c = s->pathname; else - c++; + c++; item = treeview_insert(&tvfaff, j, c, s->pathname); if (!hfirst) { diff --git a/windows/jump-list.c b/windows/jump-list.c index 37a17cc9..dd3143f9 100644 --- a/windows/jump-list.c +++ b/windows/jump-list.c @@ -716,10 +716,10 @@ void remove_session_from_jumplist(const char * const sessionname) bool set_explicit_app_user_model_id(void) { - DECL_WINDOWS_FUNCTION(static, HRESULT, SetCurrentProcessExplicitAppUserModelID, - (PCWSTR)); + DECL_WINDOWS_FUNCTION( + static, HRESULT, SetCurrentProcessExplicitAppUserModelID, (PCWSTR)); - static HMODULE shell32_module = 0; + static HMODULE shell32_module = 0; if (!shell32_module) { @@ -738,7 +738,7 @@ bool set_explicit_app_user_model_id(void) const wchar_t *id = get_app_user_model_id(); if (p_SetCurrentProcessExplicitAppUserModelID(id) == S_OK) { - return true; + return true; } return false; } diff --git a/windows/network.c b/windows/network.c index 4bb8dde3..72afbe37 100644 --- a/windows/network.c +++ b/windows/network.c @@ -927,7 +927,7 @@ static DWORD try_connect(NetSocket *sock) goto ret; } - SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0); + SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0); if (sock->oobinline) { BOOL b = true; @@ -1708,9 +1708,9 @@ void select_result(WPARAM wParam, LPARAM lParam) t = p_accept(s->s,(struct sockaddr *)&isa,&addrlen); if (t == INVALID_SOCKET) { - err = p_WSAGetLastError(); - if (err == WSATRY_AGAIN) - break; + err = p_WSAGetLastError(); + if (err == WSATRY_AGAIN) + break; } actx.p = (void *)t; @@ -1723,9 +1723,9 @@ void select_result(WPARAM wParam, LPARAM lParam) if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr)) #endif { - p_closesocket(t); /* dodgy WinSock let nonlocal through */ + p_closesocket(t); /* dodgy WinSock let nonlocal through */ } else if (plug_accepting(s->plug, sk_net_accept, actx)) { - p_closesocket(t); /* denied or error */ + p_closesocket(t); /* denied or error */ } break; } diff --git a/windows/pageant.c b/windows/pageant.c index accf0ccb..47423b2a 100644 --- a/windows/pageant.c +++ b/windows/pageant.c @@ -622,9 +622,9 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP); else { - HWND item = GetDlgItem(hwnd, IDC_KEYLIST_HELP); - if (item) - DestroyWindow(item); + HWND item = GetDlgItem(hwnd, IDC_KEYLIST_HELP); + if (item) + DestroyWindow(item); } keylist = hwnd; @@ -852,9 +852,9 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg, topic = WINHELP_CTX_pageant_deferred; break; } if (topic) { - launch_help(hwnd, topic); + launch_help(hwnd, topic); } else { - MessageBeep(0); + MessageBeep(0); } break; } @@ -1312,8 +1312,8 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline, _T(""), SW_SHOW) <= 32) { - MessageBox(NULL, "Unable to execute PuTTY!", - "Error", MB_OK | MB_ICONERROR); + MessageBox(NULL, "Unable to execute PuTTY!", + "Error", MB_OK | MB_ICONERROR); } break; } @@ -1371,25 +1371,25 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, break; default: { if(wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) { - MENUITEMINFO mii; - TCHAR buf[MAX_PATH + 1]; - TCHAR param[MAX_PATH + 1]; - memset(&mii, 0, sizeof(mii)); - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_TYPE; - mii.cch = MAX_PATH; - mii.dwTypeData = buf; - GetMenuItemInfo(session_menu, wParam, false, &mii); - param[0] = '\0'; - if (restrict_putty_acl) - strcat(param, "&R"); - strcat(param, "@"); - strcat(param, mii.dwTypeData); - if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param, - _T(""), SW_SHOW) <= 32) { - MessageBox(NULL, "Unable to execute PuTTY!", "Error", - MB_OK | MB_ICONERROR); - } + MENUITEMINFO mii; + TCHAR buf[MAX_PATH + 1]; + TCHAR param[MAX_PATH + 1]; + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_TYPE; + mii.cch = MAX_PATH; + mii.dwTypeData = buf; + GetMenuItemInfo(session_menu, wParam, false, &mii); + param[0] = '\0'; + if (restrict_putty_acl) + strcat(param, "&R"); + strcat(param, "@"); + strcat(param, mii.dwTypeData); + if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param, + _T(""), SW_SHOW) <= 32) { + MessageBox(NULL, "Unable to execute PuTTY!", "Error", + MB_OK | MB_ICONERROR); + } } break; } @@ -1425,10 +1425,10 @@ static LRESULT CALLBACK wm_copydata_WndProc(HWND hwnd, UINT message, err = answer_filemapping_message(mapname); if (err) { #ifdef DEBUG_IPC - debug("IPC failed: %s\n", err); + debug("IPC failed: %s\n", err); #endif - sfree(err); - return 0; + sfree(err); + return 0; } return 1; } diff --git a/windows/puttygen.c b/windows/puttygen.c index c7b39c97..4c836873 100644 --- a/windows/puttygen.c +++ b/windows/puttygen.c @@ -438,9 +438,9 @@ static INT_PTR CALLBACK PPKParamsProc(HWND hwnd, UINT msg, topic = WINHELP_CTX_puttygen_kdfparam; break; } if (topic) { - launch_help(hwnd, topic); + launch_help(hwnd, topic); } else { - MessageBeep(0); + MessageBeep(0); } break; } @@ -2353,9 +2353,9 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, topic = WINHELP_CTX_puttygen_conversions; break; } if (topic) { - launch_help(hwnd, topic); + launch_help(hwnd, topic); } else { - MessageBeep(0); + MessageBeep(0); } break; } diff --git a/windows/utils/security.c b/windows/utils/security.c index 1a4770b6..14e55090 100644 --- a/windows/utils/security.c +++ b/windows/utils/security.c @@ -175,7 +175,7 @@ bool make_private_security_descriptor(DWORD permissions, *error = NULL; if (!getsids(error)) - goto cleanup; + goto cleanup; memset(ea, 0, sizeof(ea)); ea[0].grfAccessPermissions = permissions; diff --git a/windows/window.c b/windows/window.c index b291c2a3..d810719b 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1923,7 +1923,7 @@ static void reset_window(int reinit) { static RECT ss; int width, height; - get_fullscreen_rect(&ss); + get_fullscreen_rect(&ss); width = (ss.right - ss.left - extra_width) / font_width; height = (ss.bottom - ss.top - extra_height) / font_height; @@ -2283,52 +2283,52 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, argprefix = ""; if (wParam == IDM_DUPSESS) { - /* - * Allocate a file-mapping memory chunk for the - * config structure. - */ - SECURITY_ATTRIBUTES sa; - strbuf *serbuf; - void *p; - int size; + /* + * Allocate a file-mapping memory chunk for the + * config structure. + */ + SECURITY_ATTRIBUTES sa; + strbuf *serbuf; + void *p; + int size; - serbuf = strbuf_new(); - conf_serialise(BinarySink_UPCAST(serbuf), conf); - size = serbuf->len; + serbuf = strbuf_new(); + conf_serialise(BinarySink_UPCAST(serbuf), conf); + size = serbuf->len; - sa.nLength = sizeof(sa); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = true; - filemap = CreateFileMapping(INVALID_HANDLE_VALUE, - &sa, - PAGE_READWRITE, - 0, size, NULL); - if (filemap && filemap != INVALID_HANDLE_VALUE) { - p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size); - if (p) { - memcpy(p, serbuf->s, size); - UnmapViewOfFile(p); + sa.nLength = sizeof(sa); + sa.lpSecurityDescriptor = NULL; + sa.bInheritHandle = true; + filemap = CreateFileMapping(INVALID_HANDLE_VALUE, + &sa, + PAGE_READWRITE, + 0, size, NULL); + if (filemap && filemap != INVALID_HANDLE_VALUE) { + p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size); + if (p) { + memcpy(p, serbuf->s, size); + UnmapViewOfFile(p); + } } - } - strbuf_free(serbuf); - inherit_handles = true; - cl = dupprintf("putty %s&%p:%u", argprefix, - filemap, (unsigned)size); + strbuf_free(serbuf); + inherit_handles = true; + cl = dupprintf("putty %s&%p:%u", argprefix, + filemap, (unsigned)size); } else if (wParam == IDM_SAVEDSESS) { - unsigned int sessno = ((lParam - IDM_SAVED_MIN) - / MENU_SAVED_STEP) + 1; - if (sessno < (unsigned)sesslist.nsessions) { - const char *session = sesslist.sessions[sessno]; - cl = dupprintf("putty %s@%s", argprefix, session); - inherit_handles = false; - } else - break; + unsigned int sessno = ((lParam - IDM_SAVED_MIN) + / MENU_SAVED_STEP) + 1; + if (sessno < (unsigned)sesslist.nsessions) { + const char *session = sesslist.sessions[sessno]; + cl = dupprintf("putty %s@%s", argprefix, session); + inherit_handles = false; + } else + break; } else /* IDM_NEWSESS */ { - cl = dupprintf("putty%s%s", - *argprefix ? " " : "", - argprefix); - inherit_handles = false; + cl = dupprintf("putty%s%s", + *argprefix ? " " : "", + argprefix); + inherit_handles = false; } GetModuleFileName(NULL, b, sizeof(b) - 1); @@ -2374,24 +2374,24 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, hwnd, conf, backend ? backend_cfg_info(backend) : 0); reconfiguring = false; if (!reconfig_result) { - conf_free(prev_conf); - break; + conf_free(prev_conf); + break; } conf_cache_data(); resize_action = conf_get_int(conf, CONF_resize_action); { - /* Disable full-screen if resizing forbidden */ - int i; - for (i = 0; i < lenof(popup_menus); i++) - EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN, - MF_BYCOMMAND | - (resize_action == RESIZE_DISABLED - ? MF_GRAYED : MF_ENABLED)); - /* Gracefully unzoom if necessary */ - if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED)) - ShowWindow(hwnd, SW_RESTORE); + /* Disable full-screen if resizing forbidden */ + int i; + for (i = 0; i < lenof(popup_menus); i++) + EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN, + MF_BYCOMMAND | + (resize_action == RESIZE_DISABLED + ? MF_GRAYED : MF_ENABLED)); + /* Gracefully unzoom if necessary */ + if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED)) + ShowWindow(hwnd, SW_RESTORE); } /* Pass new config data to the logging module */ @@ -2403,8 +2403,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * case where local editing has just been disabled. */ if (ldisc) { - ldisc_configure(ldisc, conf); - ldisc_echoedit_update(ldisc); + ldisc_configure(ldisc, conf); + ldisc_echoedit_update(ldisc); } if (conf_get_bool(conf, CONF_system_colour) != @@ -2443,90 +2443,90 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, /* Enable or disable the scroll bar, etc */ { - LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE); - LONG nexflag, exflag = - GetWindowLongPtr(hwnd, GWL_EXSTYLE); + LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE); + LONG nexflag, exflag = + GetWindowLongPtr(hwnd, GWL_EXSTYLE); - nexflag = exflag; - if (conf_get_bool(conf, CONF_alwaysontop) != - conf_get_bool(prev_conf, CONF_alwaysontop)) { - if (conf_get_bool(conf, CONF_alwaysontop)) { - nexflag |= WS_EX_TOPMOST; - SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE); - } else { - nexflag &= ~(WS_EX_TOPMOST); - SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE); + nexflag = exflag; + if (conf_get_bool(conf, CONF_alwaysontop) != + conf_get_bool(prev_conf, CONF_alwaysontop)) { + if (conf_get_bool(conf, CONF_alwaysontop)) { + nexflag |= WS_EX_TOPMOST; + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE); + } else { + nexflag &= ~(WS_EX_TOPMOST); + SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE); + } } - } - if (conf_get_bool(conf, CONF_sunken_edge)) - nexflag |= WS_EX_CLIENTEDGE; - else - nexflag &= ~(WS_EX_CLIENTEDGE); + if (conf_get_bool(conf, CONF_sunken_edge)) + nexflag |= WS_EX_CLIENTEDGE; + else + nexflag &= ~(WS_EX_CLIENTEDGE); - nflg = flag; - if (conf_get_bool(conf, is_full_screen() ? - CONF_scrollbar_in_fullscreen : - CONF_scrollbar)) - nflg |= WS_VSCROLL; - else - nflg &= ~WS_VSCROLL; + nflg = flag; + if (conf_get_bool(conf, is_full_screen() ? + CONF_scrollbar_in_fullscreen : + CONF_scrollbar)) + nflg |= WS_VSCROLL; + else + nflg &= ~WS_VSCROLL; - if (resize_action == RESIZE_DISABLED || - is_full_screen()) - nflg &= ~WS_THICKFRAME; - else - nflg |= WS_THICKFRAME; + if (resize_action == RESIZE_DISABLED || + is_full_screen()) + nflg &= ~WS_THICKFRAME; + else + nflg |= WS_THICKFRAME; - if (resize_action == RESIZE_DISABLED) - nflg &= ~WS_MAXIMIZEBOX; - else - nflg |= WS_MAXIMIZEBOX; + if (resize_action == RESIZE_DISABLED) + nflg &= ~WS_MAXIMIZEBOX; + else + nflg |= WS_MAXIMIZEBOX; - if (nflg != flag || nexflag != exflag) { - if (nflg != flag) - SetWindowLongPtr(hwnd, GWL_STYLE, nflg); - if (nexflag != exflag) - SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag); + if (nflg != flag || nexflag != exflag) { + if (nflg != flag) + SetWindowLongPtr(hwnd, GWL_STYLE, nflg); + if (nexflag != exflag) + SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag); - SetWindowPos(hwnd, NULL, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOCOPYBITS | - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | - SWP_FRAMECHANGED); + SetWindowPos(hwnd, NULL, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOCOPYBITS | + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | + SWP_FRAMECHANGED); - init_lvl = 2; - } + init_lvl = 2; + } } /* Oops */ if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) { - force_normal(hwnd); - init_lvl = 2; + force_normal(hwnd); + init_lvl = 2; } { - FontSpec *font = conf_get_fontspec(conf, CONF_font); - FontSpec *prev_font = conf_get_fontspec(prev_conf, - CONF_font); + FontSpec *font = conf_get_fontspec(conf, CONF_font); + FontSpec *prev_font = conf_get_fontspec(prev_conf, + CONF_font); - if (!strcmp(font->name, prev_font->name) || - !strcmp(conf_get_str(conf, CONF_line_codepage), - conf_get_str(prev_conf, CONF_line_codepage)) || - font->isbold != prev_font->isbold || - font->height != prev_font->height || - font->charset != prev_font->charset || - conf_get_int(conf, CONF_font_quality) != - conf_get_int(prev_conf, CONF_font_quality) || - conf_get_int(conf, CONF_vtmode) != - conf_get_int(prev_conf, CONF_vtmode) || - conf_get_int(conf, CONF_bold_style) != - conf_get_int(prev_conf, CONF_bold_style) || - resize_action == RESIZE_DISABLED || - resize_action == RESIZE_EITHER || - resize_action != conf_get_int(prev_conf, - CONF_resize_action)) - init_lvl = 2; + if (!strcmp(font->name, prev_font->name) || + !strcmp(conf_get_str(conf, CONF_line_codepage), + conf_get_str(prev_conf, CONF_line_codepage)) || + font->isbold != prev_font->isbold || + font->height != prev_font->height || + font->charset != prev_font->charset || + conf_get_int(conf, CONF_font_quality) != + conf_get_int(prev_conf, CONF_font_quality) || + conf_get_int(conf, CONF_vtmode) != + conf_get_int(prev_conf, CONF_vtmode) || + conf_get_int(conf, CONF_bold_style) != + conf_get_int(prev_conf, CONF_bold_style) || + resize_action == RESIZE_DISABLED || + resize_action == RESIZE_EITHER || + resize_action != conf_get_int(prev_conf, + CONF_resize_action)) + init_lvl = 2; } InvalidateRect(hwnd, NULL, true); @@ -2734,9 +2734,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, static LPARAM lp = 0; if (wParam != wp || lParam != lp || last_mousemove != WM_MOUSEMOVE) { - show_mouseptr(true); - wp = wParam; lp = lParam; - last_mousemove = WM_MOUSEMOVE; + show_mouseptr(true); + wp = wParam; lp = lParam; + last_mousemove = WM_MOUSEMOVE; } /* * Add the mouse position and message time to the random @@ -2765,9 +2765,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, static LPARAM lp = 0; if (wParam != wp || lParam != lp || last_mousemove != WM_NCMOUSEMOVE) { - show_mouseptr(true); - wp = wParam; lp = lParam; - last_mousemove = WM_NCMOUSEMOVE; + show_mouseptr(true); + wp = wParam; lp = lParam; + last_mousemove = WM_NCMOUSEMOVE; } noise_ultralight(NOISE_SOURCE_MOUSEPOS, lParam); break; @@ -2786,8 +2786,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, HideCaret(hwnd); hdc = BeginPaint(hwnd, &p); if (pal) { - SelectPalette(hdc, pal, true); - RealizePalette(hdc); + SelectPalette(hdc, pal, true); + RealizePalette(hdc); } /* @@ -2838,40 +2838,40 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, p.rcPaint.right >= offset_width + font_width*term->cols || p.rcPaint.bottom>= offset_height + font_height*term->rows) { - HBRUSH fillcolour, oldbrush; - HPEN edge, oldpen; - fillcolour = CreateSolidBrush ( - colours[ATTR_DEFBG>>ATTR_BGSHIFT]); - oldbrush = SelectObject(hdc, fillcolour); - edge = CreatePen(PS_SOLID, 0, - colours[ATTR_DEFBG>>ATTR_BGSHIFT]); - oldpen = SelectObject(hdc, edge); + HBRUSH fillcolour, oldbrush; + HPEN edge, oldpen; + fillcolour = CreateSolidBrush ( + colours[ATTR_DEFBG>>ATTR_BGSHIFT]); + oldbrush = SelectObject(hdc, fillcolour); + edge = CreatePen(PS_SOLID, 0, + colours[ATTR_DEFBG>>ATTR_BGSHIFT]); + oldpen = SelectObject(hdc, edge); - /* - * Jordan Russell reports that this apparently - * ineffectual IntersectClipRect() call masks a - * Windows NT/2K bug causing strange display - * problems when the PuTTY window is taller than - * the primary monitor. It seems harmless enough... - */ - IntersectClipRect(hdc, - p.rcPaint.left, p.rcPaint.top, - p.rcPaint.right, p.rcPaint.bottom); + /* + * Jordan Russell reports that this apparently + * ineffectual IntersectClipRect() call masks a + * Windows NT/2K bug causing strange display + * problems when the PuTTY window is taller than + * the primary monitor. It seems harmless enough... + */ + IntersectClipRect(hdc, + p.rcPaint.left, p.rcPaint.top, + p.rcPaint.right, p.rcPaint.bottom); - ExcludeClipRect(hdc, - offset_width, offset_height, - offset_width+font_width*term->cols, - offset_height+font_height*term->rows); + ExcludeClipRect(hdc, + offset_width, offset_height, + offset_width+font_width*term->cols, + offset_height+font_height*term->rows); - Rectangle(hdc, p.rcPaint.left, p.rcPaint.top, - p.rcPaint.right, p.rcPaint.bottom); + Rectangle(hdc, p.rcPaint.left, p.rcPaint.top, + p.rcPaint.right, p.rcPaint.bottom); - /* SelectClipRgn(hdc, NULL); */ + /* SelectClipRgn(hdc, NULL); */ - SelectObject(hdc, oldbrush); - DeleteObject(fillcolour); - SelectObject(hdc, oldpen); - DeleteObject(edge); + SelectObject(hdc, oldbrush); + DeleteObject(fillcolour); + SelectObject(hdc, oldpen); + DeleteObject(edge); } SelectObject(hdc, GetStockObject(SYSTEM_FONT)); SelectObject(hdc, GetStockObject(WHITE_PEN)); @@ -3314,33 +3314,33 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); if (n > 0) { - int i; - buff = snewn(n, char); - ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n); - /* - * Jaeyoun Chung reports that Korean character - * input doesn't work correctly if we do a single - * term_keyinputw covering the whole of buff. So - * instead we send the characters one by one. - */ - /* don't divide SURROGATE PAIR */ - if (ldisc) { - for (i = 0; i < n; i += 2) { - WCHAR hs = *(unsigned short *)(buff+i); - if (IS_HIGH_SURROGATE(hs) && i+2 < n) { - WCHAR ls = *(unsigned short *)(buff+i+2); - if (IS_LOW_SURROGATE(ls)) { - term_keyinputw( - term, (unsigned short *)(buff+i), 2); - i += 2; - continue; + int i; + buff = snewn(n, char); + ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n); + /* + * Jaeyoun Chung reports that Korean character + * input doesn't work correctly if we do a single + * term_keyinputw covering the whole of buff. So + * instead we send the characters one by one. + */ + /* don't divide SURROGATE PAIR */ + if (ldisc) { + for (i = 0; i < n; i += 2) { + WCHAR hs = *(unsigned short *)(buff+i); + if (IS_HIGH_SURROGATE(hs) && i+2 < n) { + WCHAR ls = *(unsigned short *)(buff+i+2); + if (IS_LOW_SURROGATE(ls)) { + term_keyinputw( + term, (unsigned short *)(buff+i), 2); + i += 2; + continue; + } + } + term_keyinputw( + term, (unsigned short *)(buff+i), 1); } - } - term_keyinputw( - term, (unsigned short *)(buff+i), 1); } - } - free(buff); + free(buff); } ImmReleaseContext(hwnd, hIMC); return 1; @@ -5688,7 +5688,7 @@ static void wintw_move(TermWin *tw, int x, int y) if (resize_action == RESIZE_DISABLED || resize_action == RESIZE_FONT || IsZoomed(wgs.term_hwnd)) - return; + return; SetWindowPos(wgs.term_hwnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } @@ -5763,7 +5763,7 @@ static bool get_fullscreen_rect(RECT * ss) ss->right = GetSystemMetrics(SM_CXSCREEN); ss->bottom = GetSystemMetrics(SM_CYSCREEN); */ - return GetClientRect(GetDesktopWindow(), ss); + return GetClientRect(GetDesktopWindow(), ss); } @@ -5774,12 +5774,12 @@ static bool get_fullscreen_rect(RECT * ss) static void make_full_screen() { DWORD style; - RECT ss; + RECT ss; assert(IsZoomed(wgs.term_hwnd)); - if (is_full_screen()) - return; + if (is_full_screen()) + return; /* Remove the window furniture. */ style = GetWindowLongPtr(wgs.term_hwnd, GWL_STYLE); @@ -5791,7 +5791,7 @@ static void make_full_screen() SetWindowLongPtr(wgs.term_hwnd, GWL_STYLE, style); /* Resize ourselves to exactly cover the nearest monitor. */ - get_fullscreen_rect(&ss); + get_fullscreen_rect(&ss); SetWindowPos(wgs.term_hwnd, HWND_TOP, ss.left, ss.top, ss.right - ss.left, ss.bottom - ss.top, SWP_FRAMECHANGED);