Skip to content

Commit

Permalink
Updated for SDL3 version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 15, 2024
1 parent 39c611e commit bf75201
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .wikiheaders-options
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mainincludefname = SDL3_rtf/SDL_rtf.h
versionfname = include/SDL3_rtf/SDL_rtf.h
versionmajorregex = \A\#define\s+SDL_RTF_MAJOR_VERSION\s+(\d+)\Z
versionminorregex = \A\#define\s+SDL_RTF_MINOR_VERSION\s+(\d+)\Z
versionpatchregex = \A\#define\s+SDL_RTF_PATCHLEVEL\s+(\d+)\Z
versionmicroregex = \A\#define\s+SDL_RTF_MICRO_VERSION\s+(\d+)\Z
selectheaderregex = \ASDL_rtf\.h\Z
projecturl = https://libsdl.org/projects/SDL_rtf
wikiurl = https://wiki.libsdl.org/SDL_rtf
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/test-versioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export LC_CTYPE=C

ref_major=$(sed -ne 's/^#define SDL_RTF_MAJOR_VERSION *//p' include/SDL3_rtf/SDL_rtf.h)
ref_minor=$(sed -ne 's/^#define SDL_RTF_MINOR_VERSION *//p' include/SDL3_rtf/SDL_rtf.h)
ref_micro=$(sed -ne 's/^#define SDL_RTF_PATCHLEVEL *//p' include/SDL3_rtf/SDL_rtf.h)
ref_micro=$(sed -ne 's/^#define SDL_RTF_MICRO_VERSION *//p' include/SDL3_rtf/SDL_rtf.h)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"

tests=0
Expand Down
22 changes: 11 additions & 11 deletions build-scripts/wikiheaders.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
my $versionfname = 'include/SDL_version.h';
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
my $versionpatchregex = '\A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z';
my $versionmicroregex = '\A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z';
my $mainincludefname = 'SDL.h';
my $selectheaderregex = '\ASDL.*?\.h\Z';
my $projecturl = 'https://libsdl.org/';
Expand Down Expand Up @@ -92,7 +92,7 @@
$readmesubdir = $val, next if $key eq 'readmesubdir';
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
$versionminorregex = $val, next if $key eq 'versionminorregex';
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
$versionmicroregex = $val, next if $key eq 'versionmicroregex';
$versionfname = $val, next if $key eq 'versionfname';
$mainincludefname = $val, next if $key eq 'mainincludefname';
$selectheaderregex = $val, next if $key eq 'selectheaderregex';
Expand Down Expand Up @@ -2036,19 +2036,19 @@ sub print_undocumented_section {
open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
my $majorver = 0;
my $minorver = 0;
my $patchver = 0;
my $microver = 0;
while (<FH>) {
chomp;
if (/$versionmajorregex/) {
$majorver = int($1);
} elsif (/$versionminorregex/) {
$minorver = int($1);
} elsif (/$versionpatchregex/) {
$patchver = int($1);
} elsif (/$versionmicroregex/) {
$microver = int($1);
}
}
close(FH);
my $fullversion = "$majorver.$minorver.$patchver";
my $fullversion = "$majorver.$minorver.$microver";

foreach (keys %headersyms) {
my $sym = $_;
Expand Down Expand Up @@ -2318,19 +2318,19 @@ sub print_undocumented_section {
open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
my $majorver = 0;
my $minorver = 0;
my $patchver = 0;
my $microver = 0;
while (<FH>) {
chomp;
if (/$versionmajorregex/) {
$majorver = int($1);
} elsif (/$versionminorregex/) {
$minorver = int($1);
} elsif (/$versionpatchregex/) {
$patchver = int($1);
} elsif (/$versionmicroregex/) {
$microver = int($1);
}
}
close(FH);
my $fullversion = "$majorver.$minorver.$patchver";
my $fullversion = "$majorver.$minorver.$microver";

my $latex_fname = "$srcpath/$projectshortname.tex";
my $latex_tmpfname = "$latex_fname.tmp";
Expand Down Expand Up @@ -2369,7 +2369,7 @@ sub print_undocumented_section {
\\begin{document}
\\frontmatter
\\title{$projectfullname $majorver.$minorver.$patchver Reference Manual}
\\title{$projectfullname $majorver.$minorver.$microver Reference Manual}
\\author{The $projectshortname Developers}
\\maketitle
Expand Down
42 changes: 18 additions & 24 deletions include/SDL3_rtf/SDL_rtf.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,36 @@
extern "C" {
#endif

/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
/**
* Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO
*/
#define SDL_RTF_MAJOR_VERSION 3
#define SDL_RTF_MINOR_VERSION 0
#define SDL_RTF_PATCHLEVEL 0
#define SDL_RTF_MICRO_VERSION 0

/* This macro can be used to fill a version structure with the compile-time
* version of the SDL_rtf library.
/**
* This is the version number macro for the current SDL_rtf version.
*/
#define SDL_RTF_VERSION(X) \
{ \
(X)->major = SDL_RTF_MAJOR_VERSION; \
(X)->minor = SDL_RTF_MINOR_VERSION; \
(X)->patch = SDL_RTF_PATCHLEVEL; \
}
#define SDL_RTF_VERSION \
SDL_VERSIONNUM(SDL_RTF_MAJOR_VERSION, SDL_RTF_MINOR_VERSION, SDL_RTF_MICRO_VERSION)

/* Backwards compatibility */
#define RTF_MAJOR_VERSION SDL_RTF_MAJOR_VERSION
#define RTF_MINOR_VERSION SDL_RTF_MINOR_VERSION
#define RTF_PATCHLEVEL SDL_RTF_PATCHLEVEL
#define RTF_VERSION(X) SDL_RTF_VERSION(X)
/**
* This macro will evaluate to true if compiled with SDL_rtf at least X.Y.Z.
*/
#define SDL_RTF_VERSION_ATLEAST(X, Y, Z) \
((SDL_RTF_MAJOR_VERSION >= X) && \
(SDL_RTF_MAJOR_VERSION > X || SDL_RTF_MINOR_VERSION >= Y) && \
(SDL_RTF_MAJOR_VERSION > X || SDL_RTF_MINOR_VERSION > Y || SDL_RTF_MICRO_VERSION >= Z))

/**
* Query the version of SDL_rtf that the program is linked against.
*
* This function gets the version of the dynamically linked SDL_rtf library.
* This is separate from the SDL_RTF_VERSION() macro, which tells you what
* version of the SDL_rtf headers you compiled against.
*
* This returns static internal data; do not free or modify it!
*
* \returns a pointer to the version information.
* \returns SDL_rtf version
*
* \since This function is available since SDL_rtf 3.0.0.
*/
extern DECLSPEC const SDL_Version * SDLCALL RTF_Linked_Version(void);
extern DECLSPEC int SDLCALL RTF_Version(void);


typedef struct _RTF_Context RTF_Context;

Expand Down
6 changes: 2 additions & 4 deletions src/SDL_rtf.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@


/* rcg06192001 get linked library's version. */
const SDL_Version *RTF_Linked_Version(void)
int RTF_Linked_Version(void)
{
static SDL_Version linked_version;
SDL_RTF_VERSION(&linked_version);
return(&linked_version);
return SDL_RTF_VERSION;
}


Expand Down

0 comments on commit bf75201

Please sign in to comment.