Skip to content
Snippets Groups Projects
Commit cc22b795 authored by Wolfgang Denk's avatar Wolfgang Denk
Browse files

itest: fix result of string compares


The implementation of the string compare function of the "itest"
command was weird, as only the length of the shortest argument was
included in the compare, with the result that something like
"itest.s abd == abddef" would return TRUE.  Fix this.

Signed-off-by: default avatarWolfgang Denk <wd@denx.de>
Acked-by: default avatarDetlev Zundel <dzu@denx.de>
parent 518075fc
No related branches found
No related tags found
No related merge requests found
...@@ -94,16 +94,13 @@ static char * evalstr(char *s) ...@@ -94,16 +94,13 @@ static char * evalstr(char *s)
static int stringcomp(char *s, char *t, int op) static int stringcomp(char *s, char *t, int op)
{ {
int n, p; int p;
char *l, *r; char *l, *r;
l = evalstr(s); l = evalstr(s);
r = evalstr(t); r = evalstr(t);
/* we'll do a compare based on the length of the shortest string */ p = strcmp(l, r);
n = min(strlen(l), strlen(r));
p = strncmp(l, r, n);
switch (op) { switch (op) {
case EQ: return (p == 0); case EQ: return (p == 0);
case NE: return (p != 0); case NE: return (p != 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment