Commit 832bd569 authored by Murray Cumming's avatar Murray Cumming
Browse files

Fixes for krazy2 warnings: Char literals instead of single-char string literals.

parent d2f2b737
......@@ -859,7 +859,7 @@ void App_Glom::new_instance(const Glib::ustring& uri) //Override
{
Glib::ustring command = "glom";
if(!uri.empty())
command += " " + uri;
command += ' ' + uri;
GError* gerror = 0;
gdk_spawn_command_line_on_screen(Glib::unwrap(get_screen()),
......
......@@ -475,7 +475,7 @@ void App_WithDoc::after_successful_save()
Glib::ustring App_WithDoc::get_conf_fullkey(const Glib::ustring& key)
{
return "/apps/" + m_strAppName + "/" + key;
return "/apps/" + m_strAppName + '/' + key;
}
......
......@@ -759,7 +759,7 @@ void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet
//if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
//{
if(!row_string.empty())
row_string += ",";
row_string += ',';
//Output data in canonical SQL format, ignoring the user's locale, and ignoring the layout formatting:
row_string += layout_item->get_full_field_details()->to_file_format(value);
......
......@@ -52,7 +52,7 @@ Glib::ustring encoding_display(const Glib::ustring& name, const Glib::ustring& c
if(charset.empty())
return name;
else
return name + " (" + charset + ")";
return name + " (" + charset + ')';
}
} //anonymous namespace
......
......@@ -476,7 +476,7 @@ bool ConnectionPool::handle_error_cerr_only()
if(event && (event->get_event_type() == Gnome::Gda::CONNECTION_EVENT_ERROR))
{
if(!error_details.empty())
error_details += "\n"; //Add newline after each error.
error_details += '\n'; //Add newline after each error.
error_details += (*iter)->get_description();
std::cerr << "Internal error (Database): " << error_details << std::endl;
......
......@@ -217,9 +217,9 @@ bool Postgres::change_columns(const Glib::RefPtr<Gnome::Gda::Connection>& connec
"WHEN " + field_name_old_quoted + " IS NULL THEN false END)";
}
else if(old_field_type == Field::TYPE_TEXT)
conversion_command = "(" + field_name_old_quoted + " !~~* \'false\')"; // !~~* means ! ILIKE
conversion_command = '(' + field_name_old_quoted + " !~~* \'false\')"; // !~~* means ! ILIKE
else // Dates and Times:
conversion_command = "(" + field_name_old_quoted + " IS NOT NULL)";
conversion_command = '(' + field_name_old_quoted + " IS NOT NULL)";
break;
}
......
......@@ -216,7 +216,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
#endif
if(!trans_fields.empty())
trans_fields += ",";
trans_fields += ',';
const type_mapFieldChanges::const_iterator changed_iter = fields_changed.find(column->column_name);
if(changed_iter != fields_changed.end())
......@@ -242,7 +242,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
"WHEN " + column->column_name + " != 0 THEN 1 "
"WHEN " + column->column_name + " IS NULL THEN 0 END)";
else if(column->gtype == GDA_TYPE_BLOB || column->gtype == G_TYPE_DATE || column->gtype == GDA_TYPE_TIME)
trans_fields += "0";
trans_fields += '0';
else
trans_fields += Glib::ustring("CAST(") + column->column_name + " AS real)";
break;
......@@ -264,13 +264,13 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
if(column->gtype == G_TYPE_BOOLEAN || column->gtype == GDA_TYPE_BLOB || column->gtype == G_TYPE_DOUBLE)
trans_fields += "NULL";
else
trans_fields += Glib::ustring("date(") + column->column_name + ")";
trans_fields += Glib::ustring("date(") + column->column_name + ')';
break;
case Field::TYPE_TIME:
if(column->gtype == G_TYPE_BOOLEAN || column->gtype == GDA_TYPE_BLOB || column->gtype == G_TYPE_DOUBLE)
trans_fields += "NULL";
else
trans_fields += Glib::ustring("time(") + column->column_name + ")";
trans_fields += Glib::ustring("time(") + column->column_name + ')';
break;
case Field::TYPE_IMAGE:
if(column->gtype == GDA_TYPE_BLOB)
......@@ -305,7 +305,7 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
if(!add_column_to_server_operation(operation, field, i++, error))
return false;
if(!trans_fields.empty())
trans_fields += ",";
trans_fields += ',';
Gnome::Gda::Value default_value = field->get_default_value();
if(default_value.get_value_type() != G_TYPE_NONE && !default_value.is_null())
trans_fields += field->sql(default_value, connection);
......@@ -314,10 +314,10 @@ bool Sqlite::recreate_table(const Glib::RefPtr<Gnome::Gda::Connection>& connecti
switch(field->get_glom_type())
{
case Field::TYPE_NUMERIC:
trans_fields += "0";
trans_fields += '0';
break;
case Field::TYPE_BOOLEAN:
trans_fields += "0";
trans_fields += '0';
break;
case Field::TYPE_TEXT:
trans_fields += "''";
......
......@@ -125,7 +125,7 @@ Glib::ustring LayoutItem_FieldSummary::get_layout_display_name() const
if(m_summary_type == TYPE_INVALID)
result = _("No summary chosen");
else
result = get_summary_type_name(m_summary_type) + "(" + result + ")";
result = get_summary_type_name(m_summary_type) + '(' + result + ')';
return result;
}
......
......@@ -135,7 +135,7 @@ Glib::ustring LayoutItem_GroupBy::get_layout_display_name() const
sort_fields_names += iter->first->get_layout_display_name();
}
result += sort_fields_names + ")";
result += sort_fields_names + ')';
}
return result;
......
......@@ -211,7 +211,7 @@ Glib::ustring UsesRelationship::get_sql_join_alias_name() const
if(get_has_related_relationship_name() && m_related_relationship->get_has_fields())
{
result += ("_" + m_related_relationship->get_name());
result += ('_' + m_related_relationship->get_name());
}
}
......
......@@ -211,7 +211,7 @@ Glib::ustring TranslatableItem::get_current_locale()
m_current_locale = Utils::locale_simplify(cLocale);
}
else
m_current_locale = "C";
m_current_locale = 'C';
}
return m_current_locale;
......
......@@ -54,7 +54,7 @@ Glib::ustring Document::get_file_uri_with_extension(const Glib::ustring& uri)
if(!m_file_extension.empty()) //If there is an extension to enforce.
{
bool bAddExt = false;
Glib::ustring strExt = "." + get_file_extension();
const Glib::ustring strExt = '.' + get_file_extension();
if(result.size() < strExt.size()) //It can't have the ext already if it's not long enough.
{
......@@ -62,7 +62,7 @@ Glib::ustring Document::get_file_uri_with_extension(const Glib::ustring& uri)
}
else
{
Glib::ustring strEnd = result.substr(result.size() - strExt.size());
const Glib::ustring strEnd = result.substr(result.size() - strExt.size());
if(strEnd != strExt) //If it doesn't already have the extension
bAddExt = true;
}
......@@ -353,11 +353,11 @@ Glib::ustring Document::util_file_uri_get_name(const Glib::ustring& file_uri, co
//TODO: Maybe filename_display_basename() should do this.
if(!strResult.empty() && !file_extension.empty())
{
const Glib::ustring strExt = "." + file_extension;
const Glib::ustring strExt = '.' + file_extension;
if(strResult.size() >= file_extension.size()) //It can't have the ext already if it's not long enough.
{
Glib::ustring strEnd = strResult.substr(strResult.size() - strExt.size());
const Glib::ustring strEnd = strResult.substr(strResult.size() - strExt.size());
if(strEnd == strExt) //If it has the extension
{
strResult = strResult.substr(0, strResult.size() - strExt.size());
......
......@@ -276,13 +276,13 @@ Glib::ustring Utils::build_sql_select_fields_to_get(const Glib::ustring& table_n
//Add, for instance, "SUM(":
if(is_summary)
one_sql_part += fieldsummary->get_summary_type_sql() + "(";
one_sql_part += fieldsummary->get_summary_type_sql() + '(';
one_sql_part += layout_item->get_sql_name(table_name);
//Close the summary bracket if necessary.
if(is_summary)
one_sql_part += ")";
one_sql_part += ')';
//Append it to the big string of fields:
if(!one_sql_part.empty())
......@@ -335,16 +335,16 @@ Glib::ustring Utils::build_sql_select_with_where_clause(const Glib::ustring& tab
//Build the whole SQL statement:
Glib::ustring result =
"SELECT " + sql_part_fields +
" FROM \"" + table_name + "\"";
" FROM \"" + table_name + '\"';
if(!sql_part_from.empty())
result += ("," + sql_part_from);
result += (',' + sql_part_from);
if(!extra_join.empty())
sql_part_leftouterjoin += (" " + extra_join + " ");
sql_part_leftouterjoin += (' ' + extra_join + ' ');
if(!sql_part_leftouterjoin.empty())
result += (" " + sql_part_leftouterjoin);
result += (' ' + sql_part_leftouterjoin);
//Add the WHERE clause:
......@@ -354,7 +354,7 @@ Glib::ustring Utils::build_sql_select_with_where_clause(const Glib::ustring& tab
//Extra GROUP_BY clause for doubly-related records. This must be before the ORDER BY sort clause:
if(!extra_group_by.empty())
{
result += (" " + extra_group_by + " ");
result += (' ' + extra_group_by + ' ');
}
//Sort clause:
......@@ -402,7 +402,7 @@ Glib::ustring Utils::build_sql_select_with_key(const Glib::ustring& table_name,
if(!Conversions::value_is_empty(key_value)) //If there is a record to show:
{
//TODO: Use a SQL parameter instead of using sql():
const Glib::ustring where_clause = "\"" + table_name + "\".\"" + key_field->get_name() + "\" = " + key_field->sql(key_value);
const Glib::ustring where_clause = '\"' + table_name + "\".\"" + key_field->get_name() + "\" = " + key_field->sql(key_value);
return Utils::build_sql_select_with_where_clause(table_name, fieldsToGet, where_clause);
}
......@@ -430,14 +430,14 @@ Utils::type_list_values_with_second Utils::get_choice_values(const sharedptr<con
}
const bool with_second = !choice_second.empty();
const Glib::ustring sql_second = "\"" + to_table + "\".\"" + choice_second + "\"";
const Glib::ustring sql_second = "\"" + to_table + "\".\"" + choice_second + '\"';
//Get possible values from database, sorted by the first column.
Glib::ustring sql_query = "SELECT \"" + to_table + "\".\"" + choice_field + "\"";
Glib::ustring sql_query = "SELECT \"" + to_table + "\".\"" + choice_field + '\"';
if(with_second)
sql_query += ", " + sql_second;
sql_query += " FROM \"" + choice_relationship->get_to_table() + "\" ORDER BY \"" + to_table + "\".\"" + choice_field + "\"";
sql_query += " FROM \"" + choice_relationship->get_to_table() + "\" ORDER BY \"" + to_table + "\".\"" + choice_field + '\"';
//std::cout << "debug: get_choice_values(): query: " << sql_query << std::endl;
//Connect to database:
......@@ -522,14 +522,14 @@ Glib::ustring Utils::locale_simplify(const Glib::ustring& locale_id)
Glib::ustring result = locale_id;
//Get everything before the .:
Glib::ustring::size_type posDot = locale_id.find(".");
Glib::ustring::size_type posDot = locale_id.find('.');
if(posDot != Glib::ustring::npos)
{
result = result.substr(0, posDot);
}
//Get everything before the @:
const Glib::ustring::size_type posAt = locale_id.find("@");
const Glib::ustring::size_type posAt = locale_id.find('@');
if(posAt != Glib::ustring::npos)
{
result = result.substr(0, posAt);
......@@ -542,7 +542,7 @@ Glib::ustring Utils::locale_language_id(const Glib::ustring& locale_id)
{
Glib::ustring result;
const Glib::ustring::size_type posUnderscore = locale_id.find("_");
const Glib::ustring::size_type posUnderscore = locale_id.find('_');
if(posUnderscore != Glib::ustring::npos)
{
result = locale_id.substr(0, posUnderscore);
......
......@@ -119,7 +119,7 @@ Glib::ustring Box_Data::get_find_where_clause() const
if(!strClause.empty())
strClause += "AND ";
strClause += "(" + strClausePart + ") ";
strClause += '(' + strClausePart + ") ";
}
}
......
......@@ -475,7 +475,7 @@ Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint m
if(!row_text.empty())
{
if(!result.empty())
result += "\n";
result += '\n';
result += row_text;
}
......
......@@ -123,7 +123,7 @@ void Dialog_AddRelatedTable::on_combo_field_name()
possible_table_name = Utils::string_remove_suffix(possible_table_name, "_id", false /* not case sensitive */);
//Add a "s" to the end, though this probably only makes sense in English. TODO: Don't do this?
possible_table_name += "s";
possible_table_name += 's';
//Discover whether a table with this name exists already,
//and append a numerical prefix until we find one that doesn't exist:
......
......@@ -61,7 +61,7 @@ bool Dialog_Design::init_db_details(const Glib::ustring& table_name)
if(table_title.empty())
table_label = table_name;
else
table_label = table_title + " (" + table_name + ")";
table_label = table_title + " (" + table_name + ')';
}
m_label_table->set_text(table_label);
......
......@@ -264,7 +264,7 @@ Glib::ustring get_locale_name(const Glib::ustring& locale_id)
{
type_map_country::iterator iterFindCountry = map_country.find(id_country);
if(iterFindCountry != map_country.end())
name += " (" + iterFindCountry->second + ")";
name += " (" + iterFindCountry->second + ')';
else
name = Glib::ustring(); //Ignore locales with unnamed countries.
}
......
......@@ -497,7 +497,7 @@ bool Window_PrintLayout_Edit::init_db_details(const Glib::ustring& table_name)
if(table_title.empty())
table_label = table_name;
else
table_label = table_title + " (" + table_name + ")";
table_label = table_title + " (" + table_name + ')';
if(m_label_table)
m_label_table->set_text(table_label);
......
......@@ -448,7 +448,7 @@ static void show_gettext_error(int severity, const char* filename, const gchar*
default:
{
Glib::ustring msg = Glib::ustring(_("Gettext-Error: ")) + " " + msg_stream.str();
Glib::ustring msg = Glib::ustring(_("Gettext-Error: ")) + ' ' + msg_stream.str();
Gtk::MessageDialog dlg(msg, false, Gtk::MESSAGE_ERROR);
dlg.run();
break;
......@@ -496,7 +496,7 @@ Glib::ustring Window_Translations::get_po_context_for_item(const sharedptr<Trans
{
// Note that this context string should use English rather than the translated strings,
// or the context would change depending on the locale of the user doing the export:
return TranslatableItem::get_translatable_type_name_nontranslated(item->get_translatable_item_type()) + " (" + item->get_name() + ")";
return TranslatableItem::get_translatable_type_name_nontranslated(item->get_translatable_item_type()) + " (" + item->get_name() + ')';
}
void Window_Translations::on_button_export()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment