From 37ceb042e1793710332c4233f230baa477924c2d Mon Sep 17 00:00:00 2001 From: nakeee Date: Wed, 17 Jun 2009 23:36:04 +0000 Subject: [PATCH] DSPCodeUtil some code fixing git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3485 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/StringUtil.cpp | 6 +++--- Source/Core/DSPCore/Src/DSPCodeUtil.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp index e5a42dc3fb..0233c5e841 100644 --- a/Source/Core/Common/Src/StringUtil.cpp +++ b/Source/Core/Common/Src/StringUtil.cpp @@ -338,14 +338,14 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _ if (last_slash == std::string::npos) { - return false; + return false; // FIXME return the filename } size_t last_dot = full_path.rfind('.'); if ((last_dot == std::string::npos) || (last_dot < last_slash)) { - return false; + return false; // FIXME why missing . is critical? } if (_pPath) @@ -459,4 +459,4 @@ void NormalizeDirSep(std::string* str) str->replace(i, 1, DIR_SEP); } #endif -} \ No newline at end of file +} diff --git a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp index 709ecfc095..0fcd7c62dc 100644 --- a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp +++ b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp @@ -150,7 +150,7 @@ void CodeToHeader(const std::vector &code, std::string _filename, void CodesToHeader(const std::vector *codes, const std::vector* filenames, int numCodes, const char *name, std::string &header) { - char buffer[0x1000]; + char buffer[1024]; int reserveSize = 0; for(int i = 0; i < numCodes; i++) reserveSize += (int)codes[i].size(); @@ -160,15 +160,16 @@ void CodesToHeader(const std::vector *codes, const std::vector header.reserve(reserveSize * 4); sprintf(buffer, "#define NUM_UCODES %d\n\n", numCodes); header.append(buffer); - sprintf(buffer, "const char* UCODE_NAMES[NUM_UCODES] = {\n"); + header.append("const char* UCODE_NAMES[NUM_UCODES] = {\n"); for (int i = 0; i < numCodes; i++) { std::string filename; - SplitPath(filenames->at(i), NULL, &filename, NULL); - sprintf(buffer, "%s\t\"%s\",\n", buffer, filename.c_str()); + if (! SplitPath(filenames->at(i), NULL, &filename, NULL)) + filename = filenames->at(i); + sprintf(buffer, "\t\"%s\",\n", filename.c_str()); + header.append(buffer); } - sprintf(buffer, "%s};\n\n", buffer); - header.append(buffer); + header.append("};\n\n"); header.append("#ifndef _MSCVER\n"); sprintf(buffer, "const unsigned short %s[NUM_UCODES][0x1000] = {\n", name); header.append(buffer);