besides more code reuse, fix $'…' everywhere (but keep it ignored in here document bodies that aren’t here strings)

This commit is contained in:
tg
2013-01-19 19:47:13 +00:00
parent e307cb34c4
commit 9111faeeb5
4 changed files with 45 additions and 24 deletions

10
lex.c
View File

@@ -2,7 +2,7 @@
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012
* 2011, 2012, 2013
* Thorsten Glaser <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.177 2013/01/19 18:32:56 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.178 2013/01/19 19:47:11 tg Exp $");
/*
* states while lexing word
@@ -359,7 +359,7 @@ yylex(int cf)
c = getsc();
switch (c) {
case '"':
if ((cf & HEREDOC))
if ((cf & (HEREDOCBODY | HERESTRBODY)))
goto heredocquote;
/* FALLTHROUGH */
case '\\':
@@ -504,13 +504,13 @@ yylex(int cf)
*wp++ = '\0';
*wp++ = CSUBST;
*wp++ = 'X';
} else if (c == '\'' && !(cf & HEREDOC)) {
} else if (c == '\'' && !(cf & HEREDOCBODY)) {
*wp++ = OQUOTE;
ignore_backslash_newline++;
PUSH_STATE(SEQUOTE);
statep->ls_bool = false;
break;
} else if (c == '"' && !(cf & HEREDOC)) {
} else if (c == '"' && !(cf & HEREDOCBODY)) {
goto DEQUOTE;
} else {
*wp++ = CHAR;