PU.h sprintf fixing
Adjust our customised pu.h to use snprintf, with correct buffer size information. Also adjust includes so our custom version is used, ] even when including the system puAux.h.
This commit is contained in:
parent
048cb38cd0
commit
f7b0b77abb
7 changed files with 66 additions and 13 deletions
|
@ -1,10 +1,20 @@
|
|||
// AirportList.hxx - scrolling list of airports.
|
||||
|
||||
#ifndef __AIRPORTLIST_HXX
|
||||
#define __AIRPORTLIST_HXX
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
// ensure we include this before puAux.h, so that
|
||||
// #define _PU_H_ 1 has been done, and hence we don't
|
||||
// include the un-modified system pu.h
|
||||
#include "FlightGear_pu.h"
|
||||
|
||||
#include <plib/puAux.h>
|
||||
|
||||
#include "FGPUIDialog.hxx"
|
||||
|
||||
class FGAirportList;
|
||||
|
@ -23,4 +33,3 @@ private:
|
|||
std::string _filter;
|
||||
};
|
||||
|
||||
#endif // __AIRPORTLIST_HXX
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
// FGPUIDialog.hxx - XML-configured dialog box.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2012 (C) James Turner <james@flightgear.org>
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dialog.hxx"
|
||||
|
||||
// ensure we include this before puAux.h, so that
|
||||
// #define _PU_H_ 1 has been done, and hence we don't
|
||||
// include the un-modified system pu.h
|
||||
#include "FlightGear_pu.h"
|
||||
|
||||
#include <plib/puAux.h>
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
|
|
@ -377,6 +377,10 @@ protected:
|
|||
int * getIntegerp ( void ) { return res_integer != NULL ? res_integer : &integer ; }
|
||||
float * getFloaterp ( void ) { return res_floater != NULL ? res_floater : &floater ; }
|
||||
char * getStringp ( void ) { return res_string != NULL ? res_string : string ; }
|
||||
|
||||
// added by James to allow sprintf -> snprintf migration
|
||||
int getStringLength() { return res_string != NULL ? res_string_sz : string_size ;}
|
||||
|
||||
bool * getBooleanp ( void ) { return res_bool != NULL ? res_bool : &boolean ; }
|
||||
|
||||
void enableConversion ( void ) { convert = TRUE ; }
|
||||
|
@ -468,7 +472,9 @@ public:
|
|||
|
||||
if ( convert == TRUE )
|
||||
{
|
||||
*getFloaterp () = (float) i ; sprintf ( getStringp (), "%d", i ) ; *getBooleanp () = ( i != 0 ) ;
|
||||
*getFloaterp () = (float) i ;
|
||||
snprintf ( getStringp (), getStringLength(), "%d", i ) ;
|
||||
*getBooleanp () = ( i != 0 ) ;
|
||||
}
|
||||
|
||||
puPostRefresh () ;
|
||||
|
@ -480,7 +486,9 @@ public:
|
|||
|
||||
if ( convert == TRUE )
|
||||
{
|
||||
*getIntegerp () = (int) f ; sprintf ( getStringp (), "%g", f ) ; *getBooleanp () = ( f != 0.0 ) ;
|
||||
*getIntegerp () = (int) f ;
|
||||
snprintf ( getStringp (), getStringLength(), "%g", f ) ;
|
||||
*getBooleanp () = ( f != 0.0 ) ;
|
||||
}
|
||||
|
||||
puPostRefresh () ;
|
||||
|
@ -494,7 +502,9 @@ public:
|
|||
|
||||
if ( convert == TRUE )
|
||||
{
|
||||
*getIntegerp () = b ? 1 : 0 ; *getFloaterp () = b ? 1.0f : 0.0f ; sprintf ( getStringp (), "%s", b ? "1" : "0" ) ;
|
||||
*getIntegerp () = b ? 1 : 0 ;
|
||||
*getFloaterp () = b ? 1.0f : 0.0f ;
|
||||
snprintf ( getStringp (), getStringLength(), "%s", b ? "1" : "0" ) ;
|
||||
}
|
||||
|
||||
puPostRefresh () ;
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
/*
|
||||
* SPDX-FileCopyrightText: (C) 2010 James Turner <james@flightgear.org>
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "MapWidget.hxx"
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm> // for std::sort
|
||||
|
||||
// ensure we include this before puAux.h, so that
|
||||
// #define _PU_H_ 1 has been done, and hence we don't
|
||||
// include the un-modified system pu.h
|
||||
#include "FlightGear_pu.h"
|
||||
|
||||
#include <plib/puAux.h>
|
||||
|
||||
#include <simgear/sg_inlines.h>
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#ifndef GUI_MAPWIDGET_HXX
|
||||
#define GUI_MAPWIDGET_HXX
|
||||
/*
|
||||
* SPDX-FileCopyrightText: (C) 2010 James Turner <james@flightgear.org>
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <simgear/compiler.h>
|
||||
|
@ -158,5 +162,3 @@ private:
|
|||
double _gridSpacing;
|
||||
SGGeod _gridCenter;
|
||||
};
|
||||
|
||||
#endif // of GUI_MAPWIDGET_HXX
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
// new_gui.cxx: implementation of XML-configurable GUI support.
|
||||
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "new_gui.hxx"
|
||||
|
@ -35,6 +39,11 @@
|
|||
#endif
|
||||
|
||||
#if defined(HAVE_PUI)
|
||||
// ensure we include this before puAux.h, so that
|
||||
// #define _PU_H_ 1 has been done, and hence we don't
|
||||
// include the un-modified system pu.h
|
||||
#include "FlightGear_pu.h"
|
||||
|
||||
#include <plib/puAux.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
// ensure we include this before puAux.h, so that
|
||||
// #define _PU_H_ 1 has been done, and hence we don't
|
||||
// include the un-modified system pu.h
|
||||
#include "FlightGear_pu.h"
|
||||
|
||||
#include <plib/puAux.h>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include "FGPUIDialog.hxx"
|
||||
|
|
Loading…
Reference in a new issue