source:
buchla-68k/libsm/strcmp.c@
6262b5c
Last change on this file since 6262b5c was 6262b5c, checked in by , 7 years ago | |
---|---|
|
|
File size: 462 bytes |
Rev | Line | |
---|---|---|
[f40a309] | 1 | /* |
2 | ============================================================================= | |
3 | strcmp.c -- compare strings | |
4 | Version 2 -- 1987-06-15 | |
5 | ||
6 | Compare strings: s1>s2: >0 s1==s2: 0 s1<s2: <0 | |
7 | ============================================================================= | |
8 | */ | |
9 | ||
[6262b5c] | 10 | #include "all.h" |
11 | ||
[7258c6a] | 12 | int16_t strcmp(int8_t *s1, int8_t *s2) |
[f40a309] | 13 | { |
14 | if(s1 == s2) | |
15 | return(0); | |
16 | ||
17 | while(*s1 == *s2++) | |
18 | if(*s1++ == '\0') | |
19 | return(0); | |
20 | ||
[7258c6a] | 21 | return((int16_t)*s1 - (int16_t)*--s2); |
[f40a309] | 22 | } |
[7258c6a] | 23 |
Note:
See TracBrowser
for help on using the repository browser.