Skip to content

Commit

Permalink
Enable modernize-raw-string-literal
Browse files Browse the repository at this point in the history
Enable this check, and update strings as it recommends.

Also manually updated some associated strings where there was a bunch of
string literals together, in order to help keep them aligned.
  • Loading branch information
jbytheway committed Aug 12, 2019
1 parent c3cf67e commit b94a10d
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 50 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ readability-*,\
-modernize-avoid-c-arrays,\
-modernize-deprecated-headers,\
-modernize-pass-by-value,\
-modernize-raw-string-literal,\
-modernize-return-braced-init-list,\
-modernize-use-auto,\
-modernize-use-default-member-init,\
Expand Down
2 changes: 1 addition & 1 deletion src/clothing_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void clothing_mod::load( JsonObject &jo, const std::string & )
} else if( str == "coverage" ) {
mv.coverage_propotion = true;
} else {
jarr_prop.throw_error( "Invalid value, valid are: \"coverage\" and \"thickness\"" );
jarr_prop.throw_error( R"(Invalid value, valid are: "coverage" and "thickness")" );
}
}
mod_values.push_back( mv );
Expand Down
42 changes: 21 additions & 21 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,30 +1047,30 @@ bool game::cleanup_at_end()
vRip.emplace_back( " _.%%%%%%@@@@@@%%%__/\\%@@%%@@@@@@@%%%%%%" );
}
} else {
vRip.emplace_back( " _________ ____ " );
vRip.emplace_back( " _/ `/ \\_ " );
vRip.emplace_back( " _/ _ _ \\_. " );
vRip.emplace_back( " _%\\ |_) | |_) \\_ " );
vRip.emplace_back( " _/ \\/ | \\ | | \\_ " );
vRip.emplace_back( " _/ \\_ " );
vRip.emplace_back( "| |" );
vRip.emplace_back( R"( _________ ____ )" );
vRip.emplace_back( R"( _/ `/ \_ )" );
vRip.emplace_back( R"( _/ _ _ \_. )" );
vRip.emplace_back( R"( _%\ |_) | |_) \_ )" );
vRip.emplace_back( R"( _/ \/ | \ | | \_ )" );
vRip.emplace_back( R"( _/ \_ )" );
vRip.emplace_back( R"(| |)" );
iNameLine = vRip.size();
vRip.emplace_back( " ) < " );
vRip.emplace_back( "| |" );
vRip.emplace_back( "| |" );
vRip.emplace_back( "| _ |" );
vRip.emplace_back( "|__/ |" );
vRip.emplace_back( R"( ) < )" );
vRip.emplace_back( R"(| |)" );
vRip.emplace_back( R"(| |)" );
vRip.emplace_back( R"(| _ |)" );
vRip.emplace_back( R"(|__/ |)" );
iMaxWidth = vRip[vRip.size() - 1].length();
vRip.emplace_back( " / `--. |" );
vRip.emplace_back( "| ( " );
vRip.emplace_back( R"( / `--. |)" );
vRip.emplace_back( R"(| ( )" );
iInfoLine = vRip.size();
vRip.emplace_back( "| |" );
vRip.emplace_back( "| |" );
vRip.emplace_back( "| % . |" );
vRip.emplace_back( "| @` %% |" );
vRip.emplace_back( "| %@%@%\\ * %`%@%|" );
vRip.emplace_back( "%%@@@.%@%\\%% `\\ %%.%%@@%@" );
vRip.emplace_back( "@%@@%%%%%@@@@@@%%%%%%%%@@%%@@@%%%@%%@" );
vRip.emplace_back( R"(| |)" );
vRip.emplace_back( R"(| |)" );
vRip.emplace_back( R"(| % . |)" );
vRip.emplace_back( R"(| @` %% |)" );
vRip.emplace_back( R"(| %@%@%\ * %`%@%|)" );
vRip.emplace_back( R"(%%@@@.%@%\%% `\ %%.%%@@%@)" );
vRip.emplace_back( R"(@%@@%%%%%@@@@@@%%%%%%%%@@%%@@@%%%@%%@)" );
}

const int iOffsetX = TERMX > FULL_SCREEN_WIDTH ? ( TERMX - FULL_SCREEN_WIDTH ) / 2 : 0;
Expand Down
3 changes: 2 additions & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,8 @@ void inscribe_actor::load( JsonObject &obj )
assign( obj, "gerund", gerund );

if( !on_items && !on_terrain ) {
obj.throw_error( "Tried to create an useless inscribe_actor, at least on of \"on_items\" or \"on_terrain\" should be true" );
obj.throw_error(
R"(Tried to create an useless inscribe_actor, at least on of "on_items" or "on_terrain" should be true)" );
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/iuse_software_snake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ void snake_game::snake_over( const catacurses::window &w_snake, int iScore )
mvwputch( w_snake, body_length + 2, 71, c_green, 'v' );

std::vector<std::string> game_over_text;
game_over_text.push_back( " ________ _____ _____ ___________ " );
game_over_text.push_back( " / _____/ / _ \\ / \\ \\_ _____/ " );
game_over_text.push_back( "/ \\ ___ / /_\\ \\ / \\ / \\ | __)_ " );
game_over_text.push_back( "\\ \\_\\ \\/ | \\/ Y \\ | \\" );
game_over_text.push_back( " \\______ /\\____|__ /\\____|__ //_______ / " );
game_over_text.push_back( " \\/ \\/ \\/ \\/ " );
game_over_text.push_back( " ________ ____ _________________________ " );
game_over_text.push_back( " \\_____ \\\\ \\ / /\\_ _____/\\______ \\ " );
game_over_text.push_back( " / | \\\\ Y / | __)_ | _/ " );
game_over_text.push_back( " / | \\\\ / | \\ | | \\ " );
game_over_text.push_back( " \\_______ / \\___/ /_______ / |____|_ / " );
game_over_text.push_back( " \\/ \\/ \\/ " );
game_over_text.push_back( R"( ________ _____ _____ ___________)" );
game_over_text.push_back( R"( / _____/ / _ \ / \ \_ _____/)" );
game_over_text.push_back( R"(/ \ ___ / /_\ \ / \ / \ | __)_ )" );
game_over_text.push_back( R"(\ \_\ \/ | \/ Y \ | \)" );
game_over_text.push_back( R"( \______ /\____|__ /\____|__ //_______ /)" );
game_over_text.push_back( R"( \/ \/ \/ \/ )" );
game_over_text.push_back( R"( ________ ____ _________________________ )" );
game_over_text.push_back( R"( \_____ \\ \ / /\_ _____/\______ \ )" );
game_over_text.push_back( R"( / | \\ Y / | __)_ | _/ )" );
game_over_text.push_back( R"( / | \\ / | \ | | \ )" );
game_over_text.push_back( R"( \_______ / \___/ /_______ / |____|_ / )" );
game_over_text.push_back( R"( \/ \/ \/ )" );

for( size_t i = 0; i < game_over_text.size(); i++ ) {
mvwprintz( w_snake, i + 3, 17, c_light_red, game_over_text[i] );
Expand Down
10 changes: 5 additions & 5 deletions src/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ void JsonIn::skip_true()
stream->get( text, 5 );
if( strcmp( text, "true" ) != 0 ) {
std::stringstream err;
err << "expected \"true\", but found \"" << text << "\"";
err << R"(expected "true", but found ")" << text << "\"";
error( err.str(), -4 );
}
end_value();
Expand All @@ -868,7 +868,7 @@ void JsonIn::skip_false()
stream->get( text, 6 );
if( strcmp( text, "false" ) != 0 ) {
std::stringstream err;
err << "expected \"false\", but found \"" << text << "\"";
err << R"(expected "false", but found ")" << text << "\"";
error( err.str(), -5 );
}
end_value();
Expand All @@ -881,7 +881,7 @@ void JsonIn::skip_null()
stream->get( text, 5 );
if( strcmp( text, "null" ) != 0 ) {
std::stringstream err;
err << "expected \"null\", but found \"" << text << "\"";
err << R"(expected "null", but found ")" << text << "\"";
error( err.str(), -4 );
}
end_value();
Expand Down Expand Up @@ -1080,7 +1080,7 @@ bool JsonIn::get_bool()
end_value();
return true;
} else {
err << "not a boolean. expected \"true\", but got \"";
err << R"(not a boolean. expected "true", but got ")";
err << ch << text << "\"";
error( err.str(), -4 );
}
Expand All @@ -1090,7 +1090,7 @@ bool JsonIn::get_bool()
end_value();
return false;
} else {
err << "not a boolean. expected \"false\", but got \"";
err << R"(not a boolean. expected "false", but got ")";
err << ch << text << "\"";
error( err.str(), -5 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void map_data_common_t::load_symbol( JsonObject &jo )
} else if( has_bgcolor ) {
load_season_array( jo, "bgcolor", color_, bgcolor_from_string );
} else {
jo.throw_error( "Missing member: one of: \"color\", \"bgcolor\" must exist." );
jo.throw_error( R"(Missing member: one of: "color", "bgcolor" must exist.)" );
}
}

Expand Down Expand Up @@ -1118,7 +1118,7 @@ void map_data_common_t::load( JsonObject &jo, const std::string &src )
} else if( harvest_jo.has_string( "id" ) ) {
hl = harvest_id( harvest_jo.get_string( "id" ) );
} else {
jo.throw_error( "Each harvest entry must specify either \"entries\" or \"id\"",
jo.throw_error( R"(Each harvest entry must specify either "entries" or "id")",
"harvest_by_season" );
}

Expand Down
2 changes: 1 addition & 1 deletion src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ void mapgen_function_json_base::setup_setmap( JsonArray &parray )
} else if( pjo.read( "square", tmpval ) ) {
setmap_optype = JMAPGEN_SETMAP_OPTYPE_SQUARE;
} else {
pjo.throw_error( "invalid data: must contain \"point\", \"set\", \"line\" or \"square\" member" );
pjo.throw_error( R"(invalid data: must contain "point", "set", "line" or "square" member)" );
}

sm_it = setmap_opmap.find( tmpval );
Expand Down
5 changes: 3 additions & 2 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,9 @@ mtype_special_attack MonsterGenerator::create_actor( JsonObject obj, const std::
const std::string attack_type = obj.get_string( "attack_type", type );

if( type != "monster_attack" && attack_type != type ) {
obj.throw_error( "Specifying \"attack_type\" is only allowed when \"type\" is \"monster_attack\" or not specified",
"type" );
obj.throw_error(
R"(Specifying "attack_type" is only allowed when "type" is "monster_attack" or not specified)",
"type" );
}

mattack_actor *new_attack = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,13 @@ static Trait_group &make_group_or_throw( const trait_group::Trait_group_tag &gid
if( is_collection ) {
if( dynamic_cast<Trait_group_distribution *>( found->second.get() ) ) {
std::ostringstream buf;
buf << "item group \"" << gid.c_str() << "\" already defined with type \"distribution\"";
buf << "item group \"" << gid.c_str() << R"(" already defined with type "distribution")";
throw std::runtime_error( buf.str() );
}
} else {
if( dynamic_cast<Trait_group_collection *>( found->second.get() ) ) {
std::ostringstream buf;
buf << "item group \"" << gid.c_str() << "\" already defined with type \"collection\"";
buf << "item group \"" << gid.c_str() << R"(" already defined with type "collection")";
throw std::runtime_error( buf.str() );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/npctalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,7 @@ dynamic_line_t::dynamic_line_t( JsonObject jo )
const std::string line = jo.get_string( "gendered_line" );
if( !jo.has_array( "relevant_genders" ) ) {
jo.throw_error(
"dynamic line with \"gendered_line\" must also have \"relevant_genders\"" );
R"(dynamic line with "gendered_line" must also have "relevant_genders")" );
}
JsonArray ja = jo.get_array( "relevant_genders" );
std::vector<std::string> relevant_genders;
Expand Down
2 changes: 1 addition & 1 deletion src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ void oter_type_t::load( JsonObject &jo, const std::string &src )

if( has_flag( line_drawing ) ) {
if( has_flag( no_rotate ) ) {
jo.throw_error( "Mutually exclusive flags: \"NO_ROTATE\" and \"LINEAR\"." );
jo.throw_error( R"(Mutually exclusive flags: "NO_ROTATE" and "LINEAR".)" );
}

for( const auto &elem : om_lines::mapgen_suffixes ) {
Expand Down

0 comments on commit b94a10d

Please sign in to comment.