Compare commits
8 Commits
3a1e87fa24
...
dea9ea660e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dea9ea660e | ||
![]() |
cfadb53fa9 | ||
![]() |
5b4dc03763 | ||
![]() |
d28d72aaf5 | ||
![]() |
9920c2d190 | ||
![]() |
5d86ef63b2 | ||
![]() |
53cb367145 | ||
![]() |
ad3a7bcd1d |
@ -40,6 +40,7 @@ int main() {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Strip out any whitespaces
|
||||
char* dst = input;
|
||||
for(char * src = input; *src; src++) {
|
||||
if(!isspace(*src)) {
|
||||
@ -49,6 +50,10 @@ int main() {
|
||||
*dst = '\0';
|
||||
|
||||
int trimmed_len = strlen(input);
|
||||
|
||||
// Check whether the provided input
|
||||
// starts with rgb(
|
||||
// and ends with )
|
||||
if(strncmp(input, "rgb(", 4) != 0 || input[trimmed_len - 1] != ')') {
|
||||
debug("%s not in rgb(xxx) format", input);
|
||||
return invalid_input();
|
||||
@ -60,10 +65,13 @@ int main() {
|
||||
char* token = strtok(slice, ",");
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
// strtok reached end prematurely
|
||||
if(token == NULL) {
|
||||
debug("Too few numbers");
|
||||
return invalid_input();
|
||||
}
|
||||
|
||||
// Not a number
|
||||
if(!is_numeric(token)) {
|
||||
debug("%s is not a number", token);
|
||||
return invalid_input();
|
||||
|
Loading…
x
Reference in New Issue
Block a user