From db1f56c8449d2ea3d158753fe37bac5a750a2566 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 29 Nov 2015 14:18:52 -0800 Subject: 2611 --- html/014literal_string.cc.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'html/014literal_string.cc.html') diff --git a/html/014literal_string.cc.html b/html/014literal_string.cc.html index b137323a..024a0efc 100644 --- a/html/014literal_string.cc.html +++ b/html/014literal_string.cc.html @@ -55,17 +55,17 @@ recipe main [ put(Type_ordinal, "literal-string", 0); :(before "End next_word Special-cases") - if (in.peek() == '[') { - string result = slurp_quoted(in); - skip_whitespace(in); - skip_comment(in); - return result; - } +if (in.peek() == '[') { + string result = slurp_quoted(in); + skip_whitespace(in); + skip_comment(in); + return result; +} :(code) string slurp_quoted(istream& in) { ostringstream out; - assert(!in.eof()); assert(in.peek() == '['); out << static_cast<char>(in.get()); // slurp the '[' + assert(has_data(in)); assert(in.peek() == '['); out << static_cast<char>(in.get()); // slurp the '[' if (is_code_string(in, out)) slurp_quoted_comment_aware(in, out); else @@ -76,7 +76,7 @@ string slurp_quoted(istream& in// A string is a code string if it contains a newline before any non-whitespace // todo: support comments before the newline. But that gets messy. bool is_code_string(istream& in, ostream& out) { - while (!in.eof()) { + while (has_data(in)) { char c = in.get(); if (!isspace(c)) { in.putback(c); @@ -94,7 +94,7 @@ bool is_code_string(istream& in// strings. void slurp_quoted_comment_oblivious(istream& in, ostream& out) { int brace_depth = 1; - while (!in.eof()) { + while (has_data(in)) { char c = in.get(); if (c == '\\') { out << static_cast<char>(in.get()); @@ -105,7 +105,7 @@ void slurp_quoted_comment_oblivious(istream& if (c == ']') --brace_depth; if (brace_depth == 0) break; } - if (in.eof() && brace_depth > 0) { + if (!has_data(in) && brace_depth > 0) { raise_error << "unbalanced '['\n" << end(); out.clear(); } @@ -121,7 +121,7 @@ void slurp_quoted_comment_aware(istream& in} if (c == '#') { out << c; - while (!in.eof() && in.peek() != '\n') out << static_cast<char>(in.get()); + while (has_data(in) && in.peek() != '\n') out << static_cast<char>(in.get()); continue; } if (c == '[') { -- cgit 1.4.1-2-gfad0