From 297713258248b0c45d80de622027a545732de773 Mon Sep 17 00:00:00 2001 From: Kristof Szabados <Kristof.Szabados@ericsson.com> Date: Sun, 27 Nov 2016 13:24:29 +0100 Subject: [PATCH] some more explicit char conversion Signed-off-by: Kristof Szabados <Kristof.Szabados@ericsson.com> --- common/pattern_uni.y | 8 ++++---- compiler2/PredefFunc.cc | 4 ++-- compiler2/Type_chk.cc | 22 +++++++++++----------- compiler2/Value.cc | 2 +- compiler2/ttcn3/AST_ttcn3.cc | 2 +- compiler2/ttcn3/Templatestuff.cc | 2 +- core/Charstring.cc | 4 ++-- core/Universal_charstring.cc | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/common/pattern_uni.y b/common/pattern_uni.y index e882a1ce7..359406969 100644 --- a/common/pattern_uni.y +++ b/common/pattern_uni.y @@ -574,10 +574,10 @@ RE_Quadruple: if ($3 == 0 && $5 == 0 && $7 == 0 && $9 == 0) TTCN_pattern_error("Zero " "character (i.e. quadruple `\\q{0,0,0,0}') is not supported in a " "pattern for type universal charstring."); - $$.comp.group = $3; - $$.comp.plane = $5; - $$.comp.row = $7; - $$.comp.cell = $9; + $$.comp.group = (unsigned char)$3; + $$.comp.plane = (unsigned char)$5; + $$.comp.row = (unsigned char)$7; + $$.comp.cell = (unsigned char)$9; } ; diff --git a/compiler2/PredefFunc.cc b/compiler2/PredefFunc.cc index e91ee3f8b..d756b57a5 100644 --- a/compiler2/PredefFunc.cc +++ b/compiler2/PredefFunc.cc @@ -766,7 +766,7 @@ string* remove_bom(const string& encoded_value) string str_uppercase(encoded_value); size_t enough = length > sizeof(utf32be)-1 ? sizeof(utf32be)-1 : length; for (size_t i = 0; i < enough; ++i) { - str_uppercase[i] = toupper(encoded_value[i]); + str_uppercase[i] = (char)toupper(encoded_value[i]); } if (str_uppercase.find(utf32be, 0) < length) length_of_BOM = sizeof(utf32be)-1; @@ -833,7 +833,7 @@ string* get_stringencoding(const string& encoded_value) string str_uppercase(encoded_value); size_t enough = length > sizeof(utf32be)-1 ? sizeof(utf32be)-1 : length; for (size_t i = 0; i < enough; ++i) { - str_uppercase[i] = toupper(encoded_value[i]); + str_uppercase[i] = (char)toupper(encoded_value[i]); } if (str_uppercase.find(utf32be, 0) < length) return new string("UTF-32BE"); diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index 7f4d575ae..93239ac46 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -601,22 +601,22 @@ void change_name(string &name, XerAttributes::NameChange change) { case NamespaceSpecification::UPPERCASED: // Walking backwards calls size() only once. Loop var must be signed. for (int i = name.size()-1; i >= 0; --i) { - name[i] = toupper(name[i]); + name[i] = (char)toupper(name[i]); } break; case NamespaceSpecification::LOWERCASED: for (int i = name.size()-1; i >= 0; --i) { - name[i] = tolower(name[i]); + name[i] = (char)tolower(name[i]); } break; case NamespaceSpecification::CAPITALIZED: - name[0] = toupper(name[0]); + name[0] = (char)toupper(name[0]); break; case NamespaceSpecification::UNCAPITALIZED: - name[0] = tolower(name[0]); + name[0] = (char)tolower(name[0]); break; default: // explicitly specified name @@ -778,19 +778,19 @@ void Type::target_of_text(string & text) switch ((unsigned long)txt.new_text) { case NamespaceSpecification::CAPITALIZED: // tARGET -> TARGET - target[0] = toupper(target[0]); + target[0] = (char)toupper(target[0]); break; case NamespaceSpecification::UNCAPITALIZED: - target[0] = tolower(target[0]); // TARGET -> tARGET + target[0] = (char)tolower(target[0]); // TARGET -> tARGET break; case NamespaceSpecification::UPPERCASED: for (int si = target.size() - 1; si >= 0; --si) { - target[si] = toupper(target[si]); + target[si] = (char)toupper(target[si]); } break; case NamespaceSpecification::LOWERCASED: for (int si = target.size() - 1; si >= 0; --si) { - target[si] = tolower(target[si]); + target[si] = (char)tolower(target[si]); } break; @@ -2224,9 +2224,9 @@ void Type::chk_xer() { // XERSTUFF semantic check char first[5] = {0,0,0,0,0}; strncpy(first, xerattrib->namespace_.prefix, 4); bool xml_start = !memcmp(first, "xml", 3); - first[0] = toupper(first[0]); - first[1] = toupper(first[1]); - first[2] = toupper(first[2]); + first[0] = (char)toupper(first[0]); + first[1] = (char)toupper(first[1]); + first[2] = (char)toupper(first[2]); if ((xml_start // It _is_ "xml" or starts with "xml" // Or it matches (('X'|'x') ('M'|'m') ('L'|'l')) || (first[3] == 0 && !memcmp(first, "XML", 3))) diff --git a/compiler2/Value.cc b/compiler2/Value.cc index ef37c9901..cc2e9d45c 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -9477,7 +9477,7 @@ error: if (valuetype != V_CHOICE) FATAL_ERROR("Value::set_alt_name_to_lowercase()"); string new_name = u.choice.alt_name->get_name(); if (isupper(new_name[0])) { - new_name[0] = tolower(new_name[0]); + new_name[0] = (char)tolower(new_name[0]); if (new_name[new_name.size() - 1] == '_') { // an underscore is inserted at the end of the alternative name if it's // a basic type's name (since it would conflict with the class generated diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index 38829cbe7..c827a6d00 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -200,7 +200,7 @@ namespace Ttcn { if (ref_type != FIELD_REF) FATAL_ERROR("FieldOrArrayRef::set_field_name_to_lowercase()"); string new_name = u.id->get_name(); if (isupper(new_name[0])) { - new_name[0] = tolower(new_name[0]); + new_name[0] = (char)tolower(new_name[0]); if (new_name[new_name.size() - 1] == '_') { // an underscore is inserted at the end of the field name if it's // a basic type's name (since it would conflict with the class generated diff --git a/compiler2/ttcn3/Templatestuff.cc b/compiler2/ttcn3/Templatestuff.cc index 3fe276f86..1a2d91251 100644 --- a/compiler2/ttcn3/Templatestuff.cc +++ b/compiler2/ttcn3/Templatestuff.cc @@ -389,7 +389,7 @@ namespace Ttcn { { string new_name = name->get_name(); if (isupper(new_name[0])) { - new_name[0] = tolower(new_name[0]); + new_name[0] = (char)tolower(new_name[0]); if (new_name[new_name.size() - 1] == '_') { // an underscore is inserted at the end of the alternative name if it's // a basic type's name (since it would conflict with the class generated diff --git a/core/Charstring.cc b/core/Charstring.cc index 13afe2c2a..f72ce5d72 100644 --- a/core/Charstring.cc +++ b/core/Charstring.cc @@ -1017,12 +1017,12 @@ int CHARSTRING::TEXT_decode(const TTCN_Typedescriptor_t& p_td, && p_td.text->val.parameters->decoding_params.convert != 0) { if (p_td.text->val.parameters->decoding_params.convert == 1) { for (int a = 0; a < str_len; a++) { - val_ptr->chars_ptr[a] = toupper(val_ptr->chars_ptr[a]); + val_ptr->chars_ptr[a] = (char)toupper(val_ptr->chars_ptr[a]); } } else { for (int a = 0; a < str_len; a++) { - val_ptr->chars_ptr[a] = tolower(val_ptr->chars_ptr[a]); + val_ptr->chars_ptr[a] = (char)tolower(val_ptr->chars_ptr[a]); } } } diff --git a/core/Universal_charstring.cc b/core/Universal_charstring.cc index 19022aa1b..dd5b5f2c4 100644 --- a/core/Universal_charstring.cc +++ b/core/Universal_charstring.cc @@ -1355,12 +1355,12 @@ int UNIVERSAL_CHARSTRING::TEXT_decode(const TTCN_Typedescriptor_t& p_td, && p_td.text->val.parameters->decoding_params.convert != 0) { if (p_td.text->val.parameters->decoding_params.convert == 1) { for (int a = 0; a < str_len; a++) { - val_ptr->chars_ptr[a] = toupper(val_ptr->chars_ptr[a]); + val_ptr->chars_ptr[a] = (char)toupper(val_ptr->chars_ptr[a]); } } else { for (int a = 0; a < str_len; a++) { - val_ptr->chars_ptr[a] = tolower(val_ptr->chars_ptr[a]); + val_ptr->chars_ptr[a] = (char)tolower(val_ptr->chars_ptr[a]); } } }*/ -- GitLab