Changeset c065743 in mainline for uspace/lib/c/generic/str.c
- Timestamp:
- 2011-08-24T21:16:13Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a5454cf
- Parents:
- ace588a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
race588a rc065743 1160 1160 str_ncpy(dest, size + 1, src, size); 1161 1161 return dest; 1162 }1163 1164 void str_reverse(char* begin, char* end)1165 {1166 char aux;1167 while(end>begin)1168 aux=*end, *end--=*begin, *begin++=aux;1169 }1170 1171 int size_t_str(size_t value, int base, char* str, size_t size)1172 {1173 static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";1174 char* wstr=str;1175 1176 if (size == 0)1177 return EINVAL;1178 if (base<2 || base>35) {1179 *str='\0';1180 return EINVAL;1181 }1182 1183 do {1184 *wstr++ = num[value % base];1185 if (--size == 0)1186 return EOVERFLOW;1187 } while(value /= base);1188 *wstr='\0';1189 1190 // Reverse string1191 str_reverse(str,wstr-1);1192 return EOK;1193 1162 } 1194 1163
Note:
See TracChangeset
for help on using the changeset viewer.