anchao opened a new pull request, #21340:
URL: https://github.com/apache/nuttx/pull/21340

   ```markdown
   ## Summary
   
   Refactor `vsprintf_internal()` in `libs/libc/stream/lib_libvsprintf.c` by 
splitting major conversion paths into focused helpers, while keeping the 
existing formatting behavior unchanged.
   
   The changes include:
   - batch floating-point mantissa digit output to avoid per-character stream 
callbacks
   - split common field padding/output logic
   - split character and wide-string output handling
   - split integer prefix/sign/padding/digit emission
   - split NaN/Inf floating-point output handling
   - split floating-point prefix, fixed-format, exponent-format, and format 
setup logic
   - move the complete `CONFIG_LIBC_FLOATINGPOINT` conversion path out of 
`vsprintf_internal()`
   - move `CONFIG_LIBC_PRINT_EXTENSION` `%p*` handling into a dedicated helper
   - split numbered-argument validation/type recording into a helper
   - share signed/unsigned integer argument fetching and size narrowing logic
   - add NuttX-style helper comments and use `inline_function` for the 
extracted helpers
   
   This keeps `vsprintf_internal()` focused on parsing and dispatching 
conversions, making the implementation easier to review and maintain.
   
   ## ROM size impact
   
   Measured with the same `.config`, comparing:
   - before: `e5a5f85dd863481a418a5268c9cb75e6d6418296^`
   - after: current HEAD including this series
   
   `size nuttx` result:
   
   | Item                | Before    | After     | Delta         |
   |---------------------|-----------|-----------|---------------|
   | text                | 1,408,364 | 1,408,412 | +48           |
   | data                | 273,936   | 273,936   | 0             |
   | bss                 | 189,536   | 189,568   | +32           |
   | dec                 | 1,871,836 | 1,871,916 | +80           |
   | ROM (`text + data`) | 1,682,300 | 1,682,348 | **+48 bytes** |
   | RAM (`data + bss`)  | 463,472   | 463,504   | +32 bytes     |
   
   ROM increases by **48 bytes**.
   
   ## Validation
   
   Style checks:
   ```sh
   tools/nxstyle libs/libc/stream/lib_libvsprintf.c
   git diff HEAD~6..HEAD -- libs/libc/stream/lib_libvsprintf.c | 
tools/checkpatch.sh -
   git diff --check HEAD~6..HEAD
   ```
   
   Result:
   - nxstyle: pass
   - checkpatch: pass
   - diff --check: pass
   
   Build coverage was also checked with the relevant Kconfig variants:
   
   1. Minimal printf path
   ```
   CONFIG_LIBC_NUMBERED_ARGS=n
   CONFIG_LIBC_FLOATINGPOINT=n
   CONFIG_LIBC_LOCALE=n
   CONFIG_LIBC_PRINT_EXTENSION=n
   CONFIG_ALLSYMS=n
   ```
   
   2. Floating-point / numbered args / locale / print extension enabled
   ```
   CONFIG_LIBC_NUMBERED_ARGS=y
   CONFIG_LIBC_FLOATINGPOINT=y
   CONFIG_LIBC_LOCALE=y
   CONFIG_LIBC_PRINT_EXTENSION=y
   CONFIG_ALLSYMS=n
   ```
   
   3. All symbols enabled, which selects print extensions
   ```
   CONFIG_LIBC_NUMBERED_ARGS=y
   CONFIG_LIBC_FLOATINGPOINT=y
   CONFIG_LIBC_LOCALE=y
   CONFIG_LIBC_PRINT_EXTENSION=y
   CONFIG_ALLSYMS=y
   ```
   
   4. Original local configuration
   
   Each variant was built with:
   ```sh
   make -j$(nproc)
   ```
   
   All variants completed successfully with no warning or error found in the 
build logs.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to