diff --git a/include/boost/nowide/args.hpp b/include/boost/nowide/args.hpp index 134e04b..95bfd3d 100644 --- a/include/boost/nowide/args.hpp +++ b/include/boost/nowide/args.hpp @@ -33,18 +33,21 @@ namespace nowide { /// Microsoft Windows. /// /// The class uses \c GetCommandLineW(), \c CommandLineToArgvW() and \c GetEnvironmentStringsW() - /// in order to obtain the information. It does not relates to actual values of argc,argv and env + /// in order to obtain the information. It does not relate to actual values of argc,argv and env /// under Windows. /// /// It restores the original values in its destructor /// + /// If any of the system calls fails, an exception of type std::runtime_error will be thrown + /// and argc, argv, env remain unchanged. + /// /// \note the class owns the memory of the newly allocated strings /// class args { public: /// - /// Fix command line agruments + /// Fix command line arguments /// args(int &argc,char **&argv) : old_argc_(argc), @@ -57,18 +60,18 @@ namespace nowide { fix_args(argc,argv); } /// - /// Fix command line agruments and environment + /// Fix command line arguments and environment /// - args(int &argc,char **&argv,char **&en) : + args(int &argc,char **&argv,char **&env) : old_argc_(argc), old_argv_(argv), - old_env_(en), + old_env_(env), old_argc_ptr_(&argc), old_argv_ptr_(&argv), - old_env_ptr_(&en) + old_env_ptr_(&env) { fix_args(argc,argv); - fix_env(en); + fix_env(env); } /// /// Restore original argc,argv,env values, if changed @@ -89,49 +92,34 @@ namespace nowide { wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(),&wargc); if(!wargv) throw std::runtime_error("Could not get command line!"); - try{ - args_.resize(wargc+1,0); - arg_values_.resize(wargc); - for(int i=0;i args_;