Rev 885 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 885 | Rev 886 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | // Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist nicht von der Lizenz für den MikroKopter-Teil unterstellt |
1 | // Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist nicht von der Lizenz für den MikroKopter-Teil unterstellt |
Line 2... | Line 2... | ||
2 | 2 | ||
3 | /* |
3 | /* |
Line 4... | Line 4... | ||
4 | Copyright (C) 1993 Free Software Foundation |
4 | Copyright (C) 1993 Free Software Foundation |
5 | 5 | ||
6 | This file is part of the GNU IO Library. This library is free |
6 | This file is part of the GNU IO Library. This library is free |
Line 84... | Line 84... | ||
84 | #include <stdarg.h> |
84 | #include <stdarg.h> |
85 | #else |
85 | #else |
86 | #include <varargs.h> |
86 | #include <varargs.h> |
87 | #endif |
87 | #endif |
Line -... | Line 88... | ||
- | 88 | ||
- | 89 | #include "old_macros.h" |
|
- | 90 | #include "printf_P.h" |
|
88 | 91 | #include "menu.h" |
|
Line 89... | Line 92... | ||
89 | #include "main.h" |
92 | #include "uart.h" |
90 | 93 | ||
Line 98... | Line 101... | ||
98 | if(PrintZiel == OUT_LCD) { DisplayBuff[DispPtr++] = zeichen; return(1);} |
101 | if(PrintZiel == OUT_LCD) { DisplayBuff[DispPtr++] = zeichen; return(1);} |
99 | else return(uart_putchar(zeichen)); |
102 | else return(uart_putchar(zeichen)); |
100 | } |
103 | } |
Line 101... | Line 104... | ||
101 | 104 | ||
102 | 105 | ||
103 | void PRINT(const char * ptr, unsigned int len) |
106 | void PRINT(const char * ptr, unsigned int len) |
104 | { |
107 | { |
105 | for(;len;len--) Putchar(*ptr++); |
108 | for(;len;len--) Putchar(*ptr++); |
106 | } |
109 | } |
107 | 110 | ||
108 | void PRINTP(const char * ptr, unsigned int len) |
111 | void PRINTP(const char * ptr, unsigned int len) |
109 | { |
112 | { |
Line 110... | Line 113... | ||
110 | for(;len;len--) Putchar(pgm_read_byte(ptr++)); |
113 | for(;len;len--) Putchar(pgm_read_byte(ptr++)); |
111 | } |
114 | } |
112 | 115 | ||
113 | void PAD_SP(signed char howmany) |
116 | void PAD_SP(signed char howmany) |
Line 114... | Line 117... | ||
114 | { |
117 | { |
115 | for(;howmany>0;howmany--) Putchar(' '); |
118 | for(;howmany>0;howmany--) Putchar(' '); |
116 | } |
119 | } |
117 | 120 | ||
Line 118... | Line 121... | ||
118 | void PAD_0(signed char howmany) |
121 | void PAD_0(signed char howmany) |
Line 167... | Line 170... | ||
167 | char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ |
170 | char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ |
168 | char ox[2]; /* space for 0x hex-prefix */ |
171 | char ox[2]; /* space for 0x hex-prefix */ |
Line 169... | Line 172... | ||
169 | 172 | ||
170 | PrintZiel = ziel; // bestimmt, LCD oder UART |
173 | PrintZiel = ziel; // bestimmt, LCD oder UART |
171 | va_start(ap, fmt0); |
174 | va_start(ap, fmt0); |
172 | 175 | ||
Line 173... | Line 176... | ||
173 | fmt = fmt0; |
176 | fmt = fmt0; |
174 | 177 | ||
175 | /* |
178 | /* |
Line 204... | Line 207... | ||
204 | register unsigned int _d; |
207 | register unsigned int _d; |
205 | _d=va_arg(ap, unsigned int); |
208 | _d=va_arg(ap, unsigned int); |
206 | _ulong = flags&SHORTINT ? (unsigned long)(unsigned short)_d : (unsigned long)_d; |
209 | _ulong = flags&SHORTINT ? (unsigned long)(unsigned short)_d : (unsigned long)_d; |
207 | } |
210 | } |
208 | } |
211 | } |
209 | 212 | ||
210 | #ifndef LIGHTPRINTF |
213 | #ifndef LIGHTPRINTF |
211 | if(ch==' ') { |
214 | if(ch==' ') { |
212 | /* |
215 | /* |
213 | * ``If the space and + flags both appear, the space |
216 | * ``If the space and + flags both appear, the space |
214 | * flag will be ignored.'' |
217 | * flag will be ignored.'' |
Line 288... | Line 291... | ||
288 | } else { |
291 | } else { |
289 | register int _d; |
292 | register int _d; |
290 | _d=va_arg(ap, int); |
293 | _d=va_arg(ap, int); |
291 | _ulong = flags&SHORTINT ? (long)(short)_d : (long)_d; |
294 | _ulong = flags&SHORTINT ? (long)(short)_d : (long)_d; |
292 | } |
295 | } |
293 | 296 | ||
294 | if ((long)_ulong < 0) { |
297 | if ((long)_ulong < 0) { |
295 | _ulong = -_ulong; |
298 | _ulong = -_ulong; |
296 | sign = '-'; |
299 | sign = '-'; |
297 | } |
300 | } |
298 | base = DEC; |
301 | base = DEC; |
299 | goto number; |
302 | goto number; |
300 | } else |
303 | } else |
301 | /* |
304 | /* |
302 | if (ch=='n') { |
305 | if (ch=='n') { |
303 | if (flags & LONGINT) |
306 | if (flags & LONGINT) |
304 | *va_arg(ap, long *) = ret; |
307 | *va_arg(ap, long *) = ret; |
305 | else if (flags & SHORTINT) |
308 | else if (flags & SHORTINT) |
306 | *va_arg(ap, short *) = ret; |
309 | *va_arg(ap, short *) = ret; |
307 | else |
310 | else |
308 | *va_arg(ap, int *) = ret; |
311 | *va_arg(ap, int *) = ret; |
309 | continue; // no output |
312 | continue; // no output |
310 | } else |
313 | } else |
311 | */ |
314 | */ |
312 | #ifndef LIGHTPRINTF |
315 | #ifndef LIGHTPRINTF |
313 | if (ch=='O'||ch=='o') { |
316 | if (ch=='O'||ch=='o') { |
314 | if (ch=='O') |
317 | if (ch=='O') |
315 | flags |= LONGINT; |
318 | flags |= LONGINT; |
316 | base = OCT; |
319 | base = OCT; |
317 | goto nosign; |
320 | goto nosign; |
Line 355... | Line 358... | ||
355 | size = prec; |
358 | size = prec; |
356 | } else |
359 | } else |
357 | size = strlen(cp); |
360 | size = strlen(cp); |
358 | sign = '\0'; |
361 | sign = '\0'; |
359 | } else |
362 | } else |
360 | #endif /* LIGHTPRINTF */ |
363 | #endif /* LIGHTPRINTF */ |
361 | if(ch=='U'||ch=='u') { |
364 | if(ch=='U'||ch=='u') { |
362 | if (ch=='U') |
365 | if (ch=='U') |
363 | flags |= LONGINT; |
366 | flags |= LONGINT; |
364 | base = DEC; |
367 | base = DEC; |
365 | goto nosign; |
368 | goto nosign; |
Line 399... | Line 402... | ||
399 | } |
402 | } |
400 | *--cp=_d; |
403 | *--cp=_d; |
401 | _ulong /= base; |
404 | _ulong /= base; |
402 | } while (notlastdigit); |
405 | } while (notlastdigit); |
403 | #ifndef LIGHTPRINTF |
406 | #ifndef LIGHTPRINTF |
404 | // handle octal leading 0 |
407 | // handle octal leading 0 |
405 | if (base==OCT && flags & ALT && *cp != '0') |
408 | if (base==OCT && flags & ALT && *cp != '0') |
406 | *--cp = '0'; |
409 | *--cp = '0'; |
407 | #endif |
410 | #endif |
408 | } |
411 | } |