Commit a22f9683 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

refactored operatorInputArg to contain logic of user input, fixed bug that...

refactored operatorInputArg to contain logic of user input, fixed bug that caused incorrect splits of the user input
parent 1e36fcb4
......@@ -246,64 +246,6 @@ Process::setInactive()
m_isActive = false;
}
void
Process::inqUserInputForOpArg(const char *enter)
{
int oargc = m_oargc;
if (oargc == 0)
{
char line[1024];
char *pline = line;
size_t pos, len, linelen;
int lreadline = 1;
if (enter)
{
set_text_color(stderr, BRIGHT, MAGENTA);
fprintf(stderr, "%-16s : ", prompt);
reset_text_color(stderr);
// set_text_color(stderr, BLINK, BLACK);
fprintf(stderr, "Enter %s > ", enter);
// reset_text_color(stderr);
}
while (lreadline)
{
readline(stdin, pline, 1024);
lreadline = 0;
while (1)
{
pos = 0;
while (pline[pos] == ' ' || pline[pos] == ',') pos++;
pline += pos;
linelen = strlen(pline);
if (linelen > 0)
{
if (pline[0] == '\\')
{
lreadline = 1;
break;
}
len = 0;
while (pline[len] != ' ' && pline[len] != ',' && pline[len] != '\\' && len < linelen) len++;
m_oargv.push_back(pline);
oargc++;
pline += len;
}
else
break;
}
}
m_oargc = oargc;
}
}
int
Process::operatorAdd(const char *name, int f1, int f2, const char *enter)
{
......
......@@ -134,7 +134,6 @@ public:
* Adds and creates a new file pstream to the out streams
*/
void addPipeOutStream();
void inqUserInputForOpArg(const char *enter);
/**
* Adds an operator to the process
*/
......
......@@ -31,6 +31,7 @@
#include "cdo_output.h"
#include "cdo_defaultValues.h"
#include "process.h"
#include "readline.h"
thread_local Process *localProcess;
static int NumProcessActive = 0;
......@@ -122,7 +123,57 @@ operatorCheckArgc(int numargs)
void
operatorInputArg(const char *enter)
{
localProcess->inqUserInputForOpArg(enter);
int oargc = localProcess->m_oargc;
if (oargc == 0)
{
char line[1024];
char *pline = line;
size_t pos, len, linelen;
int lreadline = 1;
if (enter)
{
set_text_color(stderr, BRIGHT, MAGENTA);
fprintf(stderr, "%-16s : ", localProcess->prompt);
reset_text_color(stderr);
fprintf(stderr, "Enter %s > ", enter);
}
while (lreadline)
{
readline(stdin, pline, 1024);
lreadline = 0;
while (1)
{
pos = 0;
while (pline[pos] == ' ' || pline[pos] == ',') pos++;
pline += pos;
linelen = strlen(pline);
if (linelen > 0)
{
if (pline[0] == '\\')
{
lreadline = 1;
break;
}
len = 0;
while (pline[len] != ' ' && pline[len] != ',' && pline[len] != '\\' && len < linelen) len++;
localProcess->m_oargv.push_back(std::string(pline).substr(0,len));
oargc++;
pline += len;
}
else
break;
}
}
localProcess->m_oargc = oargc;
}
}
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