-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom printf version (Draft) #390
base: master
Are you sure you want to change the base?
Conversation
678d0a8
to
ead95a7
Compare
I'm sorta lukewarm on this. Prior experiences with homegrown (s)printf implementations have been a mixed bag. I mean, I get the appeal but complex features need to pay for themselves and I'm not quite seeing that. Is there one killer feature in particular that made you start on this? |
Hi @bnoordhuis I understand your concerns, I have invested a hefty amount of work into this, both for pleasure (I like to hack
As you have noticed, Fabrice and I tried hard to avoid depending on other packages to keep the project self contained and reliable. (*) Implementing |
@chqrlie I don't have much time this week and (maybe) next week (school holidays) but I'll try to review this at the first possible opportunity. |
Thank you. I have not plugged |
ead95a7
to
c31580b
Compare
3be1340
to
0b5f76d
Compare
- add `js_snprintf`, `js_printf`... to handle extra conversions: - support for wxx length modifier - support for `%b` and `%B` - `%oa` and `%#oa` to convert `JSAtom` values - `%ps` to convert `JSString` values - add `dbuf_vprintf_fun` replaceable `dbuf_printf` handler - change `JS_DumpString` to `JS_FormatString` to convert `JSSAtom` to quoted strings - change `JS_AtomGetStrRT` to `JS_FormatAtom` to convert `JSAtom` to strings - change `JS_AtomGetStr` to return direct string pointer for builtin atoms - remove `print_atom` - use custom conversions for trace messages and error messages - add support for `%b`, `%B` and `w` length modifier in `std.printf` - remove error handlers: `JS_ThrowTypeErrorAtom` and `JS_ThrowSyntaxErrorAtom` - add `is_lower_ascii()` and `to_lower_ascii()` - add floating point conversions and wide string conversions - unbreak compilation: prevent name collision on pow10 - minimize `vsnprintf` calls in `dbuf_vprintf_default`
0b5f76d
to
0536b42
Compare
Add custom printf version
js_snprintf
,js_printf
... to handle extra conversions:%b
and%B
%oa
and%#oa
to convertJSAtom
values%ps
to convertJSString
valuesdbuf_vprintf_fun
replaceabledbuf_printf
handlerJS_DumpString
toJS_FormatString
to convertJSSAtom
to quoted stringsJS_AtomGetStrRT
toJS_FormatAtom
to convertJSAtom
to stringsJS_AtomGetStr
to return direct string pointer for builtin atomsprint_atom
%b
,%B
andw
length modifier instd.printf
JS_ThrowTypeErrorAtom
andJS_ThrowSyntaxErrorAtom
is_lower_ascii()
andto_lower_ascii()
vsnprintf
calls indbuf_vprintf_default