aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-06-04 21:01:53 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-06-04 21:01:53 +0200
commit16e9b0dc459f3ac198495127498b2255eb94c1ce (patch)
tree6630ede1ece5782d0d72cffdc466df87386be67e /src/parser.cpp
parentdd408c9ae23d37d53e0ca7d3d75e33fdae2efdcb (diff)
downloadsciteco-16e9b0dc459f3ac198495127498b2255eb94c1ce.tar.gz
added ^E@ string building character
* allows expansion of Q-Register contents with UNIX shell quoting * This especially improves the usefulness of the EC/EG commands as we can reliably determine that a TECO string (ie. Q-Register) will end up as a single argument to the spawned process. A previous workaround was to enclose ^EQ in quotes, but it does not work e.g. if the register contains the wrong kind of quotes or other magic shell characters. * NOTE: In order to be absolutely sure about the runtime behaviour of EC plus ^E@, you will have to enable UNIX98 shell emulation in portable macros.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index f05f167..941db49 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -388,6 +388,7 @@ bool
StringBuildingMachine::input(gchar chr, gchar *&result)
{
QRegister *reg;
+ gchar *str;
switch (mode) {
case MODE_UPPER:
@@ -450,13 +451,17 @@ StateCtlE:
undo.push_obj(qregspec_machine) = new QRegSpecMachine;
set(&&StateCtlENum);
break;
+ case 'U':
+ undo.push_obj(qregspec_machine) = new QRegSpecMachine;
+ set(&&StateCtlEU);
+ break;
case 'Q':
undo.push_obj(qregspec_machine) = new QRegSpecMachine;
set(&&StateCtlEQ);
break;
- case 'U':
+ case '@':
undo.push_obj(qregspec_machine) = new QRegSpecMachine;
- set(&&StateCtlEU);
+ set(&&StateCtlEQuote);
break;
default:
result = (gchar *)g_malloc(3);
@@ -497,6 +502,17 @@ StateCtlEQ:
result = reg->get_string();
return true;
+StateCtlEQuote:
+ if (!qregspec_machine->input(chr, reg))
+ return false;
+
+ undo.push_obj(qregspec_machine) = NULL;
+ set(StateStart);
+ str = reg->get_string();
+ result = g_shell_quote(str);
+ g_free(str);
+ return true;
+
StateEscaped:
set(StateStart);
result = String::chrdup(chr);