Rev 1604 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1604 | Rev 1702 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ |
28 | */ |
29 | 29 | ||
- | 30 | /** @addtogroup generic |
|
- | 31 | * @{ |
|
- | 32 | */ |
|
30 | /** |
33 | /** |
31 | * @file print.c |
34 | * @file |
32 | * @brief Printing functions. |
35 | * @brief Printing functions. |
33 | */ |
36 | */ |
34 | 37 | ||
35 | #include <printf/printf_core.h> |
38 | #include <printf/printf_core.h> |
36 | #include <putchar.h> |
39 | #include <putchar.h> |
Line 98... | Line 101... | ||
98 | 101 | ||
99 | /** Print count chars from buffer without adding newline |
102 | /** Print count chars from buffer without adding newline |
100 | * @param buf Buffer with size at least count bytes - NULL pointer NOT allowed! |
103 | * @param buf Buffer with size at least count bytes - NULL pointer NOT allowed! |
101 | * @param count |
104 | * @param count |
102 | * @param ps output method and its data |
105 | * @param ps output method and its data |
103 | * @return number or printed characters |
106 | * @return number of printed characters |
104 | */ |
107 | */ |
105 | static int printf_putnchars(const char * buf, size_t count, struct printf_spec *ps) |
108 | static int printf_putnchars(const char * buf, size_t count, struct printf_spec *ps) |
106 | { |
109 | { |
107 | return ps->write((void *)buf, count, ps->data); |
110 | return ps->write((void *)buf, count, ps->data); |
108 | } |
111 | } |
109 | 112 | ||
110 | /** Print string without added newline |
113 | /** Print string without added newline |
111 | * @param str string to print |
114 | * @param str string to print |
112 | * @param ps write function specification and support data |
115 | * @param ps write function specification and support data |
113 | * @return number or printed characters |
116 | * @return number of printed characters |
114 | */ |
117 | */ |
115 | static int printf_putstr(const char * str, struct printf_spec *ps) |
118 | static int printf_putstr(const char * str, struct printf_spec *ps) |
116 | { |
119 | { |
117 | size_t count; |
120 | size_t count; |
118 | 121 | ||
Line 126... | Line 129... | ||
126 | } |
129 | } |
127 | 130 | ||
128 | /** Print one character to output |
131 | /** Print one character to output |
129 | * @param c one character |
132 | * @param c one character |
130 | * @param ps output method |
133 | * @param ps output method |
131 | * @return number or printed characters |
134 | * @return number of printed characters |
132 | */ |
135 | */ |
133 | static int printf_putchar(int c, struct printf_spec *ps) |
136 | static int printf_putchar(int c, struct printf_spec *ps) |
134 | { |
137 | { |
135 | unsigned char ch = c; |
138 | unsigned char ch = c; |
136 | 139 | ||
Line 147... | Line 150... | ||
147 | { |
150 | { |
148 | int counter = 0; |
151 | int counter = 0; |
149 | 152 | ||
150 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
153 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
151 | while (--width > 0) { /* one space is consumed by character itself hence predecrement */ |
154 | while (--width > 0) { /* one space is consumed by character itself hence predecrement */ |
152 | /* FIXME: painful slow */ |
- | |
153 | if (printf_putchar(' ', ps) > 0) |
155 | if (printf_putchar(' ', ps) > 0) |
154 | ++counter; |
156 | ++counter; |
155 | } |
157 | } |
156 | } |
158 | } |
157 | 159 | ||
Line 714... | Line 716... | ||
714 | interrupts_restore(irqpri); |
716 | interrupts_restore(irqpri); |
715 | 717 | ||
716 | return counter; |
718 | return counter; |
717 | } |
719 | } |
718 | 720 | ||
- | 721 | ||
- | 722 | /** @} |
|
- | 723 | */ |
|
- | 724 |