Changeset 8e893ae in mainline
- Timestamp:
- 2012-04-07T17:49:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c7afcba7
- Parents:
- a4a0f1d
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/generic/src/str.c
ra4a0f1d r8e893ae 100 100 #include <str.h> 101 101 #include <errno.h> 102 103 /** Check the condition if wchar_t is signed */ 104 #ifdef WCHAR_IS_UNSIGNED 105 #define WCHAR_SIGNED_CHECK(cond) (true) 106 #else 107 #define WCHAR_SIGNED_CHECK(cond) (cond) 108 #endif 102 109 103 110 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 198 205 * code was invalid. 199 206 */ 200 int chr_encode( wchar_t ch, char *str, size_t *offset, size_t size)207 int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t size) 201 208 { 202 209 if (*offset >= size) … … 325 332 bool ascii_check(wchar_t ch) 326 333 { 327 if ( (ch >= 0) && (ch <= 127))334 if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127)) 328 335 return true; 329 336 … … 338 345 bool chr_check(wchar_t ch) 339 346 { 340 if ( (ch >= 0) && (ch <= 1114111))347 if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111)) 341 348 return true; 342 349 -
kernel/generic/src/lib/str.c
ra4a0f1d r8e893ae 111 111 #include <debug.h> 112 112 #include <macros.h> 113 114 /** Check the condition if wchar_t is signed */ 115 #ifdef WCHAR_IS_UNSIGNED 116 #define WCHAR_SIGNED_CHECK(cond) (true) 117 #else 118 #define WCHAR_SIGNED_CHECK(cond) (cond) 119 #endif 113 120 114 121 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 206 213 * 207 214 * @return EOK if the character was encoded successfully, EOVERFLOW if there 208 * 209 * 210 */ 211 int chr_encode( wchar_t ch, char *str, size_t *offset, size_t size)215 * was not enough space in the output buffer or EINVAL if the character 216 * code was invalid. 217 */ 218 int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t size) 212 219 { 213 220 if (*offset >= size) … … 427 434 bool ascii_check(wchar_t ch) 428 435 { 429 if ( (ch >= 0) && (ch <= 127))436 if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127)) 430 437 return true; 431 438 … … 440 447 bool chr_check(wchar_t ch) 441 448 { 442 if ( (ch >= 0) && (ch <= 1114111))449 if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111)) 443 450 return true; 444 451 -
uspace/lib/c/generic/str.c
ra4a0f1d r8e893ae 46 46 #include <mem.h> 47 47 #include <str.h> 48 49 /** Check the condition if wchar_t is signed */ 50 #ifdef WCHAR_IS_UNSIGNED 51 #define WCHAR_SIGNED_CHECK(cond) (true) 52 #else 53 #define WCHAR_SIGNED_CHECK(cond) (cond) 54 #endif 48 55 49 56 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 399 406 bool ascii_check(wchar_t ch) 400 407 { 401 if ( (ch >= 0) && (ch <= 127))408 if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127)) 402 409 return true; 403 410 … … 412 419 bool chr_check(wchar_t ch) 413 420 { 414 if ( (ch >= 0) && (ch <= 1114111))421 if (WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111)) 415 422 return true; 416 423 … … 513 520 * @param count Size of the destination buffer (must be > 0). 514 521 * @param src Source string. 522 * 515 523 */ 516 524 void str_cpy(char *dest, size_t size, const char *src) … … 545 553 * @param src Source string. 546 554 * @param n Maximum number of bytes to read from @a src. 555 * 547 556 */ 548 557 void str_ncpy(char *dest, size_t size, const char *src, size_t n)
Note:
See TracChangeset
for help on using the changeset viewer.