Fixed a bug where is_num() and is_int() returned true when a letter was entered.
This commit is contained in:
		
							parent
							
								
									f9e4f13bfe
								
							
						
					
					
						commit
						04959332f2
					
				
					 1 changed files with 4 additions and 4 deletions
				
			
		| 
						 | 
					@ -15,13 +15,13 @@ bool is_num(char *str) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    while (*str) {
 | 
					    while (*str) {
 | 
				
			||||||
        if (!isdigit((unsigned char)*str) || !(*str == '.')) {
 | 
					        if (!isdigit((unsigned char)*str)) {
 | 
				
			||||||
            return true;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        str++;
 | 
					        str++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return false;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool is_int(char *str) {
 | 
					bool is_int(char *str) {
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ bool is_int(char *str) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    while (*str) {
 | 
					    while (*str) {
 | 
				
			||||||
        if (!isdigit((unsigned char)*str)) {
 | 
					        if (!isdigit((unsigned char)*str)) {
 | 
				
			||||||
            return true;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        str++;
 | 
					        str++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue