FreeCalypso > hg > freecalypso-tools
annotate target-utils/libc/strncmp.c @ 633:4dca8542f569
loadtools/romload.c: collect additional response bytes after >p and >c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 01 Mar 2020 00:57:12 +0000 |
parents | 7fb62fc724dc |
children |
rev | line source |
---|---|
87
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0 |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 strncmp(s1, s2, n) |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 register char *s1, *s2; |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 register n; |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 { |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 while (--n >= 0 && *s1 == *s2++) |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 if (*s1++ == '\0') |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 return(0); |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 return(n<0 ? 0 : *s1 - *--s2); |
7fb62fc724dc
target-utils/libc: beginning of newlib-ectomy
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 } |