File tree Expand file tree Collapse file tree
test/standalone/custom_printf Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "transfer_files" : [
3+ " bin/DEMO.8xp"
4+ ],
5+ "target" : {
6+ "name" : " DEMO" ,
7+ "isASM" : true
8+ },
9+ "sequence" : [
10+ " action|launch" ,
11+ " delay|1000" ,
12+ " hashWait|1" ,
13+ " key|enter" ,
14+ " delay|400" ,
15+ " hashWait|2"
16+ ],
17+ "hashes" : {
18+ "1" : {
19+ "description" : " %s should print ALL CAPS with the custom printf" ,
20+ "start" : " vram_start" ,
21+ "size" : " vram_16_size" ,
22+ "expected_CRCs" : [
23+ " F449EF83"
24+ ]
25+ },
26+ "2" : {
27+ "description" : " Exit" ,
28+ "start" : " vram_start" ,
29+ "size" : " vram_16_size" ,
30+ "expected_CRCs" : [
31+ " FFAF89BA" ,
32+ " 101734A5" ,
33+ " 9DA19F44" ,
34+ " A32840C8" ,
35+ " 349F4775"
36+ ]
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ # ----------------------------
2+ # Makefile Options
3+ # ----------------------------
4+
5+ NAME = DEMO
6+ ICON = icon.png
7+ DESCRIPTION = "CE C Toolchain Demo"
8+ COMPRESSED = NO
9+ ARCHIVED = NO
10+
11+ CFLAGS = -Wall -Wextra -Wshadow -Oz
12+ CXXFLAGS = -Wall -Wextra -Wshadow -Oz
13+
14+ PREFER_OS_LIBC = NO
15+ PREFER_OS_CRT = NO
16+ HAS_PRINTF = NO
17+
18+ # ----------------------------
19+
20+ include $(shell cedev-config --makefile)
Original file line number Diff line number Diff line change 1+ #include <stdarg.h>
2+ #include <stdio.h>
3+ #include <ctype.h>
4+
5+ // custom version of sprintf where %s is all uppercase
6+ int sprintf (char * buffer , const char * __restrict format , ...) {
7+ va_list args ;
8+ va_start (args , format );
9+
10+ int count = 0 ;
11+ const char * ptr = format ;
12+ while (* ptr != '\0' ) {
13+ if (* ptr == '%' && * (ptr + 1 ) == 's' ) {
14+ const char * str = va_arg (args , const char * );
15+ while (* str != '\0' ) {
16+ * buffer = toupper (* str );
17+ buffer ++ ;
18+ str ++ ;
19+ count ++ ;
20+ }
21+ // consume %s
22+ ptr += 2 ;
23+ continue ;
24+ }
25+ * buffer = * ptr ;
26+ buffer ++ ;
27+ ptr ++ ;
28+ count ++ ;
29+ }
30+ * buffer ++ = '\0' ;
31+
32+ va_end (args );
33+ return count ;
34+ }
Original file line number Diff line number Diff line change 1+ #include <ti/screen.h>
2+ #include <ti/getcsc.h>
3+ #include <ti/sprintf.h>
4+ #include <stdio.h>
5+
6+ int main (void ) {
7+ char buf [50 ];
8+ os_ClrHome ();
9+
10+ // test that we are using a custom printf and not the real one
11+ const char * str = "printf" ;
12+ int result = sprintf (buf , "custom %s!" , str );
13+ puts (buf );
14+ boot_sprintf (buf , "returned %d" , result );
15+ puts (buf );
16+
17+ while (!os_GetCSC ());
18+
19+ return 0 ;
20+ }
You can’t perform that action at this time.
0 commit comments