Skip to content

Commit

Permalink
Change a tiny aspect about how file reader works
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphyWind committed Feb 23, 2024
1 parent 869e211 commit 5aaf9d5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Supports all eight directions. Finishes the program execution.

### **File Reader (r)**
Supports northeast, north, northwest, west and southwest directions. Continuously pops the value on top of the stack and constructs a filename from those values until either it hits a zero or the stack becomes empty. (If it hits a zero, it also pops that)
Then reads the file with that filename in binary mode with utf8 encoding and pushes its content on top of the stack in reverse order, meaning the first character of the file will be the value on top of the stack. If it fails, it pushes zero to the stack.
Then reads the file with that filename in binary mode and pushes its content on top of the stack in reverse order, meaning the first character of the file will be the value on top of the stack. If it fails, it pushes zero to the stack.

### **File Openers**
Similar to File Reader, File Openers read a filename from the stack in the same way. After opening the file, they push a positive integer as unique identifier that can be used to communicate with file.
Expand Down
2 changes: 1 addition & 1 deletion include/ArgParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.

#define ELECTRA_VERSION_MAJOR 2
#define ELECTRA_VERSION_MINOR 2
#define ELECTRA_VERSION_PATCH 0
#define ELECTRA_VERSION_PATCH 1

#include <vector>
#include <unordered_map>
Expand Down
5 changes: 1 addition & 4 deletions src/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ bool FileReader::work(Current::Ptr current, std::vector<Current::Ptr>& currentVe
std::stringstream ss;
ss << ifs.rdbuf();
ifs.close();
std::string fileContent_utf8 = ss.str();
std::u32string fileContent;
fileContent.reserve(fileContent_utf8.size());
utf8::utf8to32(fileContent_utf8.begin(), fileContent_utf8.end(), std::back_inserter(fileContent));
std::string fileContent = ss.str();

while(!fileContent.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool Printer::work(Current::Ptr current, std::vector<Current::Ptr>& currentVecto
}
catch(const utf8::invalid_code_point& invalidCodePoint)
{
defaultLogger.log(LogType::WARNING, "{}. {}", invalidCodePoint.what(), static_cast<long>(top_character32));
std::cout << static_cast<char>(top_character32);
}

std::cout << str_to_print << std::flush;
Expand Down

0 comments on commit 5aaf9d5

Please sign in to comment.