Loading parser.cpp +17 −4 Changes for parser.cpp: 17 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -178,6 +178,7 @@ bool Parser::parse_string(const std::string& content, Makefile& mf) { std::string current_line; bool in_recipe = false; bool in_continuation = false; bool line_is_recipe = false; // does the logical line being built start as a recipe (tab-indented)? std::istringstream stream(content); std::string line; Loading @@ -185,18 +186,30 @@ bool Parser::parse_string(const std::string& content, Makefile& mf) { if (!line.empty() && line.back() == '\r') line.pop_back(); if (in_continuation) { // Outside a recipe, GNU make collapses a backslash-newline together // with the surrounding whitespace into a single space, so the // leading indentation of a continuation line is discarded. (Recipe // lines keep their whitespace; the shell collapses it.) if (!line_is_recipe) { size_t p = line.find_first_not_of(" \t"); line = (p == std::string::npos) ? std::string() : line.substr(p); } current_line += line; } else { current_line = line; line_is_recipe = (!line.empty() && line[0] == '\t'); } if (!current_line.empty() && current_line.back() == '\\') { current_line.pop_back(); if (in_recipe) { current_line += '\n'; } else { current_line += ' '; if (!line_is_recipe) { // Drop trailing whitespace before the backslash so the join // produces a single separating space (GNU line-splitting). while (!current_line.empty() && (current_line.back() == ' ' || current_line.back() == '\t')) current_line.pop_back(); } current_line += ' '; in_continuation = true; } else { logical_lines.push_back(current_line); Loading Loading
parser.cpp +17 −4 Changes for parser.cpp: 17 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -178,6 +178,7 @@ bool Parser::parse_string(const std::string& content, Makefile& mf) { std::string current_line; bool in_recipe = false; bool in_continuation = false; bool line_is_recipe = false; // does the logical line being built start as a recipe (tab-indented)? std::istringstream stream(content); std::string line; Loading @@ -185,18 +186,30 @@ bool Parser::parse_string(const std::string& content, Makefile& mf) { if (!line.empty() && line.back() == '\r') line.pop_back(); if (in_continuation) { // Outside a recipe, GNU make collapses a backslash-newline together // with the surrounding whitespace into a single space, so the // leading indentation of a continuation line is discarded. (Recipe // lines keep their whitespace; the shell collapses it.) if (!line_is_recipe) { size_t p = line.find_first_not_of(" \t"); line = (p == std::string::npos) ? std::string() : line.substr(p); } current_line += line; } else { current_line = line; line_is_recipe = (!line.empty() && line[0] == '\t'); } if (!current_line.empty() && current_line.back() == '\\') { current_line.pop_back(); if (in_recipe) { current_line += '\n'; } else { current_line += ' '; if (!line_is_recipe) { // Drop trailing whitespace before the backslash so the join // produces a single separating space (GNU line-splitting). while (!current_line.empty() && (current_line.back() == ' ' || current_line.back() == '\t')) current_line.pop_back(); } current_line += ' '; in_continuation = true; } else { logical_lines.push_back(current_line); Loading