ref: 509b22c5a816888ad7819d57ea2a672a37be8c23
parent: 3b9503da9b5f5788e4fc430a3972af0099a8448c
parent: 9ad7b281f19e3a95b46c4a212250b5d8b3be3da2
author: Turo Lamminen <turol@users.noreply.github.com>
date: Wed Sep 28 06:57:22 EDT 2022
Merge pull request #1510 from turol/extern-1 Clean up extern, part 1
--- /dev/null
+++ b/check-extern.sh
@@ -1,0 +1,6 @@
+#!/bin/sh
+EXTERN="$(grep -e 'extern[^A-Za-z0-9_]' $(find . -name *.c))"
+if [ -n "$EXTERN" ] ; then
+ echo "extern found in .c files:\n${EXTERN}"
+ exit 1
+fi
--- a/opl/opl.c
+++ b/opl/opl.c
@@ -28,16 +28,6 @@
//#define OPL_DEBUG_TRACE
-#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IOPERM)
-extern opl_driver_t opl_linux_driver;
-#endif
-#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64)
-extern opl_driver_t opl_openbsd_driver;
-#endif
-#ifdef _WIN32
-extern opl_driver_t opl_win32_driver;
-#endif
-extern opl_driver_t opl_sdl_driver;
static opl_driver_t *drivers[] =
{
--- a/opl/opl_internal.h
+++ b/opl/opl_internal.h
@@ -54,5 +54,18 @@
extern unsigned int opl_sample_rate;
+
+#if (defined(__i386__) || defined(__x86_64__)) && defined(HAVE_IOPERM)
+extern opl_driver_t opl_linux_driver;
+#endif
+#if defined(HAVE_LIBI386) || defined(HAVE_LIBAMD64)
+extern opl_driver_t opl_openbsd_driver;
+#endif
+#ifdef _WIN32
+extern opl_driver_t opl_win32_driver;
+#endif
+extern opl_driver_t opl_sdl_driver;
+
+
#endif /* #ifndef OPL_INTERNAL_H */
--- a/pcsound/pcsound.c
+++ b/pcsound/pcsound.c
@@ -24,27 +24,6 @@
#include "pcsound_internal.h"
-#ifdef HAVE_DEV_ISA_SPKRIO_H
-#define HAVE_BSD_SPEAKER
-#endif
-#ifdef HAVE_DEV_SPEAKER_SPEAKER_H
-#define HAVE_BSD_SPEAKER
-#endif
-
-#ifdef _WIN32
-extern pcsound_driver_t pcsound_win32_driver;
-#endif
-
-#ifdef HAVE_BSD_SPEAKER
-extern pcsound_driver_t pcsound_bsd_driver;
-#endif
-
-#ifdef HAVE_LINUX_KD_H
-extern pcsound_driver_t pcsound_linux_driver;
-#endif
-
-extern pcsound_driver_t pcsound_sdl_driver;
-
static pcsound_driver_t *drivers[] =
{
#ifdef HAVE_LINUX_KD_H
--- a/pcsound/pcsound_internal.h
+++ b/pcsound/pcsound_internal.h
@@ -20,6 +20,13 @@
#include "pcsound.h"
+#ifdef HAVE_DEV_ISA_SPKRIO_H
+#define HAVE_BSD_SPEAKER
+#endif
+#ifdef HAVE_DEV_SPEAKER_SPEAKER_H
+#define HAVE_BSD_SPEAKER
+#endif
+
#define PCSOUND_8253_FREQUENCY 1193280
typedef struct pcsound_driver_s pcsound_driver_t;
@@ -34,6 +41,22 @@
};
extern int pcsound_sample_rate;
+
+
+#ifdef _WIN32
+extern pcsound_driver_t pcsound_win32_driver;
+#endif
+
+#ifdef HAVE_BSD_SPEAKER
+extern pcsound_driver_t pcsound_bsd_driver;
+#endif
+
+#ifdef HAVE_LINUX_KD_H
+extern pcsound_driver_t pcsound_linux_driver;
+#endif
+
+extern pcsound_driver_t pcsound_sdl_driver;
+
#endif /* #ifndef PCSOUND_INTERNAL_H */
--- a/src/deh_defs.h
+++ b/src/deh_defs.h
@@ -54,6 +54,11 @@
deh_sha1_hash_t sha1_hash;
};
+
+extern deh_section_t *deh_section_types[];
+extern const char *deh_signatures[];
+
+
#endif /* #ifndef DEH_DEFS_H */
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -31,8 +31,6 @@
#include "deh_io.h"
#include "deh_main.h"
-extern deh_section_t *deh_section_types[];
-extern const char *deh_signatures[];
static boolean deh_initialized = false;
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -494,10 +494,6 @@
void I_BindSoundVariables(void)
{
- extern char *snd_dmxoption;
- extern int use_libsamplerate;
- extern float libsamplerate_scale;
-
M_BindIntVariable("snd_musicdevice", &snd_musicdevice);
M_BindIntVariable("snd_sfxdevice", &snd_sfxdevice);
M_BindIntVariable("snd_sbport", &snd_sbport);
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -234,6 +234,9 @@
extern int snd_maxslicetime_ms;
extern char *snd_musiccmd;
extern int snd_pitchshift;
+extern char *snd_dmxoption;
+extern int use_libsamplerate;
+extern float libsamplerate_scale;
void I_BindSoundVariables(void);
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -68,8 +68,8 @@
static int musicVolume = 8;
static int voiceVolume = 15;
static int show_talk = 0;
-static int use_libsamplerate = 0;
-static float libsamplerate_scale = 0.65;
+int use_libsamplerate = 0;
+float libsamplerate_scale = 0.65;
static char *music_pack_path = NULL;
static char *timidity_cfg_path = NULL;
--- a/src/setup/sound.h
+++ b/src/setup/sound.h
@@ -20,6 +20,5 @@
void ConfigSound(void *widget, void *user_data);
void BindSoundVariables(void);
-extern char *snd_dmxoption;
#endif /* #ifndef SETUP_SOUND_H */
--- a/src/w_file.c
+++ b/src/w_file.c
@@ -25,15 +25,6 @@
#include "w_file.h"
-extern wad_file_class_t stdc_wad_file;
-
-#ifdef _WIN32
-extern wad_file_class_t win32_wad_file;
-#endif
-
-#ifdef HAVE_MMAP
-extern wad_file_class_t posix_wad_file;
-#endif
static wad_file_class_t *wad_file_classes[] =
{
--- a/src/w_file.h
+++ b/src/w_file.h
@@ -39,6 +39,18 @@
void *buffer, size_t buffer_len);
} wad_file_class_t;
+
+extern wad_file_class_t stdc_wad_file;
+
+#ifdef _WIN32
+extern wad_file_class_t win32_wad_file;
+#endif
+
+#ifdef HAVE_MMAP
+extern wad_file_class_t posix_wad_file;
+#endif
+
+
struct _wad_file_s
{
// Class of this file.
--- a/src/w_file_posix.c
+++ b/src/w_file_posix.c
@@ -36,7 +36,6 @@
int handle;
} posix_wad_file_t;
-extern wad_file_class_t posix_wad_file;
static void MapFile(posix_wad_file_t *wad, const char *filename)
{
--- a/src/w_file_stdc.c
+++ b/src/w_file_stdc.c
@@ -28,7 +28,6 @@
FILE *fstream;
} stdc_wad_file_t;
-extern wad_file_class_t stdc_wad_file;
static wad_file_t *W_StdC_OpenFile(const char *path)
{
--- a/src/w_file_win32.c
+++ b/src/w_file_win32.c
@@ -43,7 +43,6 @@
HANDLE handle_map;
} win32_wad_file_t;
-extern wad_file_class_t win32_wad_file;
static void MapFile(win32_wad_file_t *wad, const char *filename)
{
--- a/textscreen/txt_inputbox.c
+++ b/textscreen/txt_inputbox.c
@@ -26,8 +26,8 @@
#include "txt_utf8.h"
#include "txt_window.h"
-extern txt_widget_class_t txt_inputbox_class;
-extern txt_widget_class_t txt_int_inputbox_class;
+txt_widget_class_t txt_inputbox_class;
+txt_widget_class_t txt_int_inputbox_class;
static void SetBufferFromValue(txt_inputbox_t *inputbox)
{