Fix excessive left shift of signed integer and some doxygen errors

This commit is contained in:
Alexander Mai 2015-11-27 19:32:28 +01:00
parent 1bf547c716
commit d4749c3377
2 changed files with 11 additions and 11 deletions

View File

@ -254,7 +254,7 @@ private:
/**
* @brief assign a variable in the varlist
* @param varname name of variable to mark assigned
* @param varid id of variable to mark assigned
* @param scope pointer to variable Scope
* @param usage reference to usage vector
*/
@ -262,7 +262,7 @@ private:
/**
* @brief initialize a variable in the varlist
* @param varname name of variable to mark initialized
* @param varid id of variable to mark initialized
* @param scope pointer to variable Scope
* @param usage reference to usage vector
*/

View File

@ -328,26 +328,27 @@ MathLib::bigint MathLib::characterLiteralToLongNumber(const std::string& str)
return 0; // for unit-testing...
if (str.size()==1)
return str[0] & 0xff;
const std::string& str1 = str.substr(1);
if (str[0] != '\\') {
// C99 6.4.4.4
// The value of an integer character constant containing more than one character (e.g., 'ab'),
// or containing a character or escape sequence that does not map to a single-byte execution character,
// is implementation-defined.
// clang and gcc seem to use the following encoding: 'AB' as (('A' << 8) | 'B')
int retval(str.front());
for (std::string::const_iterator it=str.begin()+1; it!=str.end(); ++it) {
unsigned long retval(str.front());
for (std::string::const_iterator it=str1.begin(); it!=str1.end(); ++it) {
retval = retval<<8 | *it;
}
return retval;
return (MathLib::bigint)retval;
}
switch (str[1]) {
switch (str1[0]) {
case 'x':
return toLongNumber("0x" + str.substr(2));
case 'u': // 16bit unicode character
throw InternalError(0, "Internal Error. MathLib::toLongNumber: Unhandled 16-bit unicode char constant " + str);
throw InternalError(0, "Internal Error. MathLib::toLongNumber: Unhandled 16-bit unicode char constant \\" + str);
case 'U': // 16bit unicode character
throw InternalError(0, "Internal Error. MathLib::toLongNumber: Unhandled 32-bit unicode char constant " + str);
throw InternalError(0, "Internal Error. MathLib::toLongNumber: Unhandled 32-bit unicode char constant \\" + str);
default: {
char c;
switch (str.size()-1) {
@ -394,12 +395,11 @@ MathLib::bigint MathLib::characterLiteralToLongNumber(const std::string& str)
}
return c & 0xff;
case 2:
case 3: {
const std::string& str1 = str.substr(1);
case 3:
if (isOctalDigitString(str1))
return toLongNumber("0" + str1);
break;
}
}
}
}