mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
trim extra newlines from windows error message
This commit is contained in:
parent
b15a2ae9fc
commit
3bd9146030
@ -313,8 +313,8 @@ do_get(const string &key, const string &name, int &data_type, string &data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error != ERROR_SUCCESS) {
|
if (error != ERROR_SUCCESS) {
|
||||||
express_cat.error()
|
express_cat.info()
|
||||||
<< "Unable to get registry key " << key << " name " << name
|
<< "Unable to get registry value " << name
|
||||||
<< ": " << format_message(error) << "\n";
|
<< ": " << format_message(error) << "\n";
|
||||||
okflag = false;
|
okflag = false;
|
||||||
}
|
}
|
||||||
@ -337,13 +337,20 @@ do_get(const string &key, const string &name, int &data_type, string &data) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
string WindowsRegistry::
|
string WindowsRegistry::
|
||||||
format_message(int error_code) {
|
format_message(int error_code) {
|
||||||
PVOID buffer;
|
LPTSTR buffer;
|
||||||
DWORD length =
|
DWORD length =
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL, error_code, 0, (LPTSTR)&buffer, 0, NULL);
|
NULL, error_code, 0, &buffer, 0, NULL);
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return "Unknown error message";
|
return "Unknown error message";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip off \n's and \r's trailing the string.
|
||||||
|
while (length > 0 &&
|
||||||
|
(buffer[length - 1] == '\r' || buffer[length - 1] == '\n')) {
|
||||||
|
length--;
|
||||||
|
}
|
||||||
|
|
||||||
string result((const char *)buffer, length);
|
string result((const char *)buffer, length);
|
||||||
LocalFree(buffer);
|
LocalFree(buffer);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user