Skip to content

Commit 81432ba

Browse files
natoscottBenBE
authored andcommitted
Consolidate CRT_delay and CRT_crashSettings into one
No reason to have two pointers when one will do the trick, and the code becomes a little less obfuscated as a result.
1 parent a750f38 commit 81432ba

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

CRT.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ bool CRT_utf8 = false;
9292

9393
const char* const* CRT_treeStr = CRT_treeStrAscii;
9494

95-
static const Settings* CRT_crashSettings;
96-
static const int* CRT_delay;
95+
static const Settings* CRT_settings;
9796

9897
const char* CRT_degreeSign;
9998

@@ -836,7 +835,7 @@ ATTR_NORETURN
836835
static void CRT_handleSIGTERM(int sgn) {
837836
CRT_done();
838837

839-
if (!CRT_crashSettings->changed)
838+
if (!CRT_settings->changed)
840839
_exit(0);
841840

842841
const char* signal_str = strsignal(sgn);
@@ -1055,8 +1054,7 @@ void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnEx
10551054

10561055
redirectStderr();
10571056
noecho();
1058-
CRT_crashSettings = settings;
1059-
CRT_delay = &(settings->delay);
1057+
CRT_settings = settings;
10601058
CRT_colors = CRT_colorSchemes[settings->colorScheme];
10611059
CRT_colorScheme = settings->colorScheme;
10621060

@@ -1065,7 +1063,7 @@ void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnEx
10651063
CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPairGrayBlack) ? ColorPair(White, Black) : color;
10661064
}
10671065

1068-
halfdelay(*CRT_delay);
1066+
halfdelay(settings->delay);
10691067
nonl();
10701068
intrflush(stdscr, false);
10711069
keypad(stdscr, true);
@@ -1180,7 +1178,7 @@ int CRT_readKey(void) {
11801178
cbreak();
11811179
nodelay(stdscr, FALSE);
11821180
int ret = getch();
1183-
halfdelay(*CRT_delay);
1181+
halfdelay(CRT_settings->delay);
11841182
return ret;
11851183
}
11861184

@@ -1191,7 +1189,7 @@ void CRT_disableDelay(void) {
11911189
}
11921190

11931191
void CRT_enableDelay(void) {
1194-
halfdelay(*CRT_delay);
1192+
halfdelay(CRT_settings->delay);
11951193
}
11961194

11971195
void CRT_setColors(int colorScheme) {
@@ -1312,7 +1310,7 @@ void CRT_handleSIGSEGV(int signal) {
13121310
full_write_str(STDERR_FILENO,
13131311
"Setting information:\n"
13141312
"--------------------\n");
1315-
Settings_write(CRT_crashSettings, true);
1313+
Settings_write(CRT_settings, true);
13161314
full_write_str(STDERR_FILENO, "\n\n");
13171315

13181316
#ifdef PRINT_BACKTRACE

0 commit comments

Comments
 (0)