Last change
on this file since e877e55 was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Zero redundant declarations.
|
-
Property mode
set to
100644
|
File size:
525 bytes
|
Line | |
---|
1 | /*
|
---|
2 | =============================================================================
|
---|
3 | strncmp.c -- compare strings
|
---|
4 | Version 2 -- 1987-06-15
|
---|
5 |
|
---|
6 | Compare strings (at most n bytes)
|
---|
7 | Returns: s1>s2; >0 s1==s2; 0 s1<s2; <0
|
---|
8 | =============================================================================
|
---|
9 | */
|
---|
10 |
|
---|
11 | #include "ram.h"
|
---|
12 |
|
---|
13 | int16_t strncmp(int8_t *s1, int8_t *s2, int16_t n)
|
---|
14 | {
|
---|
15 | if (s1 == s2)
|
---|
16 | return(0);
|
---|
17 |
|
---|
18 | while ((--n >= 0) && (*s1 == *s2++))
|
---|
19 | if(*s1++ == '\0')
|
---|
20 | return(0);
|
---|
21 |
|
---|
22 | return((n < 0) ? 0 : (int16_t)(*s1 - *--s2));
|
---|
23 | }
|
---|
24 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.