Skip to content

Commit

Permalink
Corrected segfault issues when using cin and failures in specifying e…
Browse files Browse the repository at this point in the history
…ncodings
  • Loading branch information
drojaazu committed Apr 30, 2021
1 parent 45e3897 commit 896d732
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 126 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{c,h,cpp,hpp}]
indent_style = tab
indent_size = 2
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(GNUInstallDirs)

# define project
cmake_minimum_required (VERSION 3.5)
project (jstrings VERSION 1.1 LANGUAGES CXX)
project (jstrings VERSION 1.2 LANGUAGES CXX)
set(PROJECT_CONTACT "Damian R ([email protected])")
set(PROJECT_WEBSITE "https://github.com/drojaazu")

Expand Down
4 changes: 2 additions & 2 deletions inc/enc_cp932.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
namespace encodings
{

class cp932 : public shift_jis
class encoding_cp932 : public encoding_shiftjis
{
public:
u8 is_valid(u8 const *data);
~cp932(){};
~encoding_cp932(){};
};

} // namespace encodings
Expand Down
6 changes: 3 additions & 3 deletions inc/enc_eucjp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
namespace encodings
{

class euc : public encoding
class encoding_eucjp : public encoding
{
public:
euc() : encoding(3){};
encoding_eucjp() : encoding(3){};
u8 is_valid(u8 const *data);
~euc(){};
~encoding_eucjp(){};
};

} // namespace encodings
Expand Down
6 changes: 3 additions & 3 deletions inc/enc_shiftjis.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
namespace encodings
{

class shift_jis : public encoding
class encoding_shiftjis : public encoding
{
public:
shift_jis() : encoding(2){};
encoding_shiftjis() : encoding(2){};
u8 is_valid(u8 const *data);
~shift_jis(){};
~encoding_shiftjis(){};
};

} // namespace encodings
Expand Down
31 changes: 0 additions & 31 deletions inc/main.h

This file was deleted.

17 changes: 0 additions & 17 deletions inc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,4 @@ template <typename T> using sptr = std::shared_ptr<T>;

typedef std::map<std::string const, std::string> kvmap;

/*!
* \brief POD structure for containing a found string
*/
class found_string
{
public:
/*!
* \brief The offset of the beginning of the found string relative to the
* start of the stream
*/
off_t address;
/*!
* \brief The extracted string data
*/
std::vector<uint8_t> data;
};

#endif
4 changes: 2 additions & 2 deletions src/enc_cp932.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace encodings
{

u8 cp932::is_valid(u8 const *data)
u8 encoding_cp932::is_valid(u8 const *data)
{
u8 valid_count = shift_jis::is_valid(data);
u8 valid_count = encoding_shiftjis::is_valid(data);
if(valid_count > 0)
return valid_count;
else {
Expand Down
2 changes: 1 addition & 1 deletion src/enc_eucjp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace encodings
{
u8 euc::is_valid(u8 const *data)
u8 encoding_eucjp::is_valid(u8 const *data)
{

u8 c_hi{*data};
Expand Down
2 changes: 1 addition & 1 deletion src/enc_shiftjis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace encodings
0208 There is extended support for 0213, though we're not going to fiddle with
it Maybe we'll make an extended class
*/
u8 shift_jis::is_valid(u8 const *data)
u8 encoding_shiftjis::is_valid(u8 const *data)
{
// JIS X 0201 - 8-bit characters (including 7-bit ASCII)
// excludes non-printable (control code) and reserved bytes
Expand Down
Loading

0 comments on commit 896d732

Please sign in to comment.