Skip to content

Commit 4cba246

Browse files
committed
Revert "handle single quotes and quotes within quotes (partially)"
This reverts commit 5df8894.
1 parent d936d87 commit 4cba246

File tree

2 files changed

+8
-63
lines changed

2 files changed

+8
-63
lines changed

echeck.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ static int compact = 0;
167167
#define SPACE ' '
168168
#define ESCAPE_CHAR '\\'
169169
#define COMMENT_CHAR ';'
170-
#define SINGLE_QUOTE '\''
171-
#define DOUBLE_QUOTE '"'
172170
#define MARGIN 78
173171
#define RECRUIT_COST 50
174172

@@ -2116,7 +2114,7 @@ char *getbuf(void)
21162114
{
21172115
char lbuf[MAXLINE];
21182116
bool cont = false;
2119-
char quote = 0;
2117+
bool quote = false;
21202118
bool report = false;
21212119
char *cp = warn_buf;
21222120

@@ -2166,27 +2164,16 @@ char *getbuf(void)
21662164
&& c > 0 && isspace(c));
21672165
}
21682166
} else {
2169-
if ((!quote || quote == *bp) && (*bp == DOUBLE_QUOTE || *bp == SINGLE_QUOTE)) {
2170-
if (!cont && !quote) {
2171-
quote = *bp;
2172-
eatwhite = true;
2173-
} else if (!cont && quote == *bp) {
2174-
quote = 0;
2175-
while(cp >= warn_buf && (*(cp-1) == SPACE_REPLACEMENT)) {
2176-
--cp;
2177-
}
2178-
eatwhite = true;
2179-
} else {
2180-
*(cp++) = *bp;
2181-
}
2182-
cont = false;
2167+
cont = false;
2168+
if (c == '"') {
2169+
quote = (bool) ! quote;
2170+
eatwhite = true;
21832171
} else {
2184-
if (*bp == '\\') {
2172+
if (c == '\\')
21852173
cont = true;
2186-
} else if (!iscntrl(*bp)) {
2187-
*(cp++) = *bp;
2174+
else if (c < 0 || !iscntrl(c)) {
2175+
*(cp++) = c;
21882176
eatwhite = (bool) ! quote;
2189-
cont = false;
21902177
}
21912178
}
21922179
++bp;

tests.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,6 @@ static void test_igetstr(CuTest * tc)
115115
CuAssertStrEquals(tc, "derp", igetstr(0));
116116
}
117117

118-
static void test_cont(CuTest *tc)
119-
{
120-
mock_input("a line\\\n continued\n");
121-
CuAssertStrEquals(tc, "a linecontinued", getbuf());
122-
mock_input("a line \\\ncontinued\n");
123-
CuAssertStrEquals(tc, "a line continued", getbuf());
124-
mock_input("a \"string \\\ncontinued\"\n");
125-
CuAssertStrEquals(tc, "a string~continued", getbuf());
126-
mock_input("a \" \\\nstring continued \"\n");
127-
CuAssertStrEquals(tc, "a string~continued", getbuf());
128-
}
129-
130118
static void test_give_each(CuTest * tc)
131119
{
132120
set_order_unit(newunit(1, 0));
@@ -224,33 +212,6 @@ static void test_check_additional_parameters(CuTest *tc)
224212

225213
}
226214

227-
static void test_check_quotes(CuTest *tc)
228-
{
229-
test_orders(tc, "MACHE 1 Rostiges~Kettenhemd", 0, 0);
230-
test_orders(tc, "MACHE 2 \" Rostiges Kettenhemd \"", 0, 0);
231-
test_orders(tc, "MACHE 3 'Rostiges Kettenhemd'", 0, 0);
232-
test_orders(tc, "MACHE 4 \"Rostiges Kettenhemd'", 0, 2);
233-
test_orders(tc, "MACHE 5 'Rostiges Kettenhemd\"", 0, 2);
234-
test_orders(tc, "MACHE 6 \"Rostiges~Kettenhemd\"", 0, 0);
235-
236-
test_orders(tc, "DEFAULT \"ARBEITE\"", 0, 0);
237-
test_orders(tc, "DEFAULT 'ARBEITE'", 0, 0);
238-
test_orders(tc, "DEFAULT ARBEITE", 0, 0);
239-
240-
test_orders(tc, "DEFAULT 'MACHE 1 Schwert'", 0, 0);
241-
test_orders(tc, "DEFAULT \"MACHE 2 Schwert\"", 0, 0);
242-
// currently not working
243-
// test_orders(tc, "DEFAULT \"MACHE 3 'Rostiges Kettenhemd'\"", 0);
244-
// test_orders(tc, "DEFAULT \"MACHE 4 Rostiges~Kettenhemd\"", 0);
245-
// test_orders(tc, "DEFAULT \"MACHE 5 'Rostiges~Kettenhemd'\"", 0);
246-
// test_orders(tc, "DEFAULT 'MACHE 6 \"Rostiges Kettenhemd\"', 0);
247-
248-
test_orders(tc, "BENENNE EINHEIT \"a \\\"nice\\\" name\"", 0, 0);
249-
test_orders(tc, "BENENNE EINHEIT 'parser\\'s nightmare'", 0, 0);
250-
test_orders(tc, "BENENNE EINHEIT \"parser\\'s nightmare\"", 0, 0);
251-
test_orders(tc, "BENENNE EINHEIT \"parser\\\"s nightmare\"", 0, 0);
252-
}
253-
254215
static void test_plant(CuTest *tc)
255216
{
256217
test_orders(tc, "PFLANZE KRÄUTER", 0, 0);
@@ -318,7 +279,6 @@ int AddTestSuites(CuSuite * suite, const char * args)
318279
cs = CuSuiteNew();
319280
SUITE_ADD_TEST(cs, test_getbuf);
320281
SUITE_ADD_TEST(cs, test_igetstr);
321-
SUITE_ADD_TEST(cs, test_cont);
322282
SUITE_ADD_TEST(cs, test_nothing);
323283
CuSuiteAddSuite(suite, cs);
324284
}
@@ -363,8 +323,6 @@ int AddTestSuites(CuSuite * suite, const char * args)
363323
cs = CuSuiteNew();
364324
SUITE_ADD_TEST(cs, test_check_additional_parameters);
365325
SUITE_ADD_TEST(cs, test_origin);
366-
SUITE_ADD_TEST(cs, test_check_quotes);
367-
SUITE_ADD_TEST(cs, test_language);
368326
CuSuiteAddSuite(suite, cs);
369327
}
370328
name = strtok(0, ",");

0 commit comments

Comments
 (0)