Changeset d09f84e6 in mainline
- Timestamp:
- 2009-04-02T19:59:22Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 82bb9c1
- Parents:
- 06b785f
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/string.h
r06b785f rd09f84e6 43 43 44 44 extern wchar_t chr_decode(const char *, size_t *, size_t); 45 extern boolchr_encode(const wchar_t, char *, size_t *, size_t);45 extern int chr_encode(const wchar_t, char *, size_t *, size_t); 46 46 47 47 extern size_t str_size(const char *str); -
kernel/generic/src/lib/string.c
r06b785f rd09f84e6 41 41 #include <arch/asm.h> 42 42 #include <arch.h> 43 #include <errno.h> 43 44 #include <console/kconsole.h> 44 45 … … 141 142 * @param sz Size of the output buffer. 142 143 * 143 * @return True if the character was encoded successfully or falseif there144 * was not enough space in the output buffer or the character code145 * was invalid.146 */ 147 boolchr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz)144 * @return EOK if the character was encoded successfully, EOVERFLOW if there 145 * was not enough space in the output buffer or EINVAL if the character 146 * code was invalid. 147 */ 148 int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz) 148 149 { 149 150 uint32_t cc; /* Unsigned version of ch. */ … … 154 155 155 156 if (*offset >= sz) 156 return false;157 return EOVERFLOW; 157 158 158 159 if (ch < 0) 159 return false;160 return EINVAL; 160 161 161 162 /* Bit operations should only be done on unsigned numbers. */ … … 177 178 } else { 178 179 /* Codes longer than 21 bits are not supported. */ 179 return false;180 return EINVAL; 180 181 } 181 182 182 183 /* Check for available space in buffer. */ 183 184 if (*offset + cbytes >= sz) 184 return false;185 return EOVERFLOW; 185 186 186 187 /* Encode continuation bytes. */ … … 196 197 *offset += (1 + cbytes); 197 198 198 return true;199 return EOK; 199 200 } 200 201 -
kernel/generic/src/printf/vsnprintf.c
r06b785f rd09f84e6 37 37 #include <string.h> 38 38 #include <memstr.h> 39 #include <errno.h> 39 40 40 41 typedef struct { … … 87 88 wchar_t uc = chr_decode(str, &index, size); 88 89 89 if ( !chr_encode(uc, data->dst, &data->len, data->size - 1))90 if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK) 90 91 break; 91 92 } … … 147 148 } 148 149 149 if ( !chr_encode(str[index], data->dst, &data->len, data->size - 1))150 if (chr_encode(str[index], data->dst, &data->len, data->size - 1) != EOK) 150 151 break; 151 152
Note:
See TracChangeset
for help on using the changeset viewer.