SDL: Fix typos (thanks @qndel!)

From bd04459cde15f3d66b70c721489a8127ab6d92f5 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 18 Sep 2024 08:03:26 -0700
Subject: [PATCH] Fix typos (thanks @qndel!)

Fix typos in comments and in one case in a returned error ("insuffient -> insufficient" fb273eb)
codespell src/ *.cpp *.h *.hpp --ignore-words-list unknwn,thid,algebric,statics,pixelX,pEvents,caf,ptd,parms,pEvent,parm,TextureRS,TE,HDA,LOD,datas,UE,xwindows,IIF
cd src; git checkout \
    events/imKStoUCS.* \
    hidapi \
    joystick/controller_type.c \
    joystick/controller_type.h \
    joystick/hidapi/steam/controller_constants.h \
    joystick/hidapi/steam/controller_structs.h \
    libm \
    stdlib/SDL_malloc.c \
    stdlib/SDL_qsort.c \
    stdlib/SDL_strtokr.c \
    video/khronos \
    video/x11/edid.h \
    video/x11/edid-parse.c \
    video/x11/xsettings-client.* \
    video/yuv2rgb
---
 docs/README-migration.md                |  4 ++--
 include/SDL3/SDL_hints.h                |  2 +-
 src/atomic/SDL_spinlock.c               |  4 ++--
 src/audio/SDL_audiocvt.c                |  2 +-
 src/audio/dummy/SDL_dummyaudio.h        |  2 +-
 src/camera/SDL_camera.c                 |  2 +-
 src/camera/android/SDL_camera_android.c |  2 +-
 src/core/linux/SDL_evdev.c              |  4 ++--
 src/core/windows/SDL_windows.h          |  2 +-
 src/dialog/SDL_dialog_utils.h           |  2 +-
 src/dynapi/gendynapi.py                 |  2 +-
 src/gpu/d3d12/SDL_gpu_d3d12.c           |  2 +-
 src/gpu/vulkan/SDL_gpu_vulkan.c         |  2 +-
 src/joystick/SDL_joystick.c             |  2 +-
 src/misc/ios/SDL_sysurl.m               |  2 +-
 src/stdlib/SDL_random.c                 |  2 +-
 src/test/SDL_test_harness.c             |  2 +-
 src/time/SDL_time.c                     |  2 +-
 src/video/SDL_video.c                   |  4 ++--
 src/video/wayland/SDL_waylandevents.c   |  2 +-
 src/video/wayland/SDL_waylandwindow.c   |  2 +-
 test/testaudio.c                        | 12 ++++++------
 22 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/docs/README-migration.md b/docs/README-migration.md
index ed52ec01c3eb9..43aa25eaabc05 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1827,9 +1827,9 @@ But if you're migrating your code which uses masks, you probably have a format i
 
 SDL_BlitSurface() and SDL_BlitSurfaceScaled() now have a const `dstrect` parameter and do not fill it in with the final destination rectangle.
 
-SDL_BlitSurfaceScaled() and SDL_BlitSurfaceUncheckedScaled() now take a scale paramater.
+SDL_BlitSurfaceScaled() and SDL_BlitSurfaceUncheckedScaled() now take a scale parameter.
 
-SDL_SoftStretch() now takes a scale paramater.
+SDL_SoftStretch() now takes a scale parameter.
 
 SDL_PixelFormat is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
 
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index c276ad9b54b7f..ceea7fe43db06 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -2497,7 +2497,7 @@ extern "C" {
  * system while relative mode is active, in case the desired confinement state
  * became out-of-sync due to interference from other running programs.
  *
- * The variable can be integers representing miliseconds between each refresh.
+ * The variable can be integers representing milliseconds between each refresh.
  * A value of zero means SDL will not automatically refresh the confinement.
  * The default value varies depending on the operating system, this variable
  * might not have any effects on inapplicable platforms such as those without
diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index 4a44ad47d4ba4..ad5ba15df6bc4 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -129,14 +129,14 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock)
 #elif defined(PS2)
     uint32_t oldintr;
     bool res = false;
-    // disable interuption
+    // disable interruption
     oldintr = DIntr();
 
     if (*lock == 0) {
         *lock = 1;
         res = true;
     }
-    // enable interuption
+    // enable interruption
     if (oldintr) {
         EIntr();
     }
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index bb0f1c38df29b..6423282d7f48c 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -1013,7 +1013,7 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
     // Calculate the number of input frames necessary for this request.
     // Because resampling happens "between" frames, The same number of output_frames
     // can require a different number of input_frames, depending on the resample_offset.
-    // Infact, input_frames can sometimes even be zero when upsampling.
+    // In fact, input_frames can sometimes even be zero when upsampling.
     const int input_frames = (int) SDL_GetResamplerInputFrames(output_frames, resample_rate, stream->resample_offset);
 
     const int padding_frames = SDL_GetResamplerPaddingFrames(resample_rate);
diff --git a/src/audio/dummy/SDL_dummyaudio.h b/src/audio/dummy/SDL_dummyaudio.h
index 6f4c31c97917f..fd46c3a8f03ab 100644
--- a/src/audio/dummy/SDL_dummyaudio.h
+++ b/src/audio/dummy/SDL_dummyaudio.h
@@ -28,7 +28,7 @@
 struct SDL_PrivateAudioData
 {
     Uint8 *mixbuf;   // The file descriptor for the audio device
-    Uint32 io_delay; // miliseconds to sleep in WaitDevice.
+    Uint32 io_delay; // milliseconds to sleep in WaitDevice.
 };
 
 #endif // SDL_dummyaudio_h_
diff --git a/src/camera/SDL_camera.c b/src/camera/SDL_camera.c
index 419fa9d675717..e153010d2dba1 100644
--- a/src/camera/SDL_camera.c
+++ b/src/camera/SDL_camera.c
@@ -116,7 +116,7 @@ bool SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_
 static bool ZombieWaitDevice(SDL_Camera *device)
 {
     if (!SDL_GetAtomicInt(&device->shutdown)) {
-        // !!! FIXME: this is bad for several reasons (uses double, could be precalculated, doesn't track elasped time).
+        // !!! FIXME: this is bad for several reasons (uses double, could be precalculated, doesn't track elapsed time).
         const double duration = ((double) device->actual_spec.framerate_denominator / ((double) device->actual_spec.framerate_numerator));
         SDL_Delay((Uint32) (duration * 1000.0));
     }
diff --git a/src/camera/android/SDL_camera_android.c b/src/camera/android/SDL_camera_android.c
index 640b291617ae7..835c22abc6ab8 100644
--- a/src/camera/android/SDL_camera_android.c
+++ b/src/camera/android/SDL_camera_android.c
@@ -194,7 +194,7 @@ static const char *MediaStatusStr(const media_status_t rc)
 {
     switch (rc) {
         case AMEDIA_OK: return "no error";
-        case AMEDIACODEC_ERROR_INSUFFICIENT_RESOURCE: return "insuffient resources";
+        case AMEDIACODEC_ERROR_INSUFFICIENT_RESOURCE: return "insufficient resources";
         case AMEDIACODEC_ERROR_RECLAIMED: return "reclaimed";
         case AMEDIA_ERROR_UNKNOWN: return "unknown error";
         case AMEDIA_ERROR_MALFORMED: return "malformed";
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 0419ca147dac9..c9efa536f827e 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -352,9 +352,9 @@ void SDL_EVDEV_Poll(void)
                     }
 
                     /* BTN_TOUCH event value 1 indicates there is contact with
-                       a touchscreen or trackpad (earlist finger's current
+                       a touchscreen or trackpad (earliest finger's current
                        position is sent in EV_ABS ABS_X/ABS_Y, switching to
-                       next finger after earlist is released) */
+                       next finger after earliest is released) */
                     if (item->is_touchscreen && event->code == BTN_TOUCH) {
                         if (item->touchscreen_data->max_slots == 1) {
                             if (event->value) {
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index 9bf2902f0c554..854c072cec05c 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -161,7 +161,7 @@ extern BOOL WIN_IsRectEmpty(const RECT *rect);
 
 extern SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat);
 
-// WideCharToMultiByte, but with some WinXP manangement.
+// WideCharToMultiByte, but with some WinXP management.
 extern int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
 
 // Ends C function definitions when using C++
diff --git a/src/dialog/SDL_dialog_utils.h b/src/dialog/SDL_dialog_utils.h
index 1422231acf669..6c5a77df10df1 100644
--- a/src/dialog/SDL_dialog_utils.h
+++ b/src/dialog/SDL_dialog_utils.h
@@ -46,7 +46,7 @@ char *convert_filter(const SDL_DialogFileFilter filter, NameTransform ntf,
                      const char *suffix, const char *ext_prefix,
                      const char *ext_separator, const char *ext_suffix);
 
-// Converts the extenstion list of a filter into a single string.
+// Converts the extension list of a filter into a single string.
 // <prefix>[extension]{<separator>[extension]...}<suffix>
 char *convert_ext_list(const char *list, const char *prefix,
                        const char *separator, const char *suffix);
diff --git a/src/dynapi/gendynapi.py b/src/dynapi/gendynapi.py
index 70de57cae929c..651174aa03483 100755
--- a/src/dynapi/gendynapi.py
+++ b/src/dynapi/gendynapi.py
@@ -85,7 +85,7 @@ def main():
                     ignore_wiki_documentation = False
                 continue
 
-            # Discard wiki documentions blocks.
+            # Discard wiki documentations blocks.
             if line.startswith("#ifdef SDL_WIKI_DOCUMENTATION_SECTION"):
                 ignore_wiki_documentation = True
                 continue
diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c
index 26efd76860a92..10693c8f20f67 100644
--- a/src/gpu/d3d12/SDL_gpu_d3d12.c
+++ b/src/gpu/d3d12/SDL_gpu_d3d12.c
@@ -888,7 +888,7 @@ struct D3D12UniformBuffer
     Uint32 currentBlockSize;
 };
 
-// Foward function declarations
+// Forward function declarations
 
 static void D3D12_ReleaseWindow(SDL_GPURenderer *driverData, SDL_Window *window);
 static void D3D12_Wait(SDL_GPURenderer *driverData);
diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c
index 32cb795c8ab63..ff9237d5da62d 100644
--- a/src/gpu/vulkan/SDL_gpu_vulkan.c
+++ b/src/gpu/vulkan/SDL_gpu_vulkan.c
@@ -2408,7 +2408,7 @@ static void VULKAN_INTERNAL_TrackUniformBuffer(
  *
  * This strategy imposes certain limitations on resource usage flags.
  * For example, a texture cannot have both the SAMPLER and GRAPHICS_STORAGE usage flags,
- * because then it is imposible for the backend to infer which default usage mode the texture should use.
+ * because then it is impossible for the backend to infer which default usage mode the texture should use.
  *
  * Sync hazards can be detected by setting VK_KHRONOS_VALIDATION_VALIDATE_SYNC=1 when using validation layers.
  */
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 349d44191f830..43843e341ff27 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -213,7 +213,7 @@ static Uint32 initial_blacklist_devices[] = {
     // Microsoft Nano Transceiver v2.0
     MAKE_VIDPID(0x045e, 0x0800),
 
-    MAKE_VIDPID(0x046d, 0xc30a), // Logitech, Inc. iTouch Composite keboard
+    MAKE_VIDPID(0x046d, 0xc30a), // Logitech, Inc. iTouch Composite keyboard
 
     MAKE_VIDPID(0x04d9, 0xa0df), // Tek Syndicate Mouse (E-Signal USB Gaming Mouse)
 
diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m
index 9de531b9a4c0c..9a504b21e2236 100644
--- a/src/misc/ios/SDL_sysurl.m
+++ b/src/misc/ios/SDL_sysurl.m
@@ -31,7 +31,7 @@ bool SDL_SYS_OpenURL(const char *url)
     @autoreleasepool {
 
 #ifdef SDL_PLATFORM_VISIONOS
-        return SDL_Unsupported();  // openURL is not suported on visionOS
+        return SDL_Unsupported();  // openURL is not supported on visionOS
 #else
         NSString *nsstr = [NSString stringWithUTF8String:url];
         NSURL *nsurl = [NSURL URLWithString:nsstr];
diff --git a/src/stdlib/SDL_random.c b/src/stdlib/SDL_random.c
index ac55fa72188bb..37c29cd8c31b0 100644
--- a/src/stdlib/SDL_random.c
+++ b/src/stdlib/SDL_random.c
@@ -96,7 +96,7 @@ Sint32 SDL_rand_r(Uint64 *state, Sint32 n)
 
     if (n < 0) {
         // The algorithm looks like it works for numbers < 0 but it has an
-        // infintesimal chance of returning a value out of range.
+        // infinitesimal chance of returning a value out of range.
         // Returning -SDL_rand(abs(n)) blows up at INT_MIN instead.
         // It's easier to just say no.
         return 0;
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index 9704f36ba7955..2300afc54abfb 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -523,7 +523,7 @@ int SDLTest_ExecuteTestSuiteRunner(SDLTest_TestSuiteRunner *runner)
 
     /* Mix the list of suites to run them in random order */
     {
-        /* Exclude last test "subsystemsTestSuite" which is said to interfer with other tests */
+        /* Exclude last test "subsystemsTestSuite" which is said to interfere with other tests */
         nbSuites--;
 
         if (runner->user.execKey != 0) {
diff --git a/src/time/SDL_time.c b/src/time/SDL_time.c
index 2e63efc26e468..07c410fac2831 100644
--- a/src/time/SDL_time.c
+++ b/src/time/SDL_time.c
@@ -195,7 +195,7 @@ SDL_bool SDL_DateTimeToTime(const SDL_DateTime *dt, SDL_Time *ticks)
 void SDL_TimeToWindows(SDL_Time ticks, Uint32 *dwLowDateTime, Uint32 *dwHighDateTime)
 {
     /* Convert nanoseconds to Win32 ticks.
-     * SDL_Time has a range of roughly 292 years, so even SDL_MIN_TIME can't underflow thw Win32 epoch.
+     * SDL_Time has a range of roughly 292 years, so even SDL_MIN_TIME can't underflow the Win32 epoch.
      */
     const Uint64 wtime = (Uint64)((ticks / 100) + DELTA_EPOCH_1601_100NS);
 
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 8597e0511a1fd..c215806e4ecb8 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2896,8 +2896,8 @@ SDL_bool SDL_SetWindowSize(SDL_Window *window, int w, int h)
         return SDL_InvalidParamError("h");
     }
 
-    // It is possible for the aspect ratio contraints to not satisfy the size constraints.
-    // The size constraints will override the aspect ratio contraints so we will apply the
+    // It is possible for the aspect ratio constraints to not satisfy the size constraints.
+    // The size constraints will override the aspect ratio constraints so we will apply the
     // the aspect ratio constraints first
     float new_aspect = w / (float)h;
     if (window->max_aspect > 0.0f && new_aspect > window->max_aspect) {
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index b209116d01627..eb0bf5c47626b 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -1048,7 +1048,7 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial
             SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch,
                           (SDL_FingerID)(id + 1), window_data->sdlwindow, false, x, y, 0.0f);
 
-            /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window curently
+            /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window currently
              * has mouse focus, and the surface has no active touch events, consider mouse focus to be lost.
              */
             if (!input->pointer_focus && input->keyboard_focus != window_data &&
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index e8bcc7c5ebe3a..81bc563d483fd 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -617,7 +617,7 @@ static void UpdateWindowFullscreen(SDL_Window *window, bool fullscreen)
             SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, false);
 
             /* Set the output for exclusive fullscreen windows when entering fullscreen from a
-             * compositor event, or if the fullscreen paramaters were changed between the initial
+             * compositor event, or if the fullscreen parameters were changed between the initial
              * fullscreen request and now, to ensure that the window is on the correct output,
              * as requested by the client.
              */
diff --git a/test/testaudio.c b/test/testaudio.c
index 572137e5b4682..e78d4cca57fd5 100644
--- a/test/testaudio.c
+++ b/test/testaudio.c
@@ -454,11 +454,11 @@ static void PoofThing_ondrag(Thing *thing, int button, float x, float y)
 static void PoofThing_ontick(Thing *thing, Uint64 now)
 {
     const int lifetime = POOF_LIFETIME;
-    const int elasped = (int) (now - thing->createticks);
-    if (elasped > lifetime) {
+    const int elapsed = (int) (now - thing->createticks);
+    if (elapsed > lifetime) {
         DestroyThing(thing);
     } else {
-        const float pct = ((float) elasped) / ((float) lifetime);
+        const float pct = ((float) elapsed) / ((float) lifetime);
         thing->a = (Uint8) (int) (255.0f - (pct * 255.0f));
         thing->scale = 1.0f - pct;  /* shrink to nothing! */
     }
@@ -962,13 +962,13 @@ static void PhysicalDeviceThing_ondrop(Thing *thing, int button, float x, float
 static void PhysicalDeviceThing_ontick(Thing *thing, Uint64 now)
 {
     const int lifetime = POOF_LIFETIME;
-    const int elasped = (int) (now - thing->createticks);
-    if (elasped > lifetime) {
+    const int elapsed = (int) (now - thing->createticks);
+    if (elapsed > lifetime) {
         thing->scale = 1.0f;
         thing->a = 255;
         thing->ontick = NULL;  /* no more ticking. */
     } else {
-        const float pct = ((float) elasped) / ((float) lifetime);
+        const float pct = ((float) elapsed) / ((float) lifetime);
         thing->a = (Uint8) (int) (pct * 255.0f);
         thing->scale = pct;  /* grow to normal size */
     }