CYOptions options;
CYContext context(options);
- CYStatement *statement(driver.program_->statements_);
+ CYStatement *statement(driver.program_->code_);
_assert(statement != NULL);
_assert(statement->next_ == NULL);
- CYExpress *express(dynamic_cast<CYExpress *>(driver.program_->statements_));
+ CYExpress *express(dynamic_cast<CYExpress *>(driver.program_->code_));
_assert(express != NULL);
- return express->expression_;
+ CYParenthetical *parenthetical(dynamic_cast<CYParenthetical *>(express->expression_));
+ _assert(parenthetical != NULL);
+
+ return parenthetical->expression_;
}
static int client_;
driver.program_->Replace(context);
- std::ostringstream str;
+ std::stringbuf str;
CYOutput out(str, options);
out << *driver.program_;
}
void operator +=(const std::string &command) {
- add_history(command_.c_str());
+ add_history(command.c_str());
++histlines_;
}
};
}
command_ += line;
+ command_ += "\n";
char *begin(line), *end(line + strlen(line));
while (char *nl = reinterpret_cast<char *>(memchr(begin, '\n', end - begin))) {
if (parser.parse() != 0 || !driver.errors_.empty()) {
for (CYDriver::Errors::const_iterator error(driver.errors_.begin()); error != driver.errors_.end(); ++error) {
CYPosition begin(error->location_.begin);
- if (begin.line != lines.size() || begin.column < lines.back().size() || error->warning_) {
+ if (begin.line != lines.size() + 1 || error->warning_) {
CYPosition end(error->location_.end);
if (begin.line != lines.size()) {
std::cerr << " | ";
std::cerr << error->message_ << std::endl;
- history += command_;
+ history += command_.substr(0, command_.size() - 1);
goto restart;
}
}
driver.errors_.clear();
- command_ += '\n';
prompt = "cy> ";
goto read;
}
if (driver.program_ == NULL)
goto restart;
- std::ostringstream str;
+ std::stringbuf str;
CYOutput out(str, options);
Setup(out, driver, options, lower);
out << *driver.program_;
code = str.str();
}
- history += command_;
+ history += command_.substr(0, command_.size() - 1);
if (debug) {
std::cout << "cy= ";
}
}
-void InjectLibrary(pid_t, int, const char *[]);
+void InjectLibrary(pid_t, int, const char *const []);
int Main(int argc, char * const argv[], char const * const envp[]) {
bool tty(isatty(STDIN_FILENO));
// XXX: arg needs to be escaped in some horrendous way of doom
// XXX: this is a memory leak now because I just don't care enough
char *command;
- asprintf(&command, "ps axc|sed -e '/^ *[0-9]/{s/^ *\\([0-9]*\\)\\( *[^ ]*\\)\\{3\\} *-*\\([^ ]*\\)/\\3 \\1/;/^%s /{s/^[^ ]* //;q;};};d'", optarg);
+ int writ(asprintf(&command, "ps axc|sed -e '/^ *[0-9]/{s/^ *\\([0-9]*\\)\\( *[^ ]*\\)\\{3\\} *-*\\([^ ]*\\)/\\3 \\1/;/^%s /{s/^[^ ]* //;q;};};d'", optarg));
+ _assert(writ != -1);
if (FILE *pids = popen(command, "r")) {
char value[32];
_syscall(chmod(address.sun_path, 0777));
_syscall(listen(server, 1));
- InjectLibrary(pid, 1, (const char *[]) {address.sun_path, NULL});
+ const char *const argv[] = {address.sun_path, NULL};
+ InjectLibrary(pid, 1, argv);
client_ = _syscall(accept(server, NULL, NULL));
}
#else
for (CYDriver::Errors::const_iterator i(driver.errors_.begin()); i != driver.errors_.end(); ++i)
std::cerr << i->location_.begin << ": " << i->message_ << std::endl;
} else if (driver.program_ != NULL) {
- std::ostringstream str;
+ std::stringbuf str;
CYOutput out(str, options);
Setup(out, driver, options, true);
out << *driver.program_;