Skip to content

Commit 15e3702

Browse files
committed
Fix some stylistic issues with the windows unicode code.
1 parent 975343e commit 15e3702

File tree

4 files changed

+43
-51
lines changed

4 files changed

+43
-51
lines changed

src/win/wgl_disp.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,7 @@ static ALLEGRO_EXTRA_DISPLAY_SETTINGS* read_pixel_format_old(int fmt, HDC dc)
427427

428428
result = DescribePixelFormat(dc, fmt+1, sizeof(pfd), &pfd);
429429
if (!result) {
430-
ALLEGRO_WARN("DescribePixelFormat() failed. %s\n",
431-
_al_win_last_error());
430+
ALLEGRO_WARN("DescribePixelFormat() failed. %s\n", _al_win_last_error());
432431
return NULL;
433432
}
434433

@@ -514,8 +513,7 @@ static ALLEGRO_EXTRA_DISPLAY_SETTINGS* read_pixel_format_ext(int fmt, HDC dc)
514513
}
515514

516515
if (!ret) {
517-
ALLEGRO_ERROR("wglGetPixelFormatAttrib failed! %s\n",
518-
_al_win_last_error());
516+
ALLEGRO_ERROR("wglGetPixelFormatAttrib failed! %s\n", _al_win_last_error());
519517
al_free(value);
520518
return NULL;
521519
}
@@ -616,8 +614,7 @@ static bool change_display_mode(ALLEGRO_DISPLAY *d)
616614
result = ChangeDisplaySettingsEx(dev_name, &dm, NULL, CDS_FULLSCREEN, 0);
617615

618616
if (result != DISP_CHANGE_SUCCESSFUL) {
619-
ALLEGRO_ERROR("Unable to set mode. %s\n",
620-
_al_win_last_error());
617+
ALLEGRO_ERROR("Unable to set mode. %s\n", _al_win_last_error());
621618
return false;
622619
}
623620

@@ -859,15 +856,13 @@ static bool select_pixel_format(ALLEGRO_DISPLAY_WGL *d, HDC dc)
859856
break;
860857
}
861858
else {
862-
ALLEGRO_WARN("Unable to set pixel format! %s\n",
863-
_al_win_last_error());
859+
ALLEGRO_WARN("Unable to set pixel format! %s\n", _al_win_last_error());
864860
ALLEGRO_WARN("Trying next one.\n");
865861
}
866862
}
867863

868864
if (i == eds_count) {
869-
ALLEGRO_ERROR("Unable to set any pixel format! %s\n",
870-
_al_win_last_error());
865+
ALLEGRO_ERROR("Unable to set any pixel format! %s\n", _al_win_last_error());
871866
for (i = 0; i < eds_count; i++)
872867
al_free(eds[i]);
873868
al_free(eds);
@@ -947,16 +942,14 @@ static bool create_display_internals(ALLEGRO_DISPLAY_WGL *wgl_disp)
947942
}
948943

949944
if (!wgl_disp->glrc) {
950-
ALLEGRO_ERROR("Unable to create a render context! %s\n",
951-
_al_win_last_error());
945+
ALLEGRO_ERROR("Unable to create a render context! %s\n", _al_win_last_error());
952946
destroy_display_internals(wgl_disp);
953947
return false;
954948
}
955949

956950
/* make the context the current one */
957951
if (!wglMakeCurrent(wgl_disp->dc, wgl_disp->glrc)) {
958-
ALLEGRO_ERROR("Unable to make the context current! %s\n",
959-
_al_win_last_error());
952+
ALLEGRO_ERROR("Unable to make the context current! %s\n", _al_win_last_error());
960953
destroy_display_internals(wgl_disp);
961954
return false;
962955
}
@@ -1161,8 +1154,7 @@ static void wgl_unset_current_display(ALLEGRO_DISPLAY *d)
11611154
(void)d;
11621155

11631156
if (!wglMakeCurrent(NULL, NULL)) {
1164-
ALLEGRO_ERROR("Unable unset the current context! %s\n",
1165-
_al_win_last_error());
1157+
ALLEGRO_ERROR("Unable unset the current context! %s\n", _al_win_last_error());
11661158
}
11671159
}
11681160

src/win/wjoydxnu.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static void fill_joystick_info_using_caps_and_names(ALLEGRO_JOYSTICK_DIRECTX *jo
605605
N_AXIS++;
606606
}
607607

608-
info->stick[N_STICK].name = ADD_STRING(0, default_name_stick);
608+
info->stick[N_STICK].name = ADD_STRING(NULL, default_name_stick);
609609
N_STICK++;
610610
}
611611

@@ -635,15 +635,15 @@ static void fill_joystick_info_using_caps_and_names(ALLEGRO_JOYSTICK_DIRECTX *jo
635635
N_AXIS++;
636636
}
637637

638-
info->stick[N_STICK].name = ADD_STRING(0, default_name_stick);
638+
info->stick[N_STICK].name = ADD_STRING(NULL, default_name_stick);
639639
N_STICK++;
640640
}
641641

642642
/* sliders are assigned to one stick each */
643643
for (i = 0; i < can->num_sliders; i++) {
644644
info->stick[N_STICK].flags = ALLEGRO_JOYFLAG_DIGITAL | ALLEGRO_JOYFLAG_ANALOGUE;
645645
info->stick[N_STICK].num_axes = 1;
646-
info->stick[N_STICK].axis[0].name = ADD_STRING(0, "axis");
646+
info->stick[N_STICK].axis[0].name = ADD_STRING(NULL, "axis");
647647
info->stick[N_STICK].name = ADD_STRING(can->name_slider[i], default_name_slider);
648648
joy->slider_mapping[i].stick = N_STICK;
649649
joy->slider_mapping[i].axis = 0;
@@ -654,8 +654,8 @@ static void fill_joystick_info_using_caps_and_names(ALLEGRO_JOYSTICK_DIRECTX *jo
654654
for (i = 0; i < can->num_povs; i++) {
655655
info->stick[N_STICK].flags = ALLEGRO_JOYFLAG_DIGITAL;
656656
info->stick[N_STICK].num_axes = 2;
657-
info->stick[N_STICK].axis[0].name = ADD_STRING(0, "left/right");
658-
info->stick[N_STICK].axis[1].name = ADD_STRING(0, "up/down");
657+
info->stick[N_STICK].axis[0].name = ADD_STRING(NULL, "left/right");
658+
info->stick[N_STICK].axis[1].name = ADD_STRING(NULL, "up/down");
659659
info->stick[N_STICK].name = ADD_STRING(can->name_pov[i], default_name_hat);
660660
joy->pov_mapping_stick[i] = N_STICK;
661661
N_STICK++;
@@ -687,15 +687,15 @@ static void fill_joystick_info_using_caps_and_names(ALLEGRO_JOYSTICK_DIRECTX *jo
687687
info->stick[2].axis[1].name = info->stick[1].axis[1].name = info->stick[0].axis[1].name;
688688

689689
/* first four button names contained junk; replace with valid strings */
690-
info->button[ 0].name = ADD_STRING(0, "Triangle");
691-
info->button[ 1].name = ADD_STRING(0, "Circle");
692-
info->button[ 2].name = ADD_STRING(0, "X");
693-
info->button[ 3].name = ADD_STRING(0, "Square");
690+
info->button[ 0].name = ADD_STRING(NULL, "Triangle");
691+
info->button[ 1].name = ADD_STRING(NULL, "Circle");
692+
info->button[ 2].name = ADD_STRING(NULL, "X");
693+
info->button[ 3].name = ADD_STRING(NULL, "Square");
694694

695695
/* while we're at it, give these controls more sensible names, too */
696-
info->stick[0].name = ADD_STRING(0, "[L-stick] or D-pad");
697-
info->stick[1].name = ADD_STRING(0, "[R-stick]");
698-
info->stick[2].name = ADD_STRING(0, "[D-pad]");
696+
info->stick[0].name = ADD_STRING(NULL, "[L-stick] or D-pad");
697+
info->stick[1].name = ADD_STRING(NULL, "[R-stick]");
698+
info->stick[2].name = ADD_STRING(NULL, "[D-pad]");
699699
}
700700

701701
#undef N_AXIS

src/win/wsystem.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -926,25 +926,25 @@ void _al_register_system_interfaces()
926926
}
927927

928928
const char* _al_win_error(DWORD err) {
929-
LPTSTR msg = NULL;
930-
int len;
931-
static char buf[2048];
932-
933-
len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, err, 0, (LPTSTR)&msg, 0, NULL);
934-
if (len == 0) {
935-
_al_sane_strncpy(buf, "(Unable to decode the error code)", sizeof(buf));
936-
}
937-
else {
938-
/* Truncate trailing CRLF if it has one */
939-
if (len >= 2 && _tcscmp(msg + len - 2, TEXT("\r\n")) == 0) {
940-
msg[len - 2] = (TCHAR)0;
941-
}
942-
_twin_copy_tchar_to_utf8(buf, msg, sizeof(buf));
943-
LocalFree(msg);
944-
}
945-
return buf;
929+
LPTSTR msg = NULL;
930+
int len;
931+
static char buf[2048];
932+
933+
len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, err, 0, (LPTSTR)&msg, 0, NULL);
934+
if (len == 0) {
935+
_al_sane_strncpy(buf, "(Unable to decode the error code)", sizeof(buf));
936+
}
937+
else {
938+
/* Truncate trailing CRLF if it has one */
939+
if (len >= 2 && _tcscmp(msg + len - 2, TEXT("\r\n")) == 0) {
940+
msg[len - 2] = (TCHAR)0;
941+
}
942+
_twin_copy_tchar_to_utf8(buf, msg, sizeof(buf));
943+
LocalFree(msg);
944+
}
945+
return buf;
946946
}
947947
const char* _al_win_last_error() {
948-
return _al_win_error(GetLastError());
948+
return _al_win_error(GetLastError());
949949
}
950950
/* vim: set sts=3 sw=3 et: */

src/win/wtouch_input.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ static bool init_touch_input(void)
210210
bool r;
211211
ALLEGRO_DISPLAY_WIN *win_display = *((ALLEGRO_DISPLAY_WIN**)_al_vector_ref(&system->displays, i));
212212
r = _al_win_register_touch_window(win_display->window, 0);
213-
ALLEGRO_INFO("registering touch window %p: %d\n", win_display, r);
214-
if (!r) {
215-
ALLEGRO_ERROR("RegisterTouchWindow failed: %s\n", _al_win_last_error());
216-
return false;
217-
}
213+
ALLEGRO_INFO("registering touch window %p: %d\n", win_display, r);
214+
if (!r) {
215+
ALLEGRO_ERROR("RegisterTouchWindow failed: %s\n", _al_win_last_error());
216+
return false;
217+
}
218218
}
219219

220220
return true;

0 commit comments

Comments
 (0)