@@ -1908,16 +1908,13 @@ void NinjaFoam::Sample()
19081908** This essentially copies the data and changes it inline.
19091909**
19101910*/
1911-
19121911int NinjaFoam::SanitizeOutput ()
19131912{
19141913 /*
19151914 ** Note that fin is a normal FILE used with VSI*, not VSI*L. This is for
19161915 ** the VSIFGets functions.
19171916 */
19181917 FILE *fin, *fin2;
1919- // VSILFILE *fin, *fin2;
1920- // FILE *fout, *fvrt;
19211918 VSILFILE *fout, *fvrt;
19221919 char buf[512 ];
19231920 char buf2[512 ];
@@ -1948,30 +1945,27 @@ int NinjaFoam::SanitizeOutput()
19481945 papszOutputSurfacePath[i]), " r" );
19491946 break ;
19501947 }
1951- else {
1952- continue ;
1953- }
19541948 }
19551949
19561950 fout = VSIFOpenL ( pszMem, " w" );
19571951 fvrt = VSIFOpenL ( pszVrtMem, " w" );
19581952 if ( !fin )
19591953 {
1960- CPLError ( CE_Failure, CPLE_AppDefined, " Failed to open output file for " \
1954+ CPLError ( CE_Failure, CPLE_AppDefined, " Failed to open U output file for " \
19611955 " reading." );
19621956 return NINJA_E_FILE_IO;
19631957 }
19641958 if ( !fin2 )
19651959 {
1966- CPLError ( CE_Failure, CPLE_AppDefined, " Failed to open output file for " \
1960+ CPLError ( CE_Failure, CPLE_AppDefined, " Failed to open k output file for " \
19671961 " reading." );
19681962 return NINJA_E_FILE_IO;
19691963 }
19701964 if ( !fout )
19711965 {
19721966 VSIFClose ( fin );
19731967 VSIFClose ( fin2 );
1974- CPLError ( CE_Failure, CPLE_AppDefined, " Failed to open output file for " \
1968+ CPLError ( CE_Failure, CPLE_AppDefined, " Failed to open output.raw file for " \
19751969 " writing." );
19761970 return NINJA_E_FILE_IO;
19771971 }
@@ -2016,7 +2010,6 @@ int NinjaFoam::SanitizeOutput()
20162010 /*
20172011 ** sanitize the data.
20182012 */
2019- char **papszTokens = NULL ;
20202013 while ( VSIFGets ( buf, 512 , fin ) != NULL )
20212014 {
20222015 buf[ strcspn ( buf, " \n " ) ] = ' \0 ' ;
@@ -2025,15 +2018,18 @@ int NinjaFoam::SanitizeOutput()
20252018 s2 = buf2;
20262019 ReplaceKeys ( s, " " , " ," , 5 );
20272020 ReplaceKeys ( s2, " " , " ," , 5 );
2028- papszTokens = CSLTokenizeString2 ( s2.c_str (), " ," , 0 );
2021+ char ** papszTokens = CSLTokenizeString2 ( s2.c_str (), " ," , 0 );
20292022 s = s + " ," + std::string (papszTokens[CSLCount ( papszTokens )-1 ]);
20302023 VSIFWriteL ( s.c_str (), s.size (), 1 , fout );
2024+ CSLDestroy ( papszTokens );
20312025 }
20322026
2033- CSLDestroy ( papszTokens );
2027+ CSLDestroy ( papszOutputSurfacePath );
20342028 VSIFClose ( fin );
20352029 VSIFClose ( fin2 );
20362030 VSIFCloseL ( fout );
2031+
2032+ return NINJA_SUCCESS;
20372033}
20382034
20392035static int TransformGeoToPixelSpace ( double *adfInvGeoTransform, double dfX,
0 commit comments