|
From: Erik H. <eh...@us...> - 2015-10-25 10:07:54
|
Update of /cvsroot/jsbsim/JSBSim/utils/aeromatic++ In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7274 Modified Files: Aircraft.cpp CMakeLists.txt types.cpp types.h Log Message: slightly more accurate computation of tsfc Get rid of snprintf Proper getenv for Windows Fix Windows(MingW) build Index: Aircraft.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/utils/aeromatic++/Aircraft.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** Aircraft.cpp 24 Oct 2015 22:04:59 -0000 1.18 --- Aircraft.cpp 25 Oct 2015 10:07:50 -0000 1.19 *************** *** 24,28 **** #include <math.h> - #include <string.h> #include <ctime> --- 24,27 ---- *************** *** 48,56 **** /* general information */ #if defined(WIN32) ! std::string dir(getenv("HOMEPATH")); #else ! std::string dir(getenv("HOME")); #endif ! snprintf(_path, PARAM_MAX_STRING, "%s", dir.c_str()); _general.push_back(new Param("Output directory", "Specify the output directory for the configuration files", _path)); --- 47,55 ---- /* general information */ #if defined(WIN32) ! std::string dir(getEnv("HOMEPATH")); #else ! std::string dir(getEnv("HOME")); #endif ! strCopy(_path, dir); _general.push_back(new Param("Output directory", "Specify the output directory for the configuration files", _path)); *************** *** 59,63 **** _general.push_back(new Param("Overwrite?", "Overwrite files that are already present?", _overwrite)); ! snprintf(_name, PARAM_MAX_STRING, "my_aircraft"); _general.push_back(new Param("Aircraft name", "This defines the name and filename of the aircraft", _name)); } --- 58,62 ---- _general.push_back(new Param("Overwrite?", "Overwrite files that are already present?", _overwrite)); ! strCopy(_name, "my_aircraft"); _general.push_back(new Param("Aircraft name", "This defines the name and filename of the aircraft", _name)); } *************** *** 206,210 **** if (_inertia[X] == 0.0f && _inertia[Y] == 0.0f && _inertia[Z] == 0.0f) { ! float slugs = (_empty_weight / 32.2); // sluggishness const float *R = aircraft->get_roskam(); --- 205,209 ---- if (_inertia[X] == 0.0f && _inertia[Y] == 0.0f && _inertia[Z] == 0.0f) { ! float slugs = (_empty_weight / 32.2f); // sluggishness const float *R = aircraft->get_roskam(); *************** *** 220,224 **** cg_loc[X] = (_length - _htail_arm) * FEET_TO_INCH; cg_loc[Y] = 0; ! cg_loc[Z] = -(_length / 40.0) * FEET_TO_INCH; //***** AERO REFERENCE POINT ************************** --- 219,223 ---- cg_loc[X] = (_length - _htail_arm) * FEET_TO_INCH; cg_loc[Y] = 0; ! cg_loc[Z] = -(_length / 40.0f) * FEET_TO_INCH; //***** AERO REFERENCE POINT ************************** *************** *** 621,627 **** // Create Engines directory std::string dir = path + "/" + subdir; ! #if (win32) ! if (!PathFileExists(dir) { ! if (CreateDirectory(dir, NULL) == 0) { dir.clear(); } --- 620,626 ---- // Create Engines directory std::string dir = path + "/" + subdir; ! #if (win32 || __MINGW32__) ! if (!PathFileExists(dir.c_str())) { ! if (CreateDirectory(dir.c_str(), NULL) == 0) { dir.clear(); } Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/utils/aeromatic++/CMakeLists.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** CMakeLists.txt 21 Oct 2015 07:15:20 -0000 1.5 --- CMakeLists.txt 25 Oct 2015 10:07:50 -0000 1.6 *************** *** 64,67 **** ADD_LIBRARY( ${LIBAEROMATIC3} STATIC ${AEROMATIC_OBJS} ) ADD_EXECUTABLE( aeromatic aeromatic.cpp ) ! TARGET_LINK_LIBRARIES( aeromatic ${LIBAEROMATIC3} ) --- 64,71 ---- ADD_LIBRARY( ${LIBAEROMATIC3} STATIC ${AEROMATIC_OBJS} ) + IF(WIN32) + SET(EXTRA_LIBS ${EXTRA_LIBS} "shlwapi.lib") + ENDIF(WIN32) + ADD_EXECUTABLE( aeromatic aeromatic.cpp ) ! TARGET_LINK_LIBRARIES( aeromatic ${LIBAEROMATIC3} ${EXTRA_LIBS}) Index: types.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/utils/aeromatic++/types.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** types.cpp 22 Oct 2015 08:14:30 -0000 1.8 --- types.cpp 25 Oct 2015 10:07:50 -0000 1.9 *************** *** 24,30 **** #include <iostream> ! ! #include <stdlib.h> ! #include <stdio.h> #include "types.h" --- 24,29 ---- #include <iostream> ! #include <sstream> ! #include <string> #include "types.h" *************** *** 33,36 **** --- 32,59 ---- { + void strCopy(char *b, std::string str) + { + std::size_t l = str.copy(b, PARAM_MAX_STRING); + b[l] = 0; + } + + #ifdef WIN32 + char* + getEnv(const char*name) + { + static char _key[256] = ""; + char *rv = NULL; + DWORD res, err; + + res = GetEnvironmentVariable(name, (LPSTR)&_key, 256); + err = GetLastError(); + if (res || !err) { + rv = (char*)&_key; + } + + return rv; + } + #endif + template <> Param::Param<bool>(const char* n, const char *h, bool& v, const bool& c, unsigned t) : *************** *** 94,98 **** break; case PARAM_STRING: ! snprintf(_value.s, PARAM_MAX_STRING, "%s", v.c_str()); break; case PARAM_UNSUPPORTED: --- 117,121 ---- break; case PARAM_STRING: ! strCopy(_value.s, v); break; case PARAM_UNSUPPORTED: *************** *** 104,111 **** std::string Param::get() { ! char val[PARAM_MAX_STRING+1]; ! float fact = 1.0f; std::string str; switch(_ptype) { --- 127,135 ---- std::string P |