@@ -140,8 +140,7 @@ char *memcpy(char *dest, char *src, int count)
140140 return dest ;
141141}
142142
143- /*
144- * set 10 digits (32bit) without div
143+ /* set 10 digits (32bit) without div
145144 *
146145 * This function converts a given integer value to its string representation
147146 * in base-10 without using division operations. The method involves calculating
@@ -192,14 +191,12 @@ void __str_base10(char *pb, int val)
192191void __str_base8 (char * pb , int val )
193192{
194193 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.
199197 *
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+ */
203200 int times = (sizeof (int ) << 3 ) / 3 ;
204201 for (int i = 0 ; i < times ; i ++ ) {
205202 v = val & 0x7 ;
@@ -230,29 +227,24 @@ void __str_base16(char *pb, int val)
230227 }
231228}
232229
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:
238232 * - If n is zero, nothing is written.
239233 * - 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.
246236 *
237+ * Thus, a structure fmtbuf_t is defined for formatted output conversion for
238+ * the functions in the printf() family.
247239 * @buf: the current position of the buffer.
248240 * @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.
251243 *
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.
256248 */
257249typedef struct {
258250 char * buf ;
@@ -264,8 +256,7 @@ void __fmtbuf_write_char(fmtbuf_t *fmtbuf, int val)
264256{
265257 fmtbuf -> len += 1 ;
266258
267- /*
268- * Write the given character when n is greater than 1.
259+ /* Write the given character when n is greater than 1.
269260 * This means preserving one position for the null character.
270261 */
271262 if (fmtbuf -> n <= 1 )
@@ -281,16 +272,14 @@ void __fmtbuf_write_str(fmtbuf_t *fmtbuf, char *str, int l)
281272{
282273 fmtbuf -> len += l ;
283274
284- /*
285- * Write the given string when n is greater than 1.
275+ /* Write the given string when n is greater than 1.
286276 * This means preserving one position for the null character.
287277 */
288278 if (fmtbuf -> n <= 1 )
289279 return ;
290280
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.
294283 */
295284 int sz = fmtbuf -> n - 1 ;
296285 l = l <= sz ? l : sz ;
@@ -519,7 +508,8 @@ int fclose(FILE *stream)
519508}
520509
521510/* 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+ */
523513int fgetc (FILE * stream )
524514{
525515 int buf = 0 , r = __syscall (__syscall_read , stream , & buf , 1 );
0 commit comments