aboutsummaryrefslogtreecommitdiff
path: root/source/text_handler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/text_handler.cpp')
-rw-r--r--source/text_handler.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/source/text_handler.cpp b/source/text_handler.cpp
index c31f34a6..fe12a26e 100644
--- a/source/text_handler.cpp
+++ b/source/text_handler.cpp
@@ -29,6 +29,7 @@
#include "source/util/bitutils.h"
#include "source/util/hex_float.h"
#include "source/util/parse_number.h"
+#include "source/util/string_utils.h"
namespace spvtools {
namespace {
@@ -120,7 +121,8 @@ spv_result_t getWord(spv_text text, spv_position position, std::string* word) {
case '\n':
case '\r':
if (escaping || quoting) break;
- // Fall through.
+ word->assign(text->str + start_index, text->str + position->index);
+ return SPV_SUCCESS;
case '\0': { // NOTE: End of word found!
word->assign(text->str + start_index, text->str + position->index);
return SPV_SUCCESS;
@@ -306,14 +308,8 @@ spv_result_t AssemblyContext::binaryEncodeString(const char* value,
<< SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX << " words.";
}
- pInst->words.resize(newWordCount);
-
- // Make sure all the bytes in the last word are 0, in case we only
- // write a partial word at the end.
- pInst->words.back() = 0;
-
- char* dest = (char*)&pInst->words[oldWordCount];
- strncpy(dest, value, length + 1);
+ pInst->words.reserve(newWordCount);
+ spvtools::utils::AppendToVector(value, &pInst->words);
return SPV_SUCCESS;
}