Changes in uspace/lib/c/generic/io/vsnprintf.c [9d58539:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/vsnprintf.c
r9d58539 ra35b458 65 65 { 66 66 size_t left = data->size - data->len; 67 67 68 68 if (left == 0) 69 69 return ((int) size); 70 70 71 71 if (left == 1) { 72 72 /* We have only one free byte left in buffer … … 77 77 return ((int) size); 78 78 } 79 79 80 80 if (left <= size) { 81 81 /* We do not have enough space for the whole string … … 84 84 */ 85 85 size_t index = 0; 86 86 87 87 while (index < size) { 88 88 wchar_t uc = str_decode(str, &index, size); 89 89 90 90 if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK) 91 91 break; 92 92 } 93 93 94 94 /* Put trailing zero at end, but not count it 95 95 * into data->len so it could be rewritten next time 96 96 */ 97 97 data->dst[data->len] = 0; 98 98 99 99 return ((int) size); 100 100 } 101 101 102 102 /* Buffer is big enough to print the whole string */ 103 103 memcpy((void *)(data->dst + data->len), (void *) str, size); 104 104 data->len += size; 105 105 106 106 /* Put trailing zero at end, but not count it 107 107 * into data->len so it could be rewritten next time 108 108 */ 109 109 data->dst[data->len] = 0; 110 110 111 111 return ((int) size); 112 112 } … … 132 132 { 133 133 size_t index = 0; 134 134 135 135 while (index < (size / sizeof(wchar_t))) { 136 136 size_t left = data->size - data->len; 137 137 138 138 if (left == 0) 139 139 return ((int) size); 140 140 141 141 if (left == 1) { 142 142 /* We have only one free byte left in buffer … … 147 147 return ((int) size); 148 148 } 149 149 150 150 if (chr_encode(str[index], data->dst, &data->len, data->size - 1) != EOK) 151 151 break; 152 152 153 153 index++; 154 154 } 155 155 156 156 /* Put trailing zero at end, but not count it 157 157 * into data->len so it could be rewritten next time 158 158 */ 159 159 data->dst[data->len] = 0; 160 160 161 161 return ((int) size); 162 162 } … … 174 174 &data 175 175 }; 176 176 177 177 /* Print 0 at end of string - fix the case that nothing will be printed */ 178 178 if (size > 0) 179 179 str[0] = 0; 180 180 181 181 /* vsnprintf_write ensures that str will be terminated by zero. */ 182 182 return printf_core(fmt, &ps, ap);
Note:
See TracChangeset
for help on using the changeset viewer.