From d87a0d8f27a979ad1264b3848cc1a2cad0be91c3 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sat, 28 Feb 2009 01:23:00 -0500 Subject: [PATCH] Allow c-style escapes with parameters. With this change, it's possible to use '\n' to represent a new line, instead of '\012' This will be particularly useful for the 'stuff' command. Fixes #25647. --- src/process.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/process.c b/src/process.c index b5474e7..8fd2fa7 100644 --- a/src/process.c +++ b/src/process.c @@ -4484,7 +4484,7 @@ int bufl, *argl; { if (*p == delim) delim = 0; - else if (delim != '\'' && *p == '\\' && (p[1] == '\'' || p[1] == '"' || p[1] == '\\' || p[1] == '$' || p[1] == '#' || p[1] == '^' || (p[1] >= '0' && p[1] <= '7'))) + else if (delim != '\'' && *p == '\\' && (p[1] == 'n' || p[1] == 'r' || p[1] == 't' || p[1] == '\'' || p[1] == '"' || p[1] == '\\' || p[1] == '$' || p[1] == '#' || p[1] == '^' || (p[1] >= '0' && p[1] <= '7'))) { p++; if (*p >= '0' && *p <= '7') @@ -4503,7 +4503,16 @@ int bufl, *argl; pp++; } else - *pp++ = *p; + { + switch (*p) + { + case 'n': *pp = '\n'; break; + case 'r': *pp = '\r'; break; + case 't': *pp = '\t'; break; + default: *pp = *p; break; + } + pp++; + } } else if (delim != '\'' && *p == '$' && (p[1] == '{' || p[1] == ':' || (p[1] >= 'a' && p[1] <= 'z') || (p[1] >= 'A' && p[1] <= 'Z') || (p[1] >= '0' && p[1] <= '9') || p[1] == '_')) -- 2.11.4.GIT