From 5d2c2b27a6323e2666378b986129b2a7c2c39e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 6 Feb 2022 16:04:24 +0100 Subject: New upstream version 5.2.2GA --- app/lib/params/mkcarpart.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'app/lib/params/mkcarpart.c') diff --git a/app/lib/params/mkcarpart.c b/app/lib/params/mkcarpart.c index 7680a8b..1d2bf9f 100644 --- a/app/lib/params/mkcarpart.c +++ b/app/lib/params/mkcarpart.c @@ -55,7 +55,7 @@ void readMap( { FILE * mapF; char line[256]; - int len; + size_t len; mapF = fopen( mapFile, "r" ); if ( mapF == NULL ) { perror( mapFile ); @@ -110,7 +110,7 @@ void readRoadnameMap( exit(1); } while ( fgets( line, sizeof line, mapF ) != NULL ) { - int len = strlen( line ); + size_t len = strlen( line ); if ( line[len-1] == '\n' ) line[--len] = '\0'; if ( line[0] == '\0' || line[0] == '\n' || line[0] == '#' ) @@ -282,16 +282,16 @@ void processFile( int lineNumber = 0; char roadnameS[256]; char repmarkS[256]; - int len; + size_t len; int inx; char * cp, *cq; char * tab[20]; char blanks[10]; - int partX = 1; - int descX = 2; - int roadX = 3; - int numbX = 4; - int colorX = 5; + size_t partX = 1; + size_t descX = 2; + size_t roadX = 3; + size_t numbX = 4; + size_t colorX = 5; inF = fopen( inFile, "r" ); if ( inF == NULL ) { @@ -309,18 +309,28 @@ void processFile( if ( line[0] == '\n' || line[0] == '#' ) continue; len = strlen(line); - if ( line[len-1] == '\n' ) + if ( len >= 1 && line[len-1] == '\n' ) line[len-1] = '\0'; + if ( len >= 2 && line[len-2] == '\r' ) + line[len-2] = '\0'; if ( strnicmp( line, "scale=", 6 ) == 0 ) { strcpy( scale, line+6 ); if ( stricmp( scale, "N" ) == 0 ) ratio = 160.0; - else if ( stricmp( scale, "HO" ) == 0 ) + else if ( stricmp( scale, "HO" ) == 0 || stricmp(scale, "HOn3") == 0 ) ratio = 87.1; - else if ( stricmp( scale, "O" ) == 0 ) - ratio = 48.0; - else if ( stricmp( scale, "S" ) == 0 ) + else if ( stricmp( scale, "S" ) == 0 || stricmp(scale, "Sn3") == 0 ) ratio = 64.0; + else if ( stricmp(scale, "O") == 0 || stricmp(scale, "On3") == 0 || stricmp(scale, "On30") == 0 ) + ratio = 48.0; + else if ( stricmp(scale, "1") == 0 ) + ratio = 32.0; + else if ( stricmp(scale, "A") == 0 ) + ratio = 29.0; + else if ( stricmp(scale, "G") == 0 ) + ratio = 22.5; + else if ( stricmp(scale, "F") == 0 || stricmp(scale, "Fn2") == 0 || stricmp(scale, "Fn3") == 0 ) + ratio = 20.32; else { fprintf( stderr, "%d: Unknown scale %s\n", lineNumber, scale ); ratio = 87.1; -- cgit v1.2.3