Skip to content

Commit

Permalink
Merge pull request #140 from eelvi/strncmp-fix
Browse files Browse the repository at this point in the history
fixed strncmp.
  • Loading branch information
brabo authored Nov 14, 2017
2 parents 60360ae + 1732f24 commit 2f64d64
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions kernel/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,9 @@ int strncmp(const char *s1, const char *s2, size_t n)
int diff = 0;

while (n > 0) {
if (!s1) {
diff = 0 - (int)*s2;
} else if (!s2) {
diff = (int)*s1;
} else {
diff = (int)*s1 - (int)*s2;
}

if (diff)
diff = (unsigned char)*s1 - (unsigned char)*s2;
if (diff || !*s1)
break;

s1++;
s2++;
n--;
Expand Down

0 comments on commit 2f64d64

Please sign in to comment.