Precision (printf("%.Ns", text1)) not supported by all compilers, for example some versions of avrgcc and mspgcc.

This commit is contained in:
Niclas Finne 2012-05-16 11:23:03 +02:00
parent f2f6a7bd53
commit ec1d598148

View file

@ -32,8 +32,6 @@
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
* $Id: serial-shell.c,v 1.5 2009/03/17 15:56:32 adamdunkels Exp $
*/
/**
@ -59,6 +57,7 @@ PROCESS(serial_shell_process, "Contiki serial shell");
void
shell_default_output(const char *text1, int len1, const char *text2, int len2)
{
int i;
if(text1 == NULL) {
text1 = "";
len1 = 0;
@ -68,13 +67,15 @@ shell_default_output(const char *text1, int len1, const char *text2, int len2)
len2 = 0;
}
/* Workaround for absence of "%.*s" format in avr-libc */
#if defined (__AVR__)
printf("%s %s\r\n", text1, text2);
#else
printf("%.*s%.*s\r\n", len1, text1, len2, text2);
#endif
/* Precision (printf("%.Ns", text1)) not supported on all platforms.
putchar(c) not be supported on all platforms. */
for(i = 0; i < len1; i++) {
printf("%c", text1[i]);
}
for(i = 0; i < len2; i++) {
printf("%c", text2[i]);
}
printf("\r\n");
}
/*---------------------------------------------------------------------------*/
void