(svn r2277) - Codechange: change sscanf() into stroul() Which Does The Right Thing tm. Thanks tron
This commit is contained in:
		
							
								
								
									
										20
									
								
								console.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								console.c
									
									
									
									
									
								
							@@ -448,17 +448,19 @@ void IConsoleError(const char* string)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
bool GetArgumentInteger(uint32 *value, const char *arg)
 | 
					bool GetArgumentInteger(uint32 *value, const char *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int result = sscanf(arg, "%u", value);
 | 
						char *endptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Hexadecimal numbers start with 0x, so at least the first number has been parsed */
 | 
						if (strcmp(arg, "on") == 0 || strcmp(arg, "true") == 0) {
 | 
				
			||||||
	if (result == 1 && arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X'))
 | 
							*value = 1;
 | 
				
			||||||
		result = sscanf(arg, "%x", value);
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (strcmp(arg, "off") == 0 || strcmp(arg, "false") == 0) {
 | 
				
			||||||
 | 
							*value = 0;
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (result == 0 && (strcmp(arg, "on") == 0 || strcmp(arg, "true") == 0 )) {*value = 1; result = 1;}
 | 
						*value = strtoul(arg, &endptr, 0);
 | 
				
			||||||
 | 
						return (arg == endptr) ? false : true;
 | 
				
			||||||
	if (result == 0 && (strcmp(arg, "off") == 0 || strcmp(arg, "false") == 0)) {*value = 0; result = 1;}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return !!result;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user