# # # patch "ChangeLog" # from [5c754ab237cfda3cf5ed76cdef17bec2edac0df6] # to [6496500ec37be58b8a6d9939e20b59d965c9cb6d] # # patch "commands.cc" # from [9857319000bdce8f656dbbd72a282be01459fca6] # to [d129ff6c35bb6b3fb65a41c32b94e1d6233b12e5] # # patch "monotone.cc" # from [f4e2ff9591c12d439494daab38a74693715ab463] # to [8d46fa4daee40f9d1da60d5b251c8d6deebe2ce2] # ============================================================ --- ChangeLog 5c754ab237cfda3cf5ed76cdef17bec2edac0df6 +++ ChangeLog 6496500ec37be58b8a6d9939e20b59d965c9cb6d @@ -1,5 +1,10 @@ 2006-07-05 Nathaniel Smith + * commands.cc (complete_command): + * monotone.cc (cpp_main): Minor code cleanups. + +2006-07-05 Nathaniel Smith + * tests/checking_a_few_command_specific_options/__driver__.lua: Add test for minor bug reported by Marcin 'hrw' Juszkiewicz. ============================================================ --- commands.cc 9857319000bdce8f656dbbd72a282be01459fca6 +++ commands.cc d129ff6c35bb6b3fb65a41c32b94e1d6233b12e5 @@ -121,14 +121,14 @@ // no matched commands N(matched.size() != 0, - F("unknown command '%s'\n") % cmd); + F("unknown command '%s'") % cmd); // one matched command if (matched.size() == 1) { - string completed = *matched.begin(); - L(FL("expanded command to '%s'") % completed); - return completed; + string completed = *matched.begin(); + L(FL("expanded command to '%s'") % completed); + return completed; } // more than one matched command ============================================================ --- monotone.cc f4e2ff9591c12d439494daab38a74693715ab463 +++ monotone.cc 8d46fa4daee40f9d1da60d5b251c8d6deebe2ce2 @@ -595,11 +595,11 @@ // complete the command if necessary - string cmd; - if (poptPeekArg(ctx())) - { - cmd = commands::complete_command(poptGetArg(ctx())); - } + if (!poptPeekArg(ctx())) + // no command given + throw usage(""); + // poptPeekArg returned true, so we can call poptGetArg + string cmd = commands::complete_command(poptGetArg(ctx)); // stop here if they asked for help @@ -620,28 +620,21 @@ // main options processed, now invoke the // sub-command w/ remaining args - if (cmd.empty()) + // Make sure the local options used are really used by the + // given command. + set command_options = commands::command_options(cmd); + for (set::const_iterator i = used_local_options.begin(); + i != used_local_options.end(); ++i) + N(command_options.find(*i) != command_options.end(), + F("%s %s doesn't use the option %s") + % prog_name % cmd % coption_string(*i)); + + vector args; + while(poptPeekArg(ctx())) { - throw usage(""); + args.push_back(utf8(string(poptGetArg(ctx())))); } - else - { - // Make sure the local options used are really used by the - // given command. - set command_options = commands::command_options(cmd); - for (set::const_iterator i = used_local_options.begin(); - i != used_local_options.end(); ++i) - N(command_options.find(*i) != command_options.end(), - F("%s %s doesn't use the option %s") - % prog_name % cmd % coption_string(*i)); - - vector args; - while(poptPeekArg(ctx())) - { - args.push_back(utf8(string(poptGetArg(ctx())))); - } - ret = commands::process(app, cmd, args); - } + ret = commands::process(app, cmd, args); } catch (usage & u) {