develop/ktcc: libc_scanf_add_double_parse #407
Open
DVZverrr
wants to merge 4 commits from
DVZverrr/kolibrios:libc_scanf_add_double_parse into main
pull from: DVZverrr/kolibrios:libc_scanf_add_double_parse
merge into: KolibriOS:main
KolibriOS:main
KolibriOS:wolf3d-launcher
KolibriOS:kterm-upload
KolibriOS:webview-3.99
KolibriOS:app/socketdbg_fix1
KolibriOS:menu-fix-welcome-path
KolibriOS:mousepos-add-own-tupfile
KolibriOS:webview-3.96
KolibriOS:hdaudio-add-ring-buffer-for-unsolicied-events
KolibriOS:ndn-v3.00.0011
KolibriOS:workflow-fuse
KolibriOS:rewrite-piano
KolibriOS:add-license-file-header-to-guide
KolibriOS:blocks-add-models
KolibriOS:shell-improve-cpuid
KolibriOS:rewrite_ide_drv
KolibriOS:add_usbother
KolibriOS:webview-3.91
KolibriOS:qrcodegen
KolibriOS:ci/update
KolibriOS:floppybird-window-fix
KolibriOS:laser-tank-fix-win-height
KolibriOS:improvement/commit-and-branch-styles
KolibriOS:docs/libs
Labels
Clear labels
C
Category/Applications
Category/Drivers
Category/General
Category/Kernel
Category/Libraries
Eolite
FASM
FS
GSoC
HardwareTested
HLL
Influence/Settings
Influence/Text/TYPO
IRCC
Kernel
Pay for the code
This issue in GSoC program
Kind
Breaking
Breaking change that won't be backward compatible
Kind
Bug
Something is not working
Kind
Build
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Security
This is security issue
Kind
Testing
Issue or pull request related to testing
Paid task
PR
Conflicts
PR conflicts with main
PR
Dependent
This PR is dependent on another PR
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
PR
Ready to merge
Pull request is ready for merge
PR
Request changes
Changes requested in pull request
PR
Review required
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: KolibriOS/kolibrios#407
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "DVZverrr/kolibrios:libc_scanf_add_double_parse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Добавлена возможность считывать float и double
ex:
scanf("%f", &float_val);
scanf("%lf", &double_val);
Попутно починен баг в функции itoa(...), который проявлялся при запуске libc_test из набора примеров.
82fa1f7525tof55d621fb7libc_scanf_add_double_parseto develop/ktcc: libc_scanf_add_double_parse@DVZverrr - Please note that the file path for
ktccwas recently changed with #425. This will conflict with your changes.f55d621fb7todb3e211f81Rebased to fresh main
Hi, @DVZverrr!
I reviewed this PR using AI and found a few problems that seems worth fixing before this PR will be merged. Not 100% sure about all of them, so please, check and provide some feedback.
Bugs:
%fignores field widthFile:
programs/develop/ktcc/libc.obj/source/stdio/vsscanf.cThe new floating-point path calls
strtod(q, ...)directly, so a format like%3fconsumes the full input number instead of at most 3 characters.Example:
Expected behavior: parse
123as the float and4as the integer.Current behavior:
%fconsumes1234, so the following%dfails.%Lfstores into the wrong destination typeFile:
programs/develop/ktcc/libc.obj/source/stdio/vsscanf.cThe
Lmodifier setsrank = rank_longlong, but the new code treats anyrank > rank_intasdouble *.For
%Lf, the caller provides along double *, not adouble *. Iflong doubleis wider thandoublein this toolchain, this writes an incomplete/corrupt value.Improvements:
Only
%fis implementedFile:
programs/develop/ktcc/libc.obj/source/stdio/vsscanf.cStandard
scanffloating-point conversions also include%e,%E,%g, and%G. Sincestrtod()already handles exponent notation, this should mostly be handled by dispatching those specifiers to the same floating-point parsing path.Floating-point width handling needs an explicit bounded input path
Unlike
strntoumax(),strtod()does not receive a width argument here. The implementation should limit the input manually when a field width is specified, for example by parsing from a temporary bounded buffer.The floating-point conversion dispatch should be broadened and clarified
Current code only has:
It should probably become something like:
Formatting of the new block does not match the surrounding style
The indentation around
if(rank > rank_int)and theva_arg()assignments is inconsistent with the rest ofvsscanf.c.%a/%Ashould be considered explicitlyIf this libc’s
strtod()does not support hexadecimal floating-point input, it is fine to leave%a/%Aunsupported in this PR. But that limitation should be intentional.To previous.
In progress
Support for %e %g is added
%G and %E are not relevant for scanf. These options are used for printf
Support for width for %f %e %g is added
Type mapping now:
%f -> float
%lf -> double
%Lf -> long double
Some related assertions have been added to libc_test.c as tests
P.S.
I've left %a and %A unsupported. I think it would be better to implement these options when needed.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.