Changeset 28ecadb in mainline for kernel/generic/src/lib/func.c
- Timestamp:
- 2006-09-22T21:44:54Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5d684e4
- Parents:
- 16529d5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/lib/func.c
r16529d5 r28ecadb 101 101 * Do a char-by-char comparison of two NULL terminated strings. 102 102 * The strings are considered equal iff they consist of the same 103 * characters on the minimum of their lengths. 104 * 105 * @param src First string to compare. 106 * @param dst Second string to compare. 107 * 108 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. 109 * 110 */ 111 int strcmp(const char *src, const char *dst) 112 { 113 for (; *src && *dst; src++, dst++) { 114 if (*src < *dst) 115 return -1; 116 if (*src > *dst) 117 return 1; 118 } 119 if (*src == *dst) 120 return 0; 121 if (!*src) 122 return -1; 123 return 1; 124 } 125 126 127 /** Compare two NULL terminated strings 128 * 129 * Do a char-by-char comparison of two NULL terminated strings. 130 * The strings are considered equal iff they consist of the same 103 131 * characters on the minimum of their lengths and specified maximal 104 132 * length. … … 115 143 int i; 116 144 117 i = 0; 118 for (;*src && *dst && i < len;src++,dst++,i++) { 145 for (i = 0; *src && *dst && i < len; src++, dst++, i++) { 119 146 if (*src < *dst) 120 147 return -1; … … 128 155 return 1; 129 156 } 157 158 130 159 131 160 /** Copy NULL terminated string.
Note:
See TracChangeset
for help on using the changeset viewer.