Skip to content

Instantly share code, notes, and snippets.

@marcosscriven
Created March 13, 2013 21:36
Show Gist options
  • Save marcosscriven/5156546 to your computer and use it in GitHub Desktop.
Save marcosscriven/5156546 to your computer and use it in GitHub Desktop.
Test case for Emscripten. In native code this will continue on to next line, but in Javascript, it runs forever with the given input.
#include <iostream>
#include <fstream>
int main() {
std::string filename = "processfile.txt";
std::cout << "Processing file:" << filename << "\n";
std::ifstream stream(filename.c_str());
while (!stream.eof())
{
std::string key, value;
std::getline(stream, key);
std::getline(stream, value);
std::cout << "Read:" << key << ", with value:" << value << "\n";
if(value.length() == 0) {
std::cout << "Got a blank value" << "\n";
continue;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment