fixes: 1. do not skip over first non-empty line; 2. skip over all empty lines
This commit is contained in:
		
							parent
							
								
									ff01cf3a3c
								
							
						
					
					
						commit
						eebcddb472
					
				@ -24,6 +24,7 @@ struct semicolon_is_space : std::ctype<char> {
 | 
			
		||||
    return &rc[0];
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class input {
 | 
			
		||||
public:
 | 
			
		||||
  std::string s;
 | 
			
		||||
@ -33,9 +34,7 @@ public:
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
std::istream &operator>>(std::istream &in, input &i) {
 | 
			
		||||
  std::getline(in, i.s, '\n'); // An inelegant hack to skip newline character
 | 
			
		||||
  std::getline(in, i.s, ';');
 | 
			
		||||
  in >> i.k;
 | 
			
		||||
  in >> i.s >> i.k;
 | 
			
		||||
  return in;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -128,10 +127,10 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
  std::vector<test_case> test_cases;
 | 
			
		||||
  semicolon_is_space delimeter;
 | 
			
		||||
  for (int i = 1; i < argc; i++) {
 | 
			
		||||
    test_case t;
 | 
			
		||||
    std::ifstream f(argv[i]);
 | 
			
		||||
    f.imbue(std::locale(f.getloc(), new semicolon_is_space));
 | 
			
		||||
    while (f.good()) {
 | 
			
		||||
      test_case t;
 | 
			
		||||
      f >> t;
 | 
			
		||||
      if (t.i.s.length()) { // skip empty line/string inputs
 | 
			
		||||
        std::cout << t;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user