Skip to content

Commit a5ce10c

Browse files
ZERICO2005adriweb
authored andcommitted
changed boot_sprintf.h to ti/sprintf.h and fixed the documentation
1 parent 52a64af commit a5ce10c

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

docs/headers/ti/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ whoever in the community first discovered something gave it a name following the
2323
info
2424
python
2525
real
26+
sprintf
2627
tokens
2728
ui
2829
vars

docs/headers/boot_sprintf.rst renamed to docs/headers/ti/sprintf.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
.. _boot_sprintf:
1+
.. _sprintf_h:
22

3-
boot_sprintf
3+
ti/sprintf.h
44
======================
55

66
.. code-block:: c
77
8-
#include <boot_sprintf.h>
8+
#include <ti/sprintf.h>
99
1010
The OS comes with an implementation of ANSI C89 `sprintf`, which can reduce the size of a program by ~8 KiB. However, it is very limited in functionality. It does not support width specifiers, and it won't accept :code:`long` or :code:`float` arguments.
1111

12-
The following type specifiers are supported :code:`%s %c %d %i %u %o %x %X %p %n`, alongside the flags :code:`-+ #0*` in addition to the width field.
12+
boot_sprintf
13+
----------------------------
14+
15+
The following type specifiers are supported :code:`%s %c %d %i %u %o %x %X %p %n`, alongside the flags :code:`-+#0*` in addition to the space flag and width field.
1316

1417
All length modifiers :code:`hh h l ll j z t L` and floating point specifiers :code:`%f %g %e %a` are **not** supported.
1518

1619
Additionally, each individual argument will write no more than 255 characters each. This means that any strings written with :code:`%s` will be truncated after 255 characters.
1720

18-
The :code:`<boot_sprintf.h>` header provides `boot_sprintf`. `boot_snprintf` and `boot_asprintf` are also provided as macros
21+
The :code:`<ti/sprintf.h>` provides `boot_sprintf`, in addition to `boot_snprintf` and `boot_asprintf` as macros.
1922

2023
.. code-block:: c
2124
2225
int boot_sprintf(char *restrict buffer, const char *restrict format, ...)
2326
24-
int boot_snprintf(char *buffer, size_t count, const char *restrict format, ...)
27+
int boot_snprintf(char *restrict buffer, size_t count, const char *restrict format, ...)
2528
2629
int boot_asprintf(char **restrict p_buffer, const char *restrict format, ...)
2730
@@ -30,7 +33,7 @@ Because the OS does not provide `vsprintf`, `boot_snprintf` and `boot_asprintf`
3033
replacing printf functions
3134
----------------------------
3235

33-
To disable all other printf functions with `boot_sprintf`, `boot_snprintf`, and `boot_asprintf`, add the following line to the Makefile. More information `here <https://ce-programming.github.io/toolchain/static/printf.html>`
36+
To disable all other printf functions with `boot_sprintf`, `boot_snprintf`, and `boot_asprintf`, add the following line to the Makefile. More information :ref:`here <printf>`.
3437

3538
.. code-block:: makefile
3639
@@ -53,6 +56,7 @@ boot_snprintf
5356
The truncating behavior of C99 `snprintf` can be replicated with `boot_asprintf`
5457

5558
.. code-block:: c
59+
5660
char buf[20];
5761
char* temp;
5862
boot_asprintf(&temp, format, ...);
@@ -67,6 +71,7 @@ printf and fprintf
6771
`printf` and `fprintf` can be replicated by using `boot_asprintf` and `fputs`
6872

6973
.. code-block:: c
74+
7075
char* output;
7176
boot_asprintf(&output, format, ...);
7277
if (output != NULL) {

docs/static/printf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ However, they contribute around 8 KiB to the resultant program.
1111
It is highly recommended to not use `printf` and related functions at all because of this.
1212
If you insist on using these functions, this page details how to do so in the next section.
1313

14-
Alternatively, a limited `sprintf` (no `long` or `float` support) implementation is baked into the OS which doesn't add any extra size to the resultant program. See the dedicated page for more information `<boot_sprintf.h> <https://ce-programming.github.io/toolchain/headers/boot_sprintf.html>`_.
14+
Alternatively, a limited `sprintf` (no `long` or `float` support) implementation is baked into the OS which doesn't add any extra size to the resultant program. See the dedicated page for more information :ref:`ti/sprintf.h <sprintf_h>`.
1515
To disable all other printf functions and use this `sprintf` implementation, add the following line to the Makefile:
1616

1717
.. code-block:: makefile

src/ce/include/boot_sprintf.h renamed to src/ce/include/ti/sprintf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef CE_SPRINTF_H
2-
#define CE_SPRINTF_H
1+
#ifndef TI_SPRINTF_H
2+
#define TI_SPRINTF_H
33

44
#include <stddef.h>
55
#include <stdlib.h>
@@ -60,4 +60,4 @@ int boot_sprintf(
6060
}
6161
#endif
6262

63-
#endif /* CE_SPRINTF_H */
63+
#endif /* TI_SPRINTF_H */

src/libc/errno_str.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <errno.h>
33
#include <stdio.h>
44
#include <string.h>
5-
#include <boot_sprintf.h>
5+
#include <ti/sprintf.h>
66

77
static char const * const errno_strings[] = {
88
"no error",

src/libc/include/stdio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <stdarg.h>
66

77
#ifndef HAS_PRINTF
8-
# include <boot_sprintf.h>
8+
# include <ti/sprintf.h>
99
#endif /* HAS_PRINTF */
1010

1111
#ifdef HAS_CUSTOM_FILE

test/standalone/asprintf_fprintf/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <ti/screen.h>
66
#include <ti/getcsc.h>
77
#include <sys/util.h>
8-
#include <boot_sprintf.h>
8+
#include <ti/sprintf.h>
99
#include <ctype.h>
1010

1111
/**

0 commit comments

Comments
 (0)