From d509a2dc1ef4163dc929f4dd1404791cbba2de56 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 28 Dec 2022 15:32:24 +0000 Subject: [PATCH] Formatting: normalise to put a space after condition keywords. 'if (thing)' is the local style here, not 'if(thing)'. Similarly with 'for' and 'while'. --- terminal/terminal.c | 10 +++++----- unix/main-gtk-simple.c | 10 +++++----- unix/plink.c | 2 +- unix/utils/block_signal.c | 2 +- unix/utils/signal.c | 4 ++-- windows/gss.c | 6 +++--- windows/pageant.c | 26 +++++++++++++------------- windows/sftp.c | 4 ++-- windows/unicode.c | 4 ++-- windows/window.c | 10 +++++----- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/terminal/terminal.c b/terminal/terminal.c index 584bd3e6..c26513e6 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -2160,7 +2160,7 @@ void term_free(Terminal *term) sfree(beep); } bufchain_clear(&term->inbuf); - if(term->print_job) + if (term->print_job) printer_finish_job(term->print_job); bufchain_clear(&term->printer_buf); sfree(term->paste_buffer); @@ -5037,7 +5037,7 @@ static void term_out(Terminal *term, bool called_from_term_data) int i = def(term->esc_args[0], 1); pos old_curs = term->curs; - for(;i>0 && term->curs.x>0; i--) { + for (; i>0 && term->curs.x>0; i--) { do { term->curs.x--; } while (term->curs.x >0 && @@ -5841,7 +5841,7 @@ static termchar *term_bidi_line(Terminal *term, struct termline *ldata, bidi_char); } - for(it=0; itcols ; it++) + for (it=0; itcols ; it++) { unsigned long uc = (ldata->chars[it].chr); @@ -5896,10 +5896,10 @@ static termchar *term_bidi_line(Terminal *term, struct termline *ldata, nbc++; } - if(!term->no_bidi) + if (!term->no_bidi) do_bidi(term->bidi_ctx, term->wcFrom, nbc); - if(!term->no_arabicshaping) { + if (!term->no_arabicshaping) { do_shape(term->wcFrom, term->wcTo, nbc); } else { /* If we're not calling do_shape, we must copy the diff --git a/unix/main-gtk-simple.c b/unix/main-gtk-simple.c index 4cbb5a31..f477dfff 100644 --- a/unix/main-gtk-simple.c +++ b/unix/main-gtk-simple.c @@ -254,7 +254,7 @@ int read_dupsession_data(Conf *conf, char *arg) } static void help(FILE *fp) { - if(fprintf(fp, + if (fprintf(fp, "pterm option summary:\n" "\n" " --display DISPLAY Specify X display to use (note '--')\n" @@ -282,8 +282,8 @@ static void help(FILE *fp) { static void version(FILE *fp) { char *buildinfo_text = buildinfo("\n"); - if(fprintf(fp, "%s: %s\n%s\n", appname, ver, buildinfo_text) < 0 || - fflush(fp) < 0) { + if (fprintf(fp, "%s: %s\n%s\n", appname, ver, buildinfo_text) < 0 || + fflush(fp) < 0) { perror("output error"); exit(1); } @@ -520,11 +520,11 @@ bool do_cmdline(int argc, char **argv, bool do_everything, Conf *conf) EXPECTS_ARG; provide_xrm_string(val, appname); - } else if(!strcmp(p, "-help") || !strcmp(p, "--help")) { + } else if (!strcmp(p, "-help") || !strcmp(p, "--help")) { help(stdout); exit(0); - } else if(!strcmp(p, "-version") || !strcmp(p, "--version")) { + } else if (!strcmp(p, "-version") || !strcmp(p, "--version")) { version(stdout); exit(0); diff --git a/unix/plink.c b/unix/plink.c index 3f7f7bd8..503ff8d7 100644 --- a/unix/plink.c +++ b/unix/plink.c @@ -149,7 +149,7 @@ static char *plink_get_ttymode(Seat *seat, const char *mode) do { \ if (strcmp(mode, ourname) == 0) \ return get_ttychar(&orig_termios, uxname); \ - } while(0) + } while (0) #define GET_BOOL(ourname, uxname, uxmemb, transform) \ do { \ if (strcmp(mode, ourname) == 0) { \ diff --git a/unix/utils/block_signal.c b/unix/utils/block_signal.c index 918e63a4..8c6245ff 100644 --- a/unix/utils/block_signal.c +++ b/unix/utils/block_signal.c @@ -14,7 +14,7 @@ void block_signal(int sig, bool block_it) sigemptyset(&ss); sigaddset(&ss, sig); - if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) { + if (sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) { perror("sigprocmask"); exit(1); } diff --git a/unix/utils/signal.c b/unix/utils/signal.c index a56fe6be..81234f97 100644 --- a/unix/utils/signal.c +++ b/unix/utils/signal.c @@ -21,10 +21,10 @@ void (*putty_signal(int sig, void (*func)(int)))(int) struct sigaction old; sa.sa_handler = func; - if(sigemptyset(&sa.sa_mask) < 0) + if (sigemptyset(&sa.sa_mask) < 0) return SIG_ERR; sa.sa_flags = SA_RESTART; - if(sigaction(sig, &sa, &old) < 0) + if (sigaction(sig, &sa, &old) < 0) return SIG_ERR; return old.sa_handler; } diff --git a/windows/gss.c b/windows/gss.c index 905bea67..b7bca7d1 100644 --- a/windows/gss.c +++ b/windows/gss.c @@ -26,7 +26,7 @@ if (uli.QuadPart != 0) \ uli.QuadPart = uli.QuadPart / CNS_PERSEC - UNIX_EPOCH; \ (t) = (time_t) uli.QuadPart; \ -} while(0) +} while (0) /* Windows code to set up the GSSAPI library list. */ @@ -142,7 +142,7 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf) char *installdir = get_reg_sz(regkey, "InstallDir"); if (installdir) { char *bindir = dupcat(installdir, "\\bin"); - if(p_AddDllDirectory) { + if (p_AddDllDirectory) { /* Add MIT Kerberos' path to the DLL search path, * it loads its own DLLs further down the road */ wchar_t *dllPath = dup_mb_to_wc(DEFAULT_CODEPAGE, 0, bindir); @@ -235,7 +235,7 @@ struct ssh_gss_liblist *ssh_gss_setup(Conf *conf) module = NULL; path = conf_get_filename(conf, CONF_ssh_gss_custom)->path; if (*path) { - if(p_AddDllDirectory) { + if (p_AddDllDirectory) { /* Add the custom directory as well in case it chainloads * some other DLLs (e.g a non-installed MIT Kerberos * instance) */ diff --git a/windows/pageant.c b/windows/pageant.c index 7a0970a7..cb4c1186 100644 --- a/windows/pageant.c +++ b/windows/pageant.c @@ -559,7 +559,7 @@ static void prompt_add_keyfile(bool encrypted) of.lpstrTitle = "Select Private Key File"; of.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER; if (request_file(keypath, &of, true, false)) { - if(strlen(filelist) > of.nFileOffset) { + if (strlen(filelist) > of.nFileOffset) { /* Only one filename returned? */ Filename *fn = filename_from_str(filelist); win_add_keyfile(fn, encrypted); @@ -804,7 +804,7 @@ static INT_PTR CALLBACK KeyListProc(HWND hwnd, UINT msg, /* do the same for the rsa keys */ for (i = rCount - 1; (itemNum >= 0) && (i >= 0); i--) { - if(selectedArray[itemNum] == i) { + if (selectedArray[itemNum] == i) { switch (LOWORD(wParam)) { case IDC_KEYLIST_REMOVE: pageant_delete_nth_ssh1_key(i); @@ -909,10 +909,10 @@ static void update_sessions(void) if (!putty_path) return; - if(ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, PUTTY_REGKEY, &hkey)) + if (ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, PUTTY_REGKEY, &hkey)) return; - for(num_entries = GetMenuItemCount(session_menu); + for (num_entries = GetMenuItemCount(session_menu); num_entries > initial_menuitems_count; num_entries--) RemoveMenu(session_menu, 0, MF_BYPOSITION); @@ -921,8 +921,8 @@ static void update_sessions(void) index_menu = 0; sb = strbuf_new(); - while(ERROR_SUCCESS == RegEnumKey(hkey, index_key, buf, MAX_PATH)) { - if(strcmp(buf, PUTTY_DEFAULT) != 0) { + while (ERROR_SUCCESS == RegEnumKey(hkey, index_key, buf, MAX_PATH)) { + if (strcmp(buf, PUTTY_DEFAULT) != 0) { strbuf_clear(sb); unescape_registry_key(buf, sb); @@ -942,7 +942,7 @@ static void update_sessions(void) RegCloseKey(hkey); - if(index_menu == 0) { + if (index_menu == 0) { mii.cbSize = sizeof(mii); mii.fMask = MIIM_TYPE | MIIM_STATE; mii.fType = MFT_STRING; @@ -1311,8 +1311,8 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, if (restrict_putty_acl) strcat(cmdline, "&R"); - if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline, - _T(""), SW_SHOW) <= 32) { + if ((INT_PTR)ShellExecute(hwnd, NULL, putty_path, cmdline, + _T(""), SW_SHOW) <= 32) { MessageBox(NULL, "Unable to execute PuTTY!", "Error", MB_OK | MB_ICONERROR); } @@ -1371,7 +1371,7 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, launch_help(hwnd, WINHELP_CTX_pageant_general); break; default: { - if(wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) { + if (wParam >= IDM_SESSIONS_BASE && wParam <= IDM_SESSIONS_MAX) { MENUITEMINFO mii; TCHAR buf[MAX_PATH + 1]; TCHAR param[MAX_PATH + 1]; @@ -1386,8 +1386,8 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, strcat(param, "&R"); strcat(param, "@"); strcat(param, mii.dwTypeData); - if((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param, - _T(""), SW_SHOW) <= 32) { + if ((INT_PTR)ShellExecute(hwnd, NULL, putty_path, param, + _T(""), SW_SHOW) <= 32) { MessageBox(NULL, "Unable to execute PuTTY!", "Error", MB_OK | MB_ICONERROR); } @@ -1835,7 +1835,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) args = strchr(command, ' '); if (args) { *args++ = 0; - while(*args && isspace(*args)) args++; + while (*args && isspace(*args)) args++; } spawn_cmd(command, args, show); } diff --git a/windows/sftp.c b/windows/sftp.c index 2c4c94e4..9e98bbd0 100644 --- a/windows/sftp.c +++ b/windows/sftp.c @@ -86,14 +86,14 @@ static inline uint64_t uint64_from_words(uint32_t hi, uint32_t lo) uli.QuadPart = ((ULONGLONG)(t) + 11644473600ull) * 10000000ull; \ (ft).dwLowDateTime = uli.LowPart; \ (ft).dwHighDateTime = uli.HighPart; \ -} while(0) +} while (0) #define TIME_WIN_TO_POSIX(ft, t) do { \ ULARGE_INTEGER uli; \ uli.LowPart = (ft).dwLowDateTime; \ uli.HighPart = (ft).dwHighDateTime; \ uli.QuadPart = uli.QuadPart / 10000000ull - 11644473600ull; \ (t) = (unsigned long) uli.QuadPart; \ -} while(0) +} while (0) struct RFile { HANDLE h; diff --git a/windows/unicode.c b/windows/unicode.c index 8423ff1e..190a7460 100644 --- a/windows/unicode.c +++ b/windows/unicode.c @@ -682,7 +682,7 @@ void init_ucs(Conf *conf, struct unicode_data *ucsdata) if (!DIRECT_FONT(ucsdata->unitab_xterm[i])) ucsdata->unitab_xterm[i] = (WCHAR) (CSET_ACP + poorman_vt100[i - 96]); - for(i=128;i<256;i++) + for (i = 128; i < 256; i++) if (!DIRECT_FONT(ucsdata->unitab_scoacs[i])) ucsdata->unitab_scoacs[i] = (WCHAR) (CSET_ACP + poorman_scoacs[i - 128]); @@ -695,7 +695,7 @@ static void link_font(WCHAR *line_tbl, WCHAR *font_tbl, WCHAR attr) for (line_index = 0; line_index < 256; line_index++) { if (DIRECT_FONT(line_tbl[line_index])) continue; - for(i = 0; i < 256; i++) { + for (i = 0; i < 256; i++) { font_index = ((32 + i) & 0xFF); if (line_tbl[line_index] == font_tbl[font_index]) { line_tbl[line_index] = (WCHAR) (attr + font_index); diff --git a/windows/window.c b/windows/window.c index 88701247..4d00fe28 100644 --- a/windows/window.c +++ b/windows/window.c @@ -2550,7 +2550,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, * `ready to appear' state. */ show_mouseptr(wgs, true); /* make sure pointer is visible */ - if( lParam == 0 ) + if (lParam == 0) PostMessage(hwnd, WM_CHAR, ' ', 0); break; case IDM_FULLSCREEN: @@ -3792,7 +3792,7 @@ static void do_text_internal( uni_buf = snewn(uni_len, wchar_t); } - for(nlen = mptr = 0; mptrucsdata.font_codepage, (BYTE) text[mptr])) { @@ -4673,8 +4673,8 @@ static int TranslateKey(WinGuiSeat *wgs, UINT message, WPARAM wParam, bool capsOn = false; /* helg: clear CAPS LOCK state if caps lock switches to cyrillic */ - if(keystate[VK_CAPITAL] != 0 && - conf_get_bool(wgs->conf, CONF_xlat_capslockcyr)) { + if (keystate[VK_CAPITAL] != 0 && + conf_get_bool(wgs->conf, CONF_xlat_capslockcyr)) { capsOn = !left_alt; keystate[VK_CAPITAL] = 0; } @@ -4778,7 +4778,7 @@ static int TranslateKey(WinGuiSeat *wgs, UINT message, WPARAM wParam, term_keyinputw(wgs->term, &wch, 1); } } else { - if(capsOn && wch < 0x80) { + if (capsOn && wch < 0x80) { WCHAR cbuf[2]; cbuf[0] = 27; cbuf[1] = xlat_uskbd2cyrllic(wch);