Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336661 - "%$S" does not work in System_sprintf
Summary: "%$S" does not work in System_sprintf
Status: CLOSED FIXED
Alias: None
Product: RTSC
Classification: Technology
Component: Runtime (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Sasha Slijepcevic CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 336776
  Show dependency tree
 
Reported: 2011-02-08 17:08 EST by Todd Mullanix CLA
Modified: 2011-11-09 18:56 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Todd Mullanix CLA 2011-02-08 17:08:55 EST
I’m seeing a problem with System_sprintf. I have SysStd as the provider. When I try to use %$S, the printf works, but sprintf does not. Below is the output of the different test cases. Note: the sprintf cases’ output is the memory window for the string (in char and 8-bit signed decimal). I initialized the strings to all ‘4’s to make it easier to see…


System_printf("Test [%$S]\n", "ab<%d>cd", 10);

Output: Test [ab<10>cd]
 

System_sprintf(tempStr1, "Test [%$S]\n", "ab<%d>cd", 10);

tempStr1 char: Test.[]..10>cd.44

tempStr1 decimal: 84 101 115 116 32 91 93 10 0 49 48 62 99 100 0 52 52

                   T  e   s   t <sp> [ ]  lf \0 1  0 >  c   d  \0 4  4 

 

System_asprintf was the same as System_sprintf

I’ve tried this on 3.20.03.63 and 3.20.05.76.  The %$S is used in Log_error/warning/info calls. My new logger is using System_sprintf to help decode into a string and it is messed up for the Log_error/warning/info calls.
Comment 1 Sasha Slijepcevic CLA 2011-02-08 17:20:56 EST
For the $S specifier, System_printfExtend__I invokes System_doPrint, which adds characters to the buffer but does not advance the buffer pointer. System_printfExtend__I does not do it either, so after the argument consumed by the specifier is added to the buffer, the rest of the original format string is added over the argument instead after it.
Comment 2 Sasha Slijepcevic CLA 2011-02-09 20:01:42 EST
- fixed in xdc-w25
Added statements that update the buffer pointer after the string argument replaces $S conversion specifier.
Comment 3 Dave Russo CLA 2011-11-09 18:56:00 EST
closing "ancient" resolved bugs