More improvements to the minimal NSH when there is no file system and when print fieldwidths are suppressed
This commit is contained in:
parent
749eb6a027
commit
f6e948fa04
@ -174,7 +174,12 @@ int nsh_main(int argc, char *argv[])
|
||||
* is wrong.
|
||||
*/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
fprintf(stderr, "ERROR: nsh_consolemain() returned: %d\n", ret);
|
||||
#else
|
||||
printf("ERROR: nsh_consolemain() returned: %d\n", ret);
|
||||
#endif
|
||||
|
||||
exitval = 1;
|
||||
#endif
|
||||
|
||||
|
@ -198,6 +198,8 @@ static ssize_t nsh_consolewrite(FAR struct nsh_vtbl_s *vtbl, FAR const void *buf
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
/* REVISIT: buffer may not be NUL-terminated */
|
||||
|
||||
printf("%s", buffer);
|
||||
return nbytes;
|
||||
#endif
|
||||
@ -234,13 +236,30 @@ static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...)
|
||||
|
||||
return ret;
|
||||
#else
|
||||
char dest[64 * 16];
|
||||
va_list ap;
|
||||
char *str;
|
||||
int ret;
|
||||
|
||||
/* Use avsprintf() to allocate a buffer and fill it with the formatted
|
||||
* data
|
||||
*/
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsprintf(dest, fmt, ap);
|
||||
va_end(ap);
|
||||
str = NULL;
|
||||
(void)avsprintf(&str, fmt, ap);
|
||||
|
||||
return printf(dest);
|
||||
/* Was a string allocated? */
|
||||
|
||||
if (str)
|
||||
{
|
||||
/* Yes.. Print then free the allocated string */
|
||||
|
||||
printf("%s", str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,15 @@ int cmd_free(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
(void)mallinfo(&mem);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NOPRINTF_FIELDWIDTH
|
||||
nsh_output(vtbl, "\ttotal\tused\tfree\tlargest\n");
|
||||
nsh_output(vtbl, "Mem:\t%d\t%d\t%d\t%d\n",
|
||||
mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk);
|
||||
#else
|
||||
nsh_output(vtbl, " total used free largest\n");
|
||||
nsh_output(vtbl, "Mem: %11d%11d%11d%11d\n",
|
||||
mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -513,7 +513,11 @@ static inline void help_cmdlist(FAR struct nsh_vtbl_s *vtbl)
|
||||
nsh_output(vtbl, " ");
|
||||
for (j = 0, k = i; j < CMDS_PER_LINE && k < NUM_CMDS; j++, k += NUM_CMD_ROWS)
|
||||
{
|
||||
#ifdef CONFIG_NOPRINTF_FIELDWIDTH
|
||||
nsh_output(vtbl, "%s\t", g_cmdmap[k].cmd);
|
||||
#else
|
||||
nsh_output(vtbl, "%-12s", g_cmdmap[k].cmd);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsh_output(vtbl, "\n");
|
||||
|
Loading…
Reference in New Issue
Block a user