mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:50:05 +00:00 
			
		
		
		
	Ignore comment character if it appears in quotes
This commit is contained in:
		
							parent
							
								
									6767c0c50a
								
							
						
					
					
						commit
						c99e24f2c1
					
				
					 2 changed files with 15 additions and 6 deletions
				
			
		|  | @ -43,5 +43,5 @@ private: | ||||||
|    std::unique_ptr<Impl> p; |    std::unique_ptr<Impl> p; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace common
 | } // namespace gr
 | ||||||
| } // namespace scwx
 | } // namespace scwx
 | ||||||
|  |  | ||||||
|  | @ -110,11 +110,20 @@ std::shared_ptr<Placefile> Placefile::Load(std::istream& is) | ||||||
|    while (scwx::util::getline(is, line)) |    while (scwx::util::getline(is, line)) | ||||||
|    { |    { | ||||||
|       // Find position of comment (;)
 |       // Find position of comment (;)
 | ||||||
|       std::size_t lineEnd = line.find(';'); |       bool inQuotes = false; | ||||||
|       if (lineEnd == std::string::npos) |       for (std::size_t i = 0; i < line.size(); ++i) | ||||||
|  |       { | ||||||
|  |          if (!inQuotes && line[i] == ';') | ||||||
|          { |          { | ||||||
|             // Remove comment
 |             // Remove comment
 | ||||||
|          line.erase(lineEnd); |             line.erase(i); | ||||||
|  |             break; | ||||||
|  |          } | ||||||
|  |          else if (line[i] == '"') | ||||||
|  |          { | ||||||
|  |             // Toggle quote state
 | ||||||
|  |             inQuotes = !inQuotes; | ||||||
|  |          } | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       // Remove extra spacing from line
 |       // Remove extra spacing from line
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat