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.
|
* is wrong.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
fprintf(stderr, "ERROR: nsh_consolemain() returned: %d\n", ret);
|
fprintf(stderr, "ERROR: nsh_consolemain() returned: %d\n", ret);
|
||||||
|
#else
|
||||||
|
printf("ERROR: nsh_consolemain() returned: %d\n", ret);
|
||||||
|
#endif
|
||||||
|
|
||||||
exitval = 1;
|
exitval = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -198,6 +198,8 @@ static ssize_t nsh_consolewrite(FAR struct nsh_vtbl_s *vtbl, FAR const void *buf
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
/* REVISIT: buffer may not be NUL-terminated */
|
||||||
|
|
||||||
printf("%s", buffer);
|
printf("%s", buffer);
|
||||||
return nbytes;
|
return nbytes;
|
||||||
#endif
|
#endif
|
||||||
@ -234,13 +236,30 @@ static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#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);
|
va_start(ap, fmt);
|
||||||
vsprintf(dest, fmt, ap);
|
str = NULL;
|
||||||
va_end(ap);
|
(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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,9 +87,15 @@ int cmd_free(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
(void)mallinfo(&mem);
|
(void)mallinfo(&mem);
|
||||||
#endif
|
#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, " total used free largest\n");
|
||||||
nsh_output(vtbl, "Mem: %11d%11d%11d%11d\n",
|
nsh_output(vtbl, "Mem: %11d%11d%11d%11d\n",
|
||||||
mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk);
|
mem.arena, mem.uordblks, mem.fordblks, mem.mxordblk);
|
||||||
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,11 @@ static inline void help_cmdlist(FAR struct nsh_vtbl_s *vtbl)
|
|||||||
nsh_output(vtbl, " ");
|
nsh_output(vtbl, " ");
|
||||||
for (j = 0, k = i; j < CMDS_PER_LINE && k < NUM_CMDS; j++, k += NUM_CMD_ROWS)
|
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);
|
nsh_output(vtbl, "%-12s", g_cmdmap[k].cmd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsh_output(vtbl, "\n");
|
nsh_output(vtbl, "\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user