Fix a number of build issues; Not all compilers support strnlen(), some platforms use more than one lend-ending character and capture lines starting with a whitespace also.
This commit is contained in:
parent
e4bce63391
commit
a383d6285b
1 changed files with 3 additions and 2 deletions
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <stdlib.h> // atof(), atoi()
|
#include <stdlib.h> // atof(), atoi()
|
||||||
#include <strings.h> // memchr()
|
#include <strings.h> // memchr()
|
||||||
|
#include <ctype.h> // isspace()
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
@ -80,7 +81,7 @@ bool fgAirportDBLoad( FGAirportList *airports, FGRunwayList *runways,
|
||||||
line = tmp;
|
line = tmp;
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_BULK, "-> '" << line << "'" );
|
SG_LOG( SG_GENERAL, SG_BULK, "-> '" << line << "'" );
|
||||||
if ( !line.size() )
|
if ( !line.size() || isspace(tmp[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (line.size() > 3) {
|
if (line.size() > 3) {
|
||||||
|
@ -100,7 +101,7 @@ bool fgAirportDBLoad( FGAirportList *airports, FGRunwayList *runways,
|
||||||
// which is the version and copyright information
|
// which is the version and copyright information
|
||||||
in.getline(tmp, 2048);
|
in.getline(tmp, 2048);
|
||||||
// vector<string> vers_token = simgear::strutils::split( tmp );
|
// vector<string> vers_token = simgear::strutils::split( tmp );
|
||||||
if ( strnlen(tmp, 2048) > 4 ) {
|
if ( strlen(tmp) > 4 ) {
|
||||||
char *p = (char *)memchr(tmp, ' ', 4);
|
char *p = (char *)memchr(tmp, ' ', 4);
|
||||||
if ( p )
|
if ( p )
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
Loading…
Reference in a new issue