Skip to content

Assumption that EOF is enclosed in parantheses (example: (-1)); otherwise compilation error #1288

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

Closed
JayFoxRox opened this issue Apr 22, 2021 · 2 comments · Fixed by #1289
Closed

Comments

@JayFoxRox
Copy link

Previously discussed at DevSolar/pdclib#20 (comment).

These 2 problems exist in jsoncpp:

  1. EOF is used in a way that might break certain C implementations (in our case, pdclib for C + libcxx for C++, with clang as compiler). The code assumes that EOF will provide paranetheses for dynamic_cast:
    std::getline(is, doc, static_cast<char> EOF);
  2. EOF isn't a char, but it's used as if it is. EOF is also not very strictly defined, so the behavior will be C implementation defined. Typically you get either a char (cast to int) or an EOF (int) as return value from functions like getchar().

Point 1 is easily fixed, but 2 shows that it might not be necessary to fix it - the problematic code needs to be rewritten.

@BillyDonahue
Copy link
Contributor

BillyDonahue commented Apr 22, 2021 via email

@cdunn2001
Copy link
Contributor

Hmm. I guess getline(stream, EOF) was my own mistake from many years ago, in 56a1d6c .

I guess we want this:

std::string s(std::istreambuf_iterator<char>(stream), {});

cdunn2001 added a commit that referenced this issue May 5, 2021
cdunn2001 added a commit that referenced this issue May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants