本文整理汇总了C++中pushline函数的典型用法代码示例。如果您正苦于以下问题:C++ pushline函数的具体用法?C++ pushline怎么用?C++ pushline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pushline函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: loadline
/*---------------------------------------------------------------------*/
static int
loadline(lua_State *L)
{
TRACE_LUA_FUNC_START();
int status;
lua_settop(L, 0);
if (!pushline(L, 1)) {
TRACE_LUA_FUNC_END();
return -1; /* no input */
}
for (;;) { /* repeat until gets a complete line */
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
if (!incomplete(L, status)) break; /* cannot try to add lines? */
if (!pushline(L, 0)) {/* no more input? */
TRACE_LUA_FUNC_END();
return -1;
}
lua_pushliteral(L, "\n"); /* add a new line... */
lua_insert(L, -2); /* ...between the two lines */
lua_concat(L, 3); /* join them */
}
TRACE_DEBUG_LOG("%s\n", lua_tostring(L, 1));
TRACE_LUA_FUNC_END();
return status;
}
开发者ID:bro,项目名称:packet-bricks,代码行数:27,代码来源:lua_interpreter.c
示例2: loadline
static int loadline(lua_State *L) {
int status;
lua_settop(L, 0);
if (!pushline(L, 1))
return -1; /* no input */
for (;;) { /* repeat until gets a complete line */
size_t l;
const char *line = lua_tolstring(L, 1, &l);
status = luaL_loadbuffer(L, line, l, "=stdin");
if (!incomplete(L, status))
break; /* cannot try to add lines? */
if (!pushline(L, 0)) /* no more input? */
return -1;
lua_pushliteral(L, "\n"); /* add a new line... */
lua_insert(L, -2); /* ...between the two lines */
lua_concat(L, 3); /* join them */
}
lua_saveline(L, 1);
lua_remove(L, 1); /* remove line */
return status;
}
开发者ID:hemantagr,项目名称:pktgen-dpdk,代码行数:26,代码来源:lua_shell.c
示例3: loadline
static int loadline(lua_State *L)
{
int status;
lua_settop(L, 0);
if(!pushline(L, 1))
{
return -1; /* no input */
}
for(;;) /* repeat until gets a complete line */
{
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
if(!incomplete(L, status))
{
break; /* cannot try to add lines? */
}
if(!pushline(L, 0)) /* no more input? */
{
return -1;
}
lua_pushliteral(L, "\n"); /* add a new line... */
lua_insert(L, -2); /* ...between the two lines */
lua_concat(L, 3); /* join them */
}
lua_remove(L, 1); /* remove line */
return status;
}
开发者ID:AntonioModer,项目名称:Cheetah,代码行数:26,代码来源:main.c
示例4: loadline
static int loadline(lua_State *L)
{
int status;
size_t len;
const char *line;
lua_settop(L, 0);
if (!pushline(L, 1))
return -1; /* no input */
line = lua_tolstring(L, 1, &len);
if (strcmp (line, "exit") == 0)
return -1;
/* try to load the string as an expression */
if (yield_expr(L, 1, line, len) == 0)
return 0;
/* try to load it as a simple Lua chunk */
status = luaL_loadbuffer(L, line, len, "=stdin");
if (incomplete(L, status))
{
for (;;) { /* repeat until gets a complete line */
if (!pushline(L, 0)) /* no more input? */
return -1;
lua_pushliteral(L, "\n"); /* add a new line... */
lua_insert(L, -2); /* ...between the two lines */
lua_concat(L, 3); /* join them */
line = lua_tolstring(L, 1, &len);
status = luaL_loadbuffer(L, line, len, "=stdin");
if (!incomplete(L, status)) break; /* cannot try to add lines? */
}
/* even if previous "load" was successfull we try to load the string as
an expression */
if (yield_expr(L, 1, line, len) == 0)
{
/* remove old eval function */
lua_remove(L, 1);
return 0;
}
}
my_saveline(L, 1);
lua_remove(L, 1); /* remove line */
return status;
}
开发者ID:LuaDist,项目名称:gsl-shell,代码行数:50,代码来源:gsl-shell-jit.c
示例5: tag_for_undo
/* push an unreal line onto the undo stack
* lp should be the new line, _after_ insertion, so
* lforw() and lback() are right
*/
int
tag_for_undo(LINE *lp)
{
int status = FALSE;
LINE *nlp;
TRACE2((T_CALLED "tag_for_undo(%p)\n", lp));
if (needundocleanup)
preundocleanup();
if (liscopied(lp)) {
status = TRUE;
} else if ((nlp = lalloc(LINENOTREAL, curbp)) == 0) {
TRACE(("tag_for_undo: no memory\n"));
status = ABORT;
} else {
set_lforw(nlp, lforw(lp));
set_lback(nlp, lback(lp));
pushline(nlp, BACKSTK(curbp));
lsetcopied(lp);
FORWDOT(curbp).l = lp;
FORWDOT(curbp).o = DOT.o;
status = TRUE;
}
return2Code(status);
}
开发者ID:OS2World,项目名称:APP-EDITOR-Vile,代码行数:33,代码来源:undo.c
示例6: copy_for_undo
/*
* Push a copy of a line onto the undo stack. Push a patch so we can
* later fix up any references to this line that might already be in the
* stack. When the undo happens, the later pops (i.e. those lines still
* in the stack) will point at the _original_ (which will by then be on the
* redo stack) instead of at the copy, which will have just been popped,
* unless we fix them by popping and using the patch.
*/
int
copy_for_undo(LINE *lp)
{
int status = FALSE;
LINE *nlp;
TRACE2((T_CALLED "copy_for_undo(%p)\n", lp));
if (needundocleanup)
preundocleanup();
if (liscopied(lp)) {
status = TRUE;
} else if ((nlp = copyline(lp)) == 0) {
status = ABORT;
} else {
/* take care of the normal undo stack */
pushline(nlp, BACKSTK(curbp));
make_undo_patch(lp, nlp);
lsetcopied(lp);
setupuline(lp);
FORWDOT(curbp).l = lp;
FORWDOT(curbp).o = DOT.o;
status = TRUE;
}
return2Code(status);
}
开发者ID:OS2World,项目名称:APP-EDITOR-Vile,代码行数:39,代码来源:undo.c
示例7: popline
bool PositionData::next()
{
if (eof() || linesRead > totalLines - skip) return false;
popline();
pushline();
return true;
}
开发者ID:Sriep,项目名称:pipewrap,代码行数:7,代码来源:positiondata.cpp
示例8: loadline
static int loadline (lua_State *L) {
int status;
lua_settop(L, 0);
if (!pushline(L, 1))
return -1;
for (;;) {
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
if (!incomplete(L, status)) break;
if (!pushline(L, 0))
return -1;
lua_pushliteral(L, "\n");
lua_insert(L, -2);
lua_concat(L, 3);
}
lua_saveline(L, 1);
lua_remove(L, 1);
return status;
}
开发者ID:ColinGilbert,项目名称:accidental-noise-library,代码行数:18,代码来源:main.cpp
示例9: loadline
/*
** Read a line and try to load (compile) it first as an expression (by
** adding "return " in front of it) and second as a statement. Return
** the final status of load/call with the resulting function (if any)
** in the top of the stack.
*/
static int loadline (lua_State *L) {
int status;
lua_settop(L, 0);
if (!pushline(L, 1))
return -1; /* no input */
if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */
status = multiline(L); /* try as command, maybe with continuation lines */
lua_remove(L, 1); /* remove line from the stack */
lua_assert(lua_gettop(L) == 1);
return status;
}
开发者ID:Fabio3rs,项目名称:Guitar-PlusPlus,代码行数:17,代码来源:lua.c
示例10: multiline
/*
** Read multiple lines until a complete Lua statement
*/
static int multiline (lua_State *L) {
for (;;) { /* repeat until gets a complete statement */
size_t len;
const char *line = lua_tolstring(L, 1, &len); /* get what it has */
int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */
if (!incomplete(L, status) || !pushline(L, 0))
return status; /* cannot or should not try to add continuation line */
lua_pushliteral(L, "\n"); /* add newline... */
lua_insert(L, -2); /* ...between the two lines */
lua_concat(L, 3); /* join them */
}
}
开发者ID:KallistiOS,项目名称:KallistiOS,代码行数:15,代码来源:lua.c
示例11: getLineCount
void PositionData::init()
{
string inDataFile = Options::get(Options::VariantData);
totalLines = getLineCount(inDataFile);
ignore(2560,'\n');
linesRead++;
//uint skip = atoi(inDataFile.c_str());
if (skip > 0)
{
if (totalLines < 2*skip + 2*windowSize +1) return;
for (uint i = 0 ; i < skip ; i++ )
{
ignore(2560,'\n');
linesRead++;
}
}
for (uint i = 0 ; i < 2*windowSize+1 ; i++ )
{
pushline();
}
}
开发者ID:Sriep,项目名称:pipewrap,代码行数:23,代码来源:positiondata.cpp
示例12: toss_to_undo
/* push a deleted line onto the undo stack. */
void
toss_to_undo(LINE *lp)
{
LINE *next;
LINE *prev;
int fc;
TRACE2((T_CALLED "toss_to_undo(%p)\n", lp));
if (needundocleanup)
preundocleanup();
pushline(lp, BACKSTK(curbp));
next = lforw(lp);
/* need to save a dot -- either the next line or
the previous one */
if (next == buf_head(curbp)) {
prev = lback(lp);
FORWDOT(curbp).l = prev;
fc = firstchar(prev);
if (fc < 0) /* all white */
FORWDOT(curbp).o = llength(prev) - 1;
else
FORWDOT(curbp).o = fc;
} else {
FORWDOT(curbp).l = next;
fc = firstchar(next);
if (fc < 0) /* all white */
FORWDOT(curbp).o = b_left_margin(curbp);
else
FORWDOT(curbp).o = fc;
}
dumpuline(lp);
return2Void();
}
开发者ID:OS2World,项目名称:APP-EDITOR-Vile,代码行数:38,代码来源:undo.c
示例13: pushlineoredit
void
pushlineoredit(void)
{
int ics;
unsigned char *s;
char *hline = hgetline();
if (zmult < 0)
return;
if (hline && *hline) {
ics = ztrlen(hline);
sizeline(ics + ll + 1);
for (s = line + ll; --s >= line; *(s + ics) = *s);
for (s = line; *hline; hline++)
*s++ = *hline == Meta ? *++hline ^ 32 : *hline;
ll += ics;
cs += ics;
}
pushline();
if (!isfirstln) {
errflag = done = 1;
}
clearlist = 1;
}
开发者ID:prabirshrestha,项目名称:winzsh,代码行数:24,代码来源:zle_hist.c
示例14: if
/**
* Parse key/value pairs from the configuration file
*/
void config::parse_file() {
vector<pair<int, string>> lines;
vector<string> files{m_file};
std::function<void(int, string&&)> pushline = [&](int lineno, string&& line) {
// Ignore empty lines and comments
if (line.empty() || line[0] == ';' || line[0] == '#') {
return;
}
string key, value;
string::size_type pos;
// Filter lines by:
// - key/value pairs
// - section headers
if ((pos = line.find('=')) != string::npos) {
key = forward<string>(string_util::trim(forward<string>(line.substr(0, pos))));
value = forward<string>(string_util::trim(line.substr(pos + 1)));
} else if (line[0] != '[' || line[line.length() - 1] != ']') {
return;
}
if (key == "include-file") {
auto file_path = file_util::expand(value);
if (file_path.empty() || !file_util::exists(file_path)) {
throw value_error("Invalid include file \"" + file_path + "\" defined on line " + to_string(lineno));
}
if (std::find(files.begin(), files.end(), file_path) != files.end()) {
throw value_error("Recursive include file \"" + file_path + "\"");
}
files.push_back(file_util::expand(file_path));
m_log.trace("config: Including file \"%s\"", file_path);
for (auto&& l : string_util::split(file_util::contents(file_path), '\n')) {
pushline(lineno, forward<string>(l));
}
files.pop_back();
} else {
lines.emplace_back(make_pair(lineno, line));
}
};
int lineno{0};
string line;
std::ifstream in(m_file);
while (std::getline(in, line)) {
pushline(++lineno, string_util::replace_all(line, "\t", ""));
}
string section;
for (auto&& l : lines) {
auto& lineno = l.first;
auto& line = l.second;
// New section
if (line[0] == '[' && line[line.length() - 1] == ']') {
section = line.substr(1, line.length() - 2);
continue;
} else if (section.empty()) {
continue;
}
size_t equal_pos;
// Check for key-value pair equal sign
if ((equal_pos = line.find('=')) == string::npos) {
continue;
}
string key{forward<string>(string_util::trim(forward<string>(line.substr(0, equal_pos))))};
string value;
auto it = m_sections[section].find(key);
if (it != m_sections[section].end()) {
throw key_error("Duplicate key name \"" + key + "\" defined on line " + to_string(lineno));
}
if (equal_pos + 1 < line.size()) {
value = forward<string>(string_util::trim(line.substr(equal_pos + 1)));
size_t len{value.size()};
if (len > 2 && value[0] == '"' && value[len - 1] == '"') {
value.erase(len - 1, 1).erase(0, 1);
}
}
#if WITH_XRM
// Initialize the xresource manage if there are any xrdb refs
// present in the configuration
if (!m_xrm && value.find("${xrdb") != string::npos) {
m_xrm.reset(new xresource_manager{connection::make()});
}
#endif
m_sections[section].emplace_hint(it, move(key), move(value));
}
}
开发者ID:JBouron,项目名称:polybar,代码行数:99,代码来源:config.cpp
注:本文中的pushline函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论