Browse Source

public: build: split Q_buildnum to separate function that calculates build number from arbitrary date string

pull/2/head
Alibek Omarov 2 years ago
parent
commit
e4a5b95e81
  1. 32
      public/build.c
  2. 1
      public/crtlib.h

32
public/build.c

@ -16,27 +16,16 @@ GNU General Public License for more details. @@ -16,27 +16,16 @@ GNU General Public License for more details.
#include "crtlib.h"
#include "buildenums.h"
static const char *date = __DATE__ ;
static const char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static const char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
/*
===============
Q_buildnum
returns days since Apr 1 2015
===============
*/
int Q_buildnum( void )
int Q_buildnum_date( const char *date )
{
static int b = 0;
int b;
int m = 0;
int d = 0;
int y = 0;
if( b != 0 )
return b;
for( m = 0; m < 11; m++ )
{
if( !Q_strnicmp( &date[0], mon[m], 3 ))
@ -57,6 +46,23 @@ int Q_buildnum( void ) @@ -57,6 +46,23 @@ int Q_buildnum( void )
return b;
}
/*
===============
Q_buildnum
returns days since Apr 1 2015
===============
*/
int Q_buildnum( void )
{
static int b = 0;
if( !b )
b = Q_buildnum_date( __DATE__ );
return b;
}
/*
=============
Q_buildnum_compat

1
public/crtlib.h

@ -48,6 +48,7 @@ enum @@ -48,6 +48,7 @@ enum
// build.c
//
int Q_buildnum( void );
int Q_buildnum_date( const char *date );
int Q_buildnum_compat( void );
const char *Q_PlatformStringByID( const int platform );
const char *Q_buildos( void );

Loading…
Cancel
Save