Use C++ style comments consistently in SDL source code

Implemented using this script:

find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
    core/linux/SDL_evdev_kbd_default_keymap.h \
    events/imKStoUCS.* \
    hidapi \
    joystick/controller_type.c \
    joystick/controller_type.h \
    joystick/hidapi/steam/controller_constants.h \
    joystick/hidapi/steam/controller_structs.h \
    joystick/SDL_gamepad_db.h \
    libm \
    render/*/*Shader*.h \
    render/vitagxm/SDL_render_vita_gxm_shaders.h \
    render/metal/SDL_shaders_metal_*.h \
    stdlib/SDL_malloc.c \
    stdlib/SDL_qsort.c \
    stdlib/SDL_strtokr.c \
    test/ \
    video/directx/SDL_d3d12_xbox_cmacros.h \
    video/directx/d3d12.h \
    video/directx/d3d12sdklayers.h \
    video/khronos \
    video/x11/edid-parse.c \
    video/x11/xsettings-client.* \
    video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
Sam Lantinga 2024-08-22 10:30:45 -07:00
parent 658fc3db0f
commit 6501e90018
743 changed files with 11882 additions and 11882 deletions

View file

@ -24,7 +24,7 @@
#ifdef SDL_INPUT_LINUXKD
/* This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source */
// This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source
#include <unistd.h>
#include <fcntl.h>
@ -32,7 +32,7 @@
#include <linux/kd.h>
#include <linux/keyboard.h>
#include <linux/vt.h>
#include <linux/tiocl.h> /* for TIOCL_GETSHIFTSTATE */
#include <linux/tiocl.h> // for TIOCL_GETSHIFTSTATE
#include <signal.h>
@ -40,7 +40,7 @@
#include "SDL_evdev_kbd_default_accents.h"
#include "SDL_evdev_kbd_default_keymap.h"
/* These are not defined in older Linux kernel headers */
// These are not defined in older Linux kernel headers
#ifndef K_UNICODE
#define K_UNICODE 0x03
#endif
@ -87,12 +87,12 @@ struct SDL_EVDEV_keyboard_state
SDL_bool muted;
int old_kbd_mode;
unsigned short **key_maps;
unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
unsigned char shift_down[NR_SHIFT]; // shift state counters..
SDL_bool dead_key_next;
int npadch; /* -1 or number assembled on pad */
int npadch; // -1 or number assembled on pad
struct kbdiacrs *accents;
unsigned int diacr;
SDL_bool rep; /* flag telling character repeat */
SDL_bool rep; // flag telling character repeat
unsigned char lockstate;
unsigned char slockstate;
unsigned char ledflagstate;
@ -125,7 +125,7 @@ static void SDL_EVDEV_dump_accents(SDL_EVDEV_keyboard_state *kbd)
printf(" }\n");
printf("};\n");
}
#endif /* DUMP_ACCENTS */
#endif // DUMP_ACCENTS
#ifdef DUMP_KEYMAP
static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd)
@ -155,7 +155,7 @@ static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd)
}
printf("};\n");
}
#endif /* DUMP_KEYMAP */
#endif // DUMP_KEYMAP
static SDL_EVDEV_keyboard_state *kbd_cleanup_state = NULL;
static int kbd_cleanup_sigactions_installed = 0;
@ -164,7 +164,7 @@ static int kbd_cleanup_atexit_installed = 0;
static struct sigaction old_sigaction[NSIG];
static int fatal_signals[] = {
/* Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit. */
// Handlers for SIGTERM and SIGINT are installed in SDL_InitQuit.
SIGHUP, SIGQUIT, SIGILL, SIGABRT,
SIGFPE, SIGSEGV, SIGPIPE, SIGBUS,
SIGSYS
@ -194,22 +194,22 @@ static void kbd_cleanup_signal_action(int signum, siginfo_t *info, void *ucontex
struct sigaction *old_action_p = &(old_sigaction[signum]);
sigset_t sigset;
/* Restore original signal handler before going any further. */
// Restore original signal handler before going any further.
sigaction(signum, old_action_p, NULL);
/* Unmask current signal. */
// Unmask current signal.
sigemptyset(&sigset);
sigaddset(&sigset, signum);
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
/* Save original signal info and context for archeologists. */
// Save original signal info and context for archeologists.
SDL_EVDEV_kdb_cleanup_siginfo = info;
SDL_EVDEV_kdb_cleanup_ucontext = ucontext;
/* Restore keyboard. */
// Restore keyboard.
kbd_cleanup();
/* Reraise signal. */
// Reraise signal.
SDL_EVDEV_kbd_reraise_signal(signum);
}
@ -230,27 +230,27 @@ static void kbd_unregister_emerg_cleanup(void)
int signum = fatal_signals[tabidx];
old_action_p = &(old_sigaction[signum]);
/* Examine current signal action */
// Examine current signal action
if (sigaction(signum, NULL, &cur_action)) {
continue;
}
/* Check if action installed and not modified */
// Check if action installed and not modified
if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) {
continue;
}
/* Restore original action */
// Restore original action
sigaction(signum, old_action_p, NULL);
}
}
static void kbd_cleanup_atexit(void)
{
/* Restore keyboard. */
// Restore keyboard.
kbd_cleanup();
/* Try to restore signal handlers in case shared library is being unloaded */
// Try to restore signal handlers in case shared library is being unloaded
kbd_unregister_emerg_cleanup();
}
@ -333,7 +333,7 @@ static SDL_bool setup_vt_signal(int signum, signal_handler handler)
return SDL_FALSE;
}
if (old_action_p->sa_handler != SIG_DFL) {
/* This signal is already in use */
// This signal is already in use
sigaction(signum, old_action_p, NULL);
return SDL_FALSE;
}
@ -432,7 +432,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
return NULL;
}
/* This might fail if we're not connected to a tty (e.g. on the Steam Link) */
// This might fail if we're not connected to a tty (e.g. on the Steam Link)
kbd->console_fd = open("/dev/tty", O_RDONLY | O_CLOEXEC);
if (!((ioctl(kbd->console_fd, KDGKBTYPE, &kbtype) == 0) && ((kbtype == KB_101) || (kbtype == KB_84)))) {
close(kbd->console_fd);
@ -453,7 +453,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
kbd->key_maps = default_key_maps;
if (ioctl(kbd->console_fd, KDGKBMODE, &kbd->old_kbd_mode) == 0) {
/* Set the keyboard in UNICODE mode and load the keymaps */
// Set the keyboard in UNICODE mode and load the keymaps
ioctl(kbd->console_fd, KDSKBMODE, K_UNICODE);
}
@ -489,7 +489,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
} else {
kbd_unregister_emerg_cleanup();
/* Restore the original keyboard mode */
// Restore the original keyboard mode
ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
}
state->muted = muted;
@ -549,7 +549,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
*/
static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c)
{
/* c is already part of a UTF-8 sequence and safe to add as a character */
// c is already part of a UTF-8 sequence and safe to add as a character
if (kbd->text_len < (sizeof(kbd->text) - 1)) {
kbd->text[kbd->text_len++] = (char)c;
}
@ -599,7 +599,7 @@ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch)
if (kbd->console_fd >= 0)
if (ioctl(kbd->console_fd, KDGKBDIACR, kbd->accents) < 0) {
/* No worries, we'll use the default accent table */
// No worries, we'll use the default accent table
}
for (i = 0; i < kbd->accents->kb_cnt; i++) {
@ -721,7 +721,7 @@ static void k_lowercase(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char
static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag)
{
if (up_flag) {
return; /* no action, if this is a key release */
return; // no action, if this is a key release
}
if (kbd->diacr) {
@ -774,11 +774,11 @@ static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_fl
static const char pad_chars[] = "0123456789+-*/\015,.?()#";
if (up_flag) {
return; /* no action, if this is a key release */
return; // no action, if this is a key release
}
if (!vc_kbd_led(kbd, K_NUMLOCK)) {
/* unprintable action */
// unprintable action
return;
}
@ -821,7 +821,7 @@ static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
kbd->shift_state &= ~(1 << value);
}
/* kludge */
// kludge
if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) {
put_utf8(kbd, kbd->npadch);
kbd->npadch = -1;
@ -841,10 +841,10 @@ static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
}
if (value < 10) {
/* decimal input of code, while Alt depressed */
// decimal input of code, while Alt depressed
base = 10;
} else {
/* hexadecimal input of code, while AltGr depressed */
// hexadecimal input of code, while AltGr depressed
value -= 10;
base = 16;
}
@ -873,7 +873,7 @@ static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_
}
chg_vc_kbd_slock(kbd, value);
/* try to make Alt, oops, AltGr and such work */
// try to make Alt, oops, AltGr and such work
if (!kbd->key_maps[kbd->lockstate ^ kbd->slockstate]) {
kbd->slockstate = 0;
chg_vc_kbd_slock(kbd, value);
@ -900,7 +900,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
key_map = state->key_maps[shift_final];
if (!key_map) {
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
// Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state
state->shift_state = 0;
state->slockstate = 0;
state->lockstate = 0;
@ -932,7 +932,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
} else {
type -= 0xf0;
/* if type is KT_LETTER then it can be affected by Caps Lock */
// if type is KT_LETTER then it can be affected by Caps Lock
if (type == KT_LETTER) {
type = KT_LATIN;
@ -967,7 +967,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
}
}
#elif !defined(SDL_INPUT_FBSDKBIO) /* !SDL_INPUT_LINUXKD */
#elif !defined(SDL_INPUT_FBSDKBIO) // !SDL_INPUT_LINUXKD
SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
{
@ -994,4 +994,4 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
{
}
#endif /* SDL_INPUT_LINUXKD */
#endif // SDL_INPUT_LINUXKD