summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-09-18 13:05:08 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-09-18 13:05:08 -0700
commitff2dc0bd4e14cc24a64056a00a107972cb3850c8 (patch)
treef018aa806fc2053b8346b2010538d7b679810b52
parent211fb8127493b50a29e9807f7327f23bed5253df (diff)
downloadabc80sim-ff2dc0bd4e14cc24a64056a00a107972cb3850c8.tar.gz
abc80sim-ff2dc0bd4e14cc24a64056a00a107972cb3850c8.tar.xz
abc80sim-ff2dc0bd4e14cc24a64056a00a107972cb3850c8.zip
Avoid name clashes on Windows, fix incorrect errno handling
-rw-r--r--sdlscrn.c27
-rw-r--r--tempfile.c3
2 files changed, 16 insertions, 14 deletions
diff --git a/sdlscrn.c b/sdlscrn.c
index 91ae8e3..800c8ee 100644
--- a/sdlscrn.c
+++ b/sdlscrn.c
@@ -426,22 +426,23 @@ void check_event(void)
{
SDL_Event event;
static int keyboard_scan = -1; /* No key currently down */
- enum kmod {
- MOD_SHIFT = 1,
- MOD_CTRL = 2,
- MOD_ALT = 4
- } kmod;
+ enum kshift {
+ KSH_SHIFT = 1,
+ KSH_CTRL = 2,
+ KSH_ALT = 4
+ } kshift;
set_blink(timer_poll()); /* Poll timer, change blink if needed */
while ( SDL_PollEvent(&event) ) {
switch ( event.type ) {
case SDL_KEYDOWN:
- kmod = ((event.key.keysym.mod & (KMOD_LALT|KMOD_RALT)) ? MOD_ALT : 0) |
- ((event.key.keysym.mod & (KMOD_LCTRL|KMOD_RCTRL)) ? MOD_CTRL : 0) |
- ((event.key.keysym.mod & (KMOD_LSHIFT|KMOD_RSHIFT)) ? MOD_SHIFT : 0);
+ kshift = \
+ ((event.key.keysym.mod & (KMOD_LALT|KMOD_RALT)) ? KSH_ALT : 0) |
+ ((event.key.keysym.mod & (KMOD_LCTRL|KMOD_RCTRL)) ? KSH_CTRL : 0) |
+ ((event.key.keysym.mod & (KMOD_LSHIFT|KMOD_RSHIFT)) ? KSH_SHIFT : 0);
- if (kmod & MOD_ALT) {
+ if (kshift & KSH_ALT) {
/* Alt+key are special functions */
switch (event.key.keysym.sym) {
@@ -481,7 +482,7 @@ void check_event(void)
case SDLK_F6:
case SDLK_F7:
case SDLK_F8:
- mysym = (event.key.keysym.sym - SDLK_F1 + 192) + ((int)kmod << 3);
+ mysym = (event.key.keysym.sym - SDLK_F1 + 192) + ((int)kshift << 3);
break;
case SDLK_ESCAPE:
@@ -489,7 +490,7 @@ void check_event(void)
break;
case SDLK_SPACE: /* Ctrl+Space -> NUL */
- mysym = (kmod^MOD_CTRL) << 4;
+ mysym = (kshift^KSH_CTRL) << 4;
break;
default:
@@ -563,7 +564,7 @@ void check_event(void)
break;
case L'<':
case L'>':
- mysym = (kmod & MOD_CTRL) ? 127 : event.key.keysym.unicode;
+ mysym = (kshift & KSH_CTRL) ? 127 : event.key.keysym.unicode;
break;
case L'§':
case L'½':
@@ -574,7 +575,7 @@ void check_event(void)
}
if (!(mysym & ~0x1f)) {
/* Shift+Ctrl -> invert bit 4 */
- if (kmod == (MOD_CTRL|MOD_SHIFT))
+ if (kshift == (KSH_CTRL|KSH_SHIFT))
mysym ^= 0x10;
}
}
diff --git a/tempfile.c b/tempfile.c
index 6bda583..64a35f3 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -79,7 +79,6 @@ struct temp_file *temp_file(enum temp_file_mode mode)
struct temp_file *temp;
char *filename = NULL;
int fd;
- int err;
int attempts = TMP_MAX;
size_t fnlen;
const int openflags = O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_SHORT_LIVED| \
@@ -97,7 +96,9 @@ struct temp_file *temp_file(enum temp_file_mode mode)
} while (fd < 0 && errno == EEXIST && --attempts);
if (fd < 0) {
+ int err = errno;
free(filename);
+ errno = err;
return NULL;
}