Skip to content

Commit

Permalink
Fix string find()
Browse files Browse the repository at this point in the history
  • Loading branch information
omaraflak authored Oct 5, 2023
1 parent 1db6e5c commit 19fc459
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ std::string trim(const std::string& str, const std::string& character) {
std::vector<std::string> trim_lines(const std::vector<std::string>& lines, const std::string& comment = ";") {
std::vector<std::string> result;
for (std::string line : lines) {
int index = line.find(comment);
if (index != -1) {
size_t index = line.find(comment);
if (index != std::string::npos) {
line = line.substr(0, index);
}
line = trim(line, " ");
Expand Down Expand Up @@ -58,7 +58,7 @@ std::map<std::string, uint64_t> create_labels_map(const std::vector<std::string>
continue;
}
std::shared_ptr<Instruction> instruction;
if (line.find('.') < 0) {
if (line.find('.') == std::string::npos) {
instruction = Instruction::from_string(line);
} else {
std::string opstring = split_string(line)[0];
Expand Down Expand Up @@ -110,4 +110,4 @@ int main(int argc, char** argv) {
std::vector<uint8_t> binary = to_binary(parse_program(lines));
fileutils::write_bytes(binary, argv[2]);
return 0;
}
}

0 comments on commit 19fc459

Please sign in to comment.