mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Fixed win32 troubles with f.readsome()
This commit is contained in:
		
							parent
							
								
									a32e067e5c
								
							
						
					
					
						commit
						8263f6a74a
					
				
					 6 changed files with 21 additions and 4 deletions
				
			
		|  | @ -35,7 +35,7 @@ | ||||||
| USING_YOSYS_NAMESPACE | USING_YOSYS_NAMESPACE | ||||||
| 
 | 
 | ||||||
| #define YY_INPUT(buf,result,max_size) \ | #define YY_INPUT(buf,result,max_size) \ | ||||||
|         result = ILANG_FRONTEND::lexin->readsome(buf, max_size); |         result = readsome(*ILANG_FRONTEND::lexin, buf, max_size); | ||||||
| 
 | 
 | ||||||
| %} | %} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -64,7 +64,7 @@ YOSYS_NAMESPACE_END | ||||||
| 	return TOK_ID; | 	return TOK_ID; | ||||||
| 
 | 
 | ||||||
| #define YY_INPUT(buf,result,max_size) \ | #define YY_INPUT(buf,result,max_size) \ | ||||||
| 	result = lexin->readsome(buf, max_size); | 	result = readsome(*lexin, buf, max_size); | ||||||
| 
 | 
 | ||||||
| %} | %} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -202,7 +202,7 @@ static void input_file(std::istream &f, std::string filename) | ||||||
| 	auto it = input_buffer.begin(); | 	auto it = input_buffer.begin(); | ||||||
| 
 | 
 | ||||||
| 	input_buffer.insert(it, "`file_push " + filename + "\n"); | 	input_buffer.insert(it, "`file_push " + filename + "\n"); | ||||||
| 	while ((rc = f.readsome(buffer, sizeof(buffer)-1)) > 0) { | 	while ((rc = readsome(f, buffer, sizeof(buffer)-1)) > 0) { | ||||||
| 		buffer[rc] = 0; | 		buffer[rc] = 0; | ||||||
| 		input_buffer.insert(it, buffer); | 		input_buffer.insert(it, buffer); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -166,6 +166,22 @@ bool patmatch(const char *pattern, const char *string) | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | int readsome(std::istream &f, char *s, int n) | ||||||
|  | { | ||||||
|  | 	int rc = f.readsome(s, n); | ||||||
|  | 
 | ||||||
|  | 	// win32 sometimes returns 0 on a non-empty stream..
 | ||||||
|  | 	if (rc == 0) { | ||||||
|  | 		int c = f.get(); | ||||||
|  | 		if (c != EOF) { | ||||||
|  | 			*s = c; | ||||||
|  | 			rc = 1; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return rc; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int GetSize(RTLIL::Wire *wire) | int GetSize(RTLIL::Wire *wire) | ||||||
| { | { | ||||||
| 	return wire->width; | 	return wire->width; | ||||||
|  |  | ||||||
|  | @ -86,6 +86,7 @@ std::string stringf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)) | ||||||
| std::string vstringf(const char *fmt, va_list ap); | std::string vstringf(const char *fmt, va_list ap); | ||||||
| std::string next_token(std::string &text, const char *sep); | std::string next_token(std::string &text, const char *sep); | ||||||
| bool patmatch(const char *pattern, const char *string); | bool patmatch(const char *pattern, const char *string); | ||||||
|  | int readsome(std::istream &f, char *s, int n); | ||||||
| 
 | 
 | ||||||
| template<typename T> int GetSize(const T &obj) { return obj.size(); } | template<typename T> int GetSize(const T &obj) { return obj.size(); } | ||||||
| int GetSize(RTLIL::Wire *wire); | int GetSize(RTLIL::Wire *wire); | ||||||
|  |  | ||||||
|  | @ -70,7 +70,7 @@ struct WriteFileFrontend : public Frontend { | ||||||
| 		char buffer[64 * 1024]; | 		char buffer[64 * 1024]; | ||||||
| 		size_t bytes; | 		size_t bytes; | ||||||
| 
 | 
 | ||||||
| 		while (0 < (bytes = f->readsome(buffer, sizeof(buffer)))) | 		while (0 < (bytes = readsome(*f, buffer, sizeof(buffer)))) | ||||||
| 			fwrite(buffer, bytes, 1, of); | 			fwrite(buffer, bytes, 1, of); | ||||||
| 
 | 
 | ||||||
| 		fclose(of); | 		fclose(of); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue