Explorar el Código

LibCore: Reset getopt's state when starting parse()

This way, a program can use ArgsParser multiple times, potentially with
multiple different options.
AnotherTest hace 5 años
padre
commit
16ba0b39f3
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  1. 2 0
      Libraries/LibCore/ArgsParser.cpp

+ 2 - 0
Libraries/LibCore/ArgsParser.cpp

@@ -49,6 +49,8 @@ void ArgsParser::parse(int argc, char** argv)
 
     int index_of_found_long_option = -1;
 
+    optind = 0;
+
     for (size_t i = 0; i < m_options.size(); i++) {
         auto& opt = m_options[i];
         if (opt.long_name) {