Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use int instead of char in CLI config parser #3976

Merged
merged 1 commit into from
Dec 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class ConfigReaderBase {
* \brief to be implemented by subclass,
* get next token, return EOF if end of file
*/
virtual char GetChar() = 0;
virtual int GetChar() = 0;
/*! \brief to be implemented by child, check if end of stream */
virtual bool IsEnd() = 0;

private:
char ch_buf_;
int ch_buf_;
std::string s_name_, s_val_, s_buf_;

inline void SkipLine() {
Expand All @@ -79,7 +79,7 @@ class ConfigReaderBase {
case '\"': return;
case '\r':
case '\n': LOG(FATAL)<< "ConfigReader: unterminated string";
default: *tok += ch_buf_;
default: *tok += static_cast<char>(ch_buf_);
}
}
LOG(FATAL) << "ConfigReader: unterminated string";
Expand All @@ -89,7 +89,7 @@ class ConfigReaderBase {
switch (ch_buf_) {
case '\\': *tok += this->GetChar(); break;
case '\'': return;
default: *tok += ch_buf_;
default: *tok += static_cast<char>(ch_buf_);
}
}
LOG(FATAL) << "unterminated string";
Expand Down Expand Up @@ -128,7 +128,7 @@ class ConfigReaderBase {
if (tok->length() != 0) return new_line;
break;
default:
*tok += ch_buf_;
*tok += static_cast<char>(ch_buf_);
ch_buf_ = this->GetChar();
break;
}
Expand All @@ -152,7 +152,7 @@ class ConfigStreamReader: public ConfigReaderBase {
explicit ConfigStreamReader(std::istream &fin) : fin_(fin) {}

protected:
char GetChar() override {
int GetChar() override {
return fin_.get();
}
/*! \brief to be implemented by child, check if end of stream */
Expand Down