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

@@ -44,9 +44,9 @@ Sint64 SDL_CivilToDays(int year, int month, int day, int *day_of_week, int *day_
*day_of_week = (int)(z >= -4 ? (z + 4) % 7 : (z + 5) % 7 + 6);
}
if (day_of_year) {
/* This algorithm considers March 1 to be the first day of the year, so offset by Jan + Feb. */
// This algorithm considers March 1 to be the first day of the year, so offset by Jan + Feb.
if (doy > 305) {
/* Day 0 is the first day of the year. */
// Day 0 is the first day of the year.
*day_of_year = doy - 306;
} else {
const int doy_offset = 59 + (!(year % 4) && ((year % 100) || !(year % 400)));
@@ -59,7 +59,7 @@ Sint64 SDL_CivilToDays(int year, int month, int day, int *day_of_week, int *day_
int SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat)
{
/* Default to ISO 8061 date format, as it is unambiguous, and 24 hour time. */
// Default to ISO 8061 date format, as it is unambiguous, and 24 hour time.
if (dateFormat) {
*dateFormat = SDL_DATE_FORMAT_YYYYMMDD;
}
@@ -147,7 +147,7 @@ static SDL_bool SDL_DateTimeIsValid(const SDL_DateTime *dt)
}
if (dt->second < 0 || dt->second > 60) {
SDL_SetError("Malformed SDL_DateTime: second out of range [0-60], current: %i", dt->second);
return SDL_FALSE; /* 60 accounts for a possible leap second. */
return SDL_FALSE; // 60 accounts for a possible leap second.
}
if (dt->nanosecond < 0 || dt->nanosecond >= SDL_NS_PER_SECOND) {
SDL_SetError("Malformed SDL_DateTime: nanosecond out of range [0-999999999], current: %i", dt->nanosecond);
@@ -170,7 +170,7 @@ int SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks)
return SDL_InvalidParamError("ticks");
}
if (!SDL_DateTimeIsValid(dt)) {
/* The validation function sets the error string. */
// The validation function sets the error string.
return -1;
}
@@ -210,7 +210,7 @@ SDL_Time SDL_TimeFromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime)
Uint64 wtime = (((Uint64)dwHighDateTime << 32) | dwLowDateTime);
/* Clamp the windows time range to the SDL_Time min/max */
// Clamp the windows time range to the SDL_Time min/max
wtime = SDL_clamp(wtime, wintime_min, wintime_max);
return (SDL_Time)(wtime - DELTA_EPOCH_1601_100NS) * 100;

View File

@@ -33,4 +33,4 @@ extern Sint64 SDL_CivilToDays(int year, int month, int day, int *day_of_week, in
extern void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf);
#endif /* SDL_time_c_h_ */
#endif // SDL_time_c_h_

View File

@@ -30,7 +30,7 @@
* no timezone or DST functionality.
*/
/* 3DS epoch is Jan 1 1900 */
// 3DS epoch is Jan 1 1900
#define DELTA_EPOCH_1900_OFFSET_MS 2208988800000LL
/* Returns year/month/day triple in civil calendar
@@ -58,20 +58,20 @@ static void civil_from_days(int days, int *year, int *month, int *day)
void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
{
/* The 3DS only has 12 supported languages, so take the standard for each */
// The 3DS only has 12 supported languages, so take the standard for each
static const SDL_DateFormat LANG_TO_DATE_FORMAT[] = {
SDL_DATE_FORMAT_YYYYMMDD, /* JP */
SDL_DATE_FORMAT_DDMMYYYY, /* EN, assume non-american format */
SDL_DATE_FORMAT_DDMMYYYY, /* FR */
SDL_DATE_FORMAT_DDMMYYYY, /* DE */
SDL_DATE_FORMAT_DDMMYYYY, /* IT */
SDL_DATE_FORMAT_DDMMYYYY, /* ES */
SDL_DATE_FORMAT_YYYYMMDD, /* ZH (CN) */
SDL_DATE_FORMAT_YYYYMMDD, /* KR */
SDL_DATE_FORMAT_DDMMYYYY, /* NL */
SDL_DATE_FORMAT_DDMMYYYY, /* PT */
SDL_DATE_FORMAT_DDMMYYYY, /* RU */
SDL_DATE_FORMAT_YYYYMMDD /* ZH (TW) */
SDL_DATE_FORMAT_YYYYMMDD, // JP
SDL_DATE_FORMAT_DDMMYYYY, // EN, assume non-american format
SDL_DATE_FORMAT_DDMMYYYY, // FR
SDL_DATE_FORMAT_DDMMYYYY, // DE
SDL_DATE_FORMAT_DDMMYYYY, // IT
SDL_DATE_FORMAT_DDMMYYYY, // ES
SDL_DATE_FORMAT_YYYYMMDD, // ZH (CN)
SDL_DATE_FORMAT_YYYYMMDD, // KR
SDL_DATE_FORMAT_DDMMYYYY, // NL
SDL_DATE_FORMAT_DDMMYYYY, // PT
SDL_DATE_FORMAT_DDMMYYYY, // RU
SDL_DATE_FORMAT_YYYYMMDD // ZH (TW)
};
u8 system_language, is_north_america;
Result result, has_region;
@@ -112,7 +112,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks)
return SDL_InvalidParamError("ticks");
}
/* Returns milliseconds since the epoch. */
// Returns milliseconds since the epoch.
const Uint64 ndsTicksMax = (SDL_MAX_TIME / SDL_NS_PER_MS) + DELTA_EPOCH_1900_OFFSET_MS;
const Uint64 ndsTicks = SDL_min(osGetTime(), ndsTicksMax);
@@ -137,11 +137,11 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
rem -= dt->minute * 60;
dt->second = rem;
dt->nanosecond = ticks % SDL_NS_PER_SECOND;
dt->utc_offset = 0; /* Unknown */
dt->utc_offset = 0; // Unknown
SDL_CivilToDays(dt->year, dt->month, dt->day, &dt->day_of_week, NULL);
return 0;
}
#endif /* SDL_TIME_N3DS */
#endif // SDL_TIME_N3DS

View File

@@ -24,10 +24,10 @@
#include "../SDL_time_c.h"
/* PS2 epoch is Jan 1 2000 JST (UTC +9) */
// PS2 epoch is Jan 1 2000 JST (UTC +9)
#define UNIX_EPOCH_OFFSET_SEC 946717200
/* TODO: Implement this... */
// TODO: Implement this...
void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
{
}
@@ -62,4 +62,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
return 0;
}
#endif /* SDL_TIME_PS2 */
#endif // SDL_TIME_PS2

View File

@@ -28,7 +28,7 @@
#include "../SDL_time_c.h"
/* Sony seems to use 0001-01-01T00:00:00 as an epoch. */
// Sony seems to use 0001-01-01T00:00:00 as an epoch.
#define DELTA_EPOCH_0001_OFFSET 62135596800ULL
void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
@@ -82,7 +82,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks)
const Uint64 scetime_min = (Uint64)((SDL_MIN_TIME / div) + epoch_offset);
const Uint64 scetime_max = (Uint64)((SDL_MAX_TIME / div) + epoch_offset);
/* Clamp to the valid SDL_Time range. */
// Clamp to the valid SDL_Time range.
sceTicks = SDL_clamp(sceTicks, scetime_min, scetime_max);
*ticks = (SDL_Time)(sceTicks - epoch_offset) * div;
@@ -134,4 +134,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
return SDL_SetError("Local time conversion failed (%i)", ret);
}
#endif /* SDL_TIME_PSP */
#endif // SDL_TIME_PSP

View File

@@ -43,7 +43,7 @@ void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
if (df) {
const char *s = nl_langinfo(D_FMT);
/* Figure out the preferred system date format from the first format character. */
// Figure out the preferred system date format from the first format character.
if (s) {
while (*s) {
switch (*s++) {
@@ -75,7 +75,7 @@ found_date:
if (tf) {
const char *s = nl_langinfo(T_FMT);
/* Figure out the preferred system date format. */
// Figure out the preferred system date format.
if (s) {
while (*s) {
switch (*s++) {
@@ -123,7 +123,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks)
SDL_zero(mts);
ret = clock_get_time(cclock, &mts);
if (ret == 0) {
/* mach_timespec_t tv_sec is 32-bit, so no overflow possible */
// mach_timespec_t tv_sec is 32-bit, so no overflow possible
*ticks = SDL_SECONDS_TO_NS(mts.tv_sec) + mts.tv_nsec;
}
mach_port_deallocate(mach_task_self(), cclock);
@@ -194,4 +194,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
return SDL_SetError("SDL_DateTime conversion failed (%i)", errno);
}
#endif /* SDL_TIME_UNIX */
#endif // SDL_TIME_UNIX

View File

@@ -27,7 +27,7 @@
#include <psp2/rtc.h>
#include <psp2/system_param.h>
/* Sony seems to use 0001-01-01T00:00:00 as an epoch. */
// Sony seems to use 0001-01-01T00:00:00 as an epoch.
#define DELTA_EPOCH_0001_OFFSET 62135596800ULL
void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
@@ -88,7 +88,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks)
const Uint64 scetime_min = (Uint64)((SDL_MIN_TIME / div) + epoch_offset);
const Uint64 scetime_max = (Uint64)((SDL_MAX_TIME / div) + epoch_offset);
/* Clamp to the valid SDL_Time range. */
// Clamp to the valid SDL_Time range.
sceTicks.tick = SDL_clamp(sceTicks.tick, scetime_min, scetime_max);
*ticks = (SDL_Time)(sceTicks.tick - epoch_offset) * div;
@@ -139,4 +139,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
return SDL_SetError("Local time conversion failed (%i)", ret);
}
#endif /* SDL_TIME_VITA */
#endif // SDL_TIME_VITA

View File

@@ -34,7 +34,7 @@ typedef void(WINAPI *pfnGetSystemTimePreciseAsFileTime)(FILETIME *);
void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
{
WCHAR str[80]; /* Per the docs, the time and short date format strings can be a max of 80 characters. */
WCHAR str[80]; // Per the docs, the time and short date format strings can be a max of 80 characters.
if (df && GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, str, sizeof(str) / sizeof(WCHAR))) {
LPWSTR s = str;
@@ -57,7 +57,7 @@ void SDL_GetSystemTimeLocalePreferences(SDL_DateFormat *df, SDL_TimeFormat *tf)
found_date:
/* Figure out the preferred system date format. */
// Figure out the preferred system date format.
if (tf && GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, str, sizeof(str) / sizeof(WCHAR))) {
LPWSTR s = str;
while (*s) {
@@ -91,7 +91,7 @@ int SDL_GetCurrentTime(SDL_Time *ticks)
static pfnGetSystemTimePreciseAsFileTime pGetSystemTimePreciseAsFileTime = NULL;
static SDL_bool load_attempted = SDL_FALSE;
/* Only available in Win8/Server 2012 or higher. */
// Only available in Win8/Server 2012 or higher.
if (!pGetSystemTimePreciseAsFileTime && !load_attempted) {
HANDLE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (kernel32) {
@@ -130,7 +130,7 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
if (FileTimeToSystemTime(&ft, &utc_st)) {
if (localTime) {
if (SystemTimeToTzSpecificLocalTime(NULL, &utc_st, &local_st)) {
/* Calculate the difference for the UTC offset. */
// Calculate the difference for the UTC offset.
SystemTimeToFileTime(&local_st, &local_ft);
const SDL_Time local_ticks = SDL_TimeFromWindows(local_ft.dwLowDateTime, local_ft.dwHighDateTime);
dt->utc_offset = (int)SDL_NS_TO_SECONDS(local_ticks - ticks);
@@ -158,4 +158,4 @@ int SDL_TimeToDateTime(SDL_Time ticks, SDL_DateTime *dt, SDL_bool localTime)
return SDL_SetError("SDL_DateTime conversion failed (%lu)", GetLastError());
}
#endif /* SDL_TIME_WINDOWS */
#endif // SDL_TIME_WINDOWS