Commit 7cc0018a authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

operatorInputArg: Wait until input is done.

parent d7284b39
Pipeline #4926 passed with stages
in 16 minutes and 37 seconds
......@@ -116,7 +116,7 @@ cdoGetOperArgv()
void
operatorCheckArgc(int numargs)
{
const int argc = localProcess->m_oargc;
const auto argc = localProcess->m_oargc;
if (argc < numargs)
cdoAbort("Too few arguments! Need %d found %d.", numargs, argc);
......@@ -138,35 +138,41 @@ getInput()
{
char pline[1024];
std::string fline = "";
do
{
std::cin.getline(pline, 1024);
std::cout << pline << std::endl;
//std::cout << pline << std::endl;
fline += pline;
}
while (std::string(pline).find("\\") != std::string::npos);
return fline;
}
void
operatorInputArg(const char *enter)
{
if (localProcess->m_oargc != 0) return;
if (enter) printEnter(localProcess->prompt, enter);
std::stringstream stringStream(getInput());
std::string line;
while (std::getline(stringStream, line))
while (true)
{
std::size_t prev = 0, pos;
while ((pos = line.find_first_of(", \\", prev)) != std::string::npos)
if (localProcess->m_oargc != 0) return;
if (enter) printEnter(localProcess->prompt, enter);
std::stringstream stringStream(getInput());
std::string line;
while (std::getline(stringStream, line))
{
if (pos > prev) localProcess->m_oargv.push_back(line.substr(prev, pos - prev));
prev = pos + 1;
std::size_t prev = 0, pos;
while ((pos = line.find_first_of(", \\", prev)) != std::string::npos)
{
if (pos > prev) localProcess->m_oargv.push_back(line.substr(prev, pos - prev));
prev = pos + 1;
}
if (prev < line.length()) localProcess->m_oargv.push_back(line.substr(prev, std::string::npos));
}
if (prev < line.length()) localProcess->m_oargv.push_back(line.substr(prev, std::string::npos));
localProcess->m_oargc = localProcess->m_oargv.size();
}
localProcess->m_oargc = localProcess->m_oargv.size();
}
int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment