diff --git a/config/scripts.cfg b/config/scripts.cfg index 30504a06..b1701043 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -68,7 +68,7 @@ const gibsgore [ // "fullscreenscript" command: // This command allows swapping of fullscreen mode to be bound to a key. const fullscreenscript [ fullscreen (! $fullscreen) ] -const editsvar [ inputcommand $$arg1 (concatword $arg1 " $" cmdbuf) (concatword "edit " $arg1 :) ] +const editsvar [ inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " (at $q 0) ; pop q") (concatword "edit " $arg1 :) ] const editmapmsg [ editsvar mapmsg ] const return [ result $arg1 ] const run [ exec (concatword config/ $arg1 .cfg) ] diff --git a/source/src/command.cpp b/source/src/command.cpp index 3374d8ef..b1188ca8 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -39,7 +39,7 @@ void clearstack(ident &id) void pushident(ident &id, char *val, int context = execcontext) { - if(id.type != ID_ALIAS) return; + if(id.type != ID_ALIAS) { delete[] val; return; } identstack *stack = new identstack; stack->action = id.executing==id.action ? newstring(id.action) : id.action; stack->context = id.context; @@ -1426,16 +1426,17 @@ COMMANDF(rnd, "i", (int *a) { intret(*a>0 ? rnd(*a) : 0); }); #ifndef STANDALONE -const char *escapestring(const char *s, bool force) +const char *escapestring(const char *s, bool force, bool noquotes) { static vector strbuf[3]; static int stridx = 0; + if(noquotes) force = false; if(!s) return force ? "\"\"" : ""; if(!force && !*(s + strcspn(s, "\"/\\;()[] \f\t\r\n"))) return s; stridx = (stridx + 1) % 3; vector &buf = strbuf[stridx]; buf.setsize(0); - buf.add('"'); + if(!noquotes) buf.add('"'); for(; *s; s++) switch(*s) { case '\n': buf.put("\\n", 2); break; @@ -1445,7 +1446,8 @@ const char *escapestring(const char *s, bool force) case '\\': buf.put("\\\\", 2); break; default: buf.add(*s); break; } - buf.put("\"\0", 2); + if(!noquotes) buf.add('"'); + buf.add(0); return buf.getbuf(); } COMMANDF(escape, "s", (const char *s) { result(escapestring(s));}); diff --git a/source/src/console.cpp b/source/src/console.cpp index 2fa7fec5..472aa6be 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -300,7 +300,7 @@ void saycommand(char *init) // turns input to the comman setscope(false); setburst(false); if(!editmode) keyrepeat(saycommandon); - copystring(cmdline.buf, init ? init : ""); + copystring(cmdline.buf, init ? escapestring(init, false, true) : ""); DELETEA(cmdaction); DELETEA(cmdprompt); cmdline.pos = -1; @@ -322,8 +322,7 @@ SVARFF(mapmsg, }, { // set new mapmsg string text; - filterrichtext(text, mapmsg); - filtertext(text, text, FTXT__MAPMSG); + filtertext(text, mapmsg, FTXT__MAPMSG); copystring(hdr.maptitle, text, 128); if(editmode) unsavededits++; }); diff --git a/source/src/protos.h b/source/src/protos.h index a94adfd0..99e51aba 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -847,7 +847,7 @@ extern char *strreplace(char *dest, const char *source, const char *search, cons extern void pushscontext(int newcontext); extern int popscontext(); extern int curscontext(); -extern const char *escapestring(const char *s, bool force = true); +extern const char *escapestring(const char *s, bool force = true, bool noquotes = false); extern int execcontext; extern const char *currentserver(int i); extern void setcontext(const char *context, const char *info);