@@ -140,8 +140,7 @@ char *memcpy(char *dest, char *src, int count)
140
140
return dest ;
141
141
}
142
142
143
- /*
144
- * set 10 digits (32bit) without div
143
+ /* set 10 digits (32bit) without div
145
144
*
146
145
* This function converts a given integer value to its string representation
147
146
* in base-10 without using division operations. The method involves calculating
@@ -192,14 +191,12 @@ void __str_base10(char *pb, int val)
192
191
void __str_base8 (char * pb , int val )
193
192
{
194
193
int c = INT_BUF_LEN - 1 , v ;
195
- /*
196
- * Because every 3 binary digits can be converted
197
- * to 1 octal digit, here performs the conversion
198
- * 10 times, derived from 32 divided by 3.
194
+
195
+ /* Because every 3 binary digits can be converted to 1 octal digit, here
196
+ * performs the conversion 10 times, derived from 32 divided by 3.
199
197
*
200
- * Finally, the remaining 2 bits are processed after
201
- * the loop.
202
- * */
198
+ * Finally, the remaining 2 bits are processed after the loop.
199
+ */
203
200
int times = (sizeof (int ) << 3 ) / 3 ;
204
201
for (int i = 0 ; i < times ; i ++ ) {
205
202
v = val & 0x7 ;
@@ -230,29 +227,24 @@ void __str_base16(char *pb, int val)
230
227
}
231
228
}
232
229
233
- /*
234
- * The specification of snprintf() is defined in C99 7.19.6.5,
235
- * and its behavior and return value should comply with the
236
- * following description:
237
- *
230
+ /* The specification of snprintf() is defined in C99 7.19.6.5, and its behavior
231
+ * and return value should comply with the following description:
238
232
* - If n is zero, nothing is written.
239
233
* - Writes at most n bytes, including the null character.
240
- * - On success, the return value should be the length of the
241
- * entire converted string even if n is insufficient to store it.
242
- *
243
- * Therefore, the following code defines a structure called fmtbuf_t
244
- * to implement formatted output conversion for the functions in the
245
- * printf() family.
234
+ * - On success, the return value should be the length of the entire converted
235
+ * string even if n is insufficient to store it.
246
236
*
237
+ * Thus, a structure fmtbuf_t is defined for formatted output conversion for
238
+ * the functions in the printf() family.
247
239
* @buf: the current position of the buffer.
248
240
* @n : the remaining space of the buffer.
249
- * @len: the number of characters that would have been written
250
- * had n been sufficiently large.
241
+ * @len: the number of characters that would have been written (excluding the
242
+ * null terminator) had n been sufficiently large.
251
243
*
252
- * Once a write operation is performed, buf and n will be
253
- * respectively incremented and decremented by the actual written
254
- * size if n is sufficient, and len must be incremented to store
255
- * the length of the entire converted string.
244
+ * Once a write operation is performed, buf and n will be respectively
245
+ * incremented and decremented by the actual written size if n is sufficient,
246
+ * and len must be incremented to store the length of the entire converted
247
+ * string.
256
248
*/
257
249
typedef struct {
258
250
char * buf ;
@@ -264,8 +256,7 @@ void __fmtbuf_write_char(fmtbuf_t *fmtbuf, int val)
264
256
{
265
257
fmtbuf -> len += 1 ;
266
258
267
- /*
268
- * Write the given character when n is greater than 1.
259
+ /* Write the given character when n is greater than 1.
269
260
* This means preserving one position for the null character.
270
261
*/
271
262
if (fmtbuf -> n <= 1 )
@@ -281,16 +272,14 @@ void __fmtbuf_write_str(fmtbuf_t *fmtbuf, char *str, int l)
281
272
{
282
273
fmtbuf -> len += l ;
283
274
284
- /*
285
- * Write the given string when n is greater than 1.
275
+ /* Write the given string when n is greater than 1.
286
276
* This means preserving one position for the null character.
287
277
*/
288
278
if (fmtbuf -> n <= 1 )
289
279
return ;
290
280
291
- /*
292
- * If the remaining space is less than the length of the string,
293
- * write only n - 1 bytes.
281
+ /* If the remaining space is less than the length of the string, write only
282
+ * n - 1 bytes.
294
283
*/
295
284
int sz = fmtbuf -> n - 1 ;
296
285
l = l <= sz ? l : sz ;
@@ -519,7 +508,8 @@ int fclose(FILE *stream)
519
508
}
520
509
521
510
/* Read a byte from file descriptor. So the return value is either in the range
522
- * of 0 to 127 for the character, or -1 on the end of file. */
511
+ * of 0 to 127 for the character, or -1 on the end of file.
512
+ */
523
513
int fgetc (FILE * stream )
524
514
{
525
515
int buf = 0 , r = __syscall (__syscall_read , stream , & buf , 1 );
0 commit comments