mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 13:41:03 +00:00 
			
		
		
		
	Prevent defining float constant without number after exponent in shaders
This commit is contained in:
		
							parent
							
								
									8aa69c4e06
								
							
						
					
					
						commit
						c9ae83b5ab
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -613,12 +613,16 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { | ||||||
| 
 | 
 | ||||||
| 					String str; | 					String str; | ||||||
| 					int i = 0; | 					int i = 0; | ||||||
|  | 					bool digit_after_exp = false; | ||||||
| 
 | 
 | ||||||
| 					while (true) { | 					while (true) { | ||||||
| 						const char32_t symbol = String::char_lowercase(GETCHAR(i)); | 						const char32_t symbol = String::char_lowercase(GETCHAR(i)); | ||||||
| 						bool error = false; | 						bool error = false; | ||||||
| 
 | 
 | ||||||
| 						if (is_digit(symbol)) { | 						if (is_digit(symbol)) { | ||||||
|  | 							if (exponent_found) { | ||||||
|  | 								digit_after_exp = true; | ||||||
|  | 							} | ||||||
| 							if (end_suffix_found) { | 							if (end_suffix_found) { | ||||||
| 								error = true; | 								error = true; | ||||||
| 							} | 							} | ||||||
|  | @ -683,7 +687,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { | ||||||
| 							return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant"); | 							return _make_token(TK_ERROR, "Invalid (hexadecimal) numeric constant"); | ||||||
| 						} | 						} | ||||||
| 					} else if (period_found || exponent_found || float_suffix_found) { // Float
 | 					} else if (period_found || exponent_found || float_suffix_found) { // Float
 | ||||||
| 						if (exponent_found && (!is_digit(last_char) && last_char != 'f')) { // checks for eg: "2E", "2E-", "2E+"
 | 						if (exponent_found && (!digit_after_exp || (!is_digit(last_char) && last_char != 'f'))) { // Checks for eg: "2E", "2E-", "2E+" and 0ef, 0e+f, 0.0ef, 0.0e-f (exponent without digit after it).
 | ||||||
| 							return _make_token(TK_ERROR, "Invalid (float) numeric constant"); | 							return _make_token(TK_ERROR, "Invalid (float) numeric constant"); | ||||||
| 						} | 						} | ||||||
| 						if (period_found) { | 						if (period_found) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yuri Rubinsky
						Yuri Rubinsky