-
Notifications
You must be signed in to change notification settings - Fork 683
Use port APIs instead of printf in non-debug code #956
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
Conversation
0, | ||
JERRY_BITSINBYTE); | ||
|
||
printf ("\\u%02x%02x", byte_high, byte_low); | ||
jerry_port_putchar (byte_high); | ||
jerry_port_putchar (byte_low); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
working on fixing this (see comments in #945)
d5b3840
to
79ce295
Compare
|
||
jerry_port_putchar ('\\'); | ||
jerry_port_putchar ('u'); | ||
jerry_port_putchar (out_buf[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love this, but it's the simplest way to achieve what I am trying to achieve without adding more port APIs.
79ce295
to
f471c2b
Compare
I think that's all the review comments |
91f49c2
to
b40b489
Compare
jerry_port_putchar ('u'); | ||
// print high byte | ||
char out_buf[3]; | ||
itoa(byte_high, out_buf, 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like neither itoa nor sprintf is implemented in jerry-libc. What's the recommended solution here, I would happily add an itoa implementation.
b40b489
to
515e889
Compare
Added a simple implementation of itoa. I don't think the end result is super elegant, but I couldn't come up with anything better that didn't involve more port APIs and pulling in an implementation of sprintf. |
* Convert an integer to a string using base and write the result to buffer. | ||
*/ | ||
char * | ||
itoa (int value, char *buffer, int base) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is not quite complete. It doesn't add the -
sign for negative numbers and only accepts bases <= 16; but it is good enough for this use case.
2b8f5c8
to
2194f0e
Compare
JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com
2194f0e
to
ab4c3a5
Compare
Let's close this PR, because it is inactive in a long time and #1205 made this change. |
JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com