Geoff Air a écrit :

Hi Fred, and others ...

First I would say I LOVE fgrun ... my hat off
to those in our community who 'remember' all the
130 plus command line options for FlightGear ... yet
they are part of its 'power' ... as well as giving
a beautiful preview of the aircraft ... fgrun takes the
angst out of changing switches ...

Before 'running' FlightGear, in run_win32.cxx,
the Wizard::run_fgfs(string & args) function
correctly encases the path in double quotes, needed if a
space exists in any of the directory names ... but it
uses the passed args to compute the lengths ... which will
always work for the first 'change' ... but will then
be 'wrong' in the second change to the copy 'line' ...

Here is the patch, in diff format -
40c40
<     string::size_type pos_fg_root = args.find( "--fg-root=" ),
---

string::size_type pos_fg_root = line.find( "--fg-root=" ),

44c44 < end_fg_root = args.find( " --", pos_fg_root + 10 ); ---

end_fg_root = line.find( " --", pos_fg_root + 10 );

49c49 < string::size_type pos_fg_scenery = args.find( "--fg-scenery=" ), ---

string::size_type pos_fg_scenery = line.find( "--fg-scenery=" ),

53c53 < end_fg_scenery = args.find( " --", pos_fg_scenery + 13 ); ---

end_fg_scenery = line.find( " --", pos_fg_scenery + 13 );


Without this 'fix' I got things like --fg-scener"y=c:\mypa"th


Thanks, strange I didn't noticed the problem.


I wrote a simple service, for another project, to do the same - it is NEEDED quite frequently in win32 ;=)) - which you could add/use/modify -

int fg_prefs::encase_arg( string & line, string arg ) {
  int iret = 0;
  string ar = "--"; // start option argument
  string are = " --"; // to next, if any
  ar += arg; // add the current argument/option
  ar += "="; // add EQUALS
  size_t pos1 = line.find(ar); // find, like '--fg-root='
  if( pos1 != string::npos ) { // if FOUND
     size_t sz = pos1 + ar.size(); // get the arg size
     size_t pos2 = line.find( are, sz ); // find next arg beginning
     if( pos2 == string::npos ) { // if NOT FOUND
        pos2 = line.size();
     }
     line.insert( pos2, "\"" ); // pop in the quotes, at the end first
     line.insert( sz, "\"" ); // then at the front of the 'path'
     iret = 1; // advise done
  }
  return iret;
}

You will note I check the find of the 'next', in case it
is the last, or only option, in the args passed ...

I would also be interested in whether my use of 'size_t',
in place of the rather long 'string::size_type' works
in all the ports ...

I use msvc7, in XP, cygwin not installed, so also do not
use pthreads ... I added a switch, HAVE_PTHREAD, for things
like -

#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif // #ifdef HAVE_PTHREAD

if anyone is interested, or headed this direction ...

I need fgrun to 'return', so I can 'select' other things,
and run (the same or different) FG, with a changed
command ... rather than at present, it shows a modal
dialog, and goes into an infinite wait, until FG
quits ... thus do not need pthreads to compile, run ...


the pthread library is available for MSVC developers : http://sources.redhat.com/pthreads-win32/

-Fred



_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to