summaryrefslogtreecommitdiff
path: root/nuttx/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-17 19:57:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-17 19:57:40 +0000
commita2b87c9a5c89134182092d18630747b5777307eb (patch)
treeddc41c44bd03e8ba27dc3eb07db8af76a6a47801 /nuttx/examples
parent5c2b55b457af9b2fcd937f54cf2b1d818ace6303 (diff)
downloadpx4-nuttx-a2b87c9a5c89134182092d18630747b5777307eb.tar.gz
px4-nuttx-a2b87c9a5c89134182092d18630747b5777307eb.tar.bz2
px4-nuttx-a2b87c9a5c89134182092d18630747b5777307eb.zip
NSH now supports comments
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@830 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r--nuttx/examples/nsh/nsh_main.c68
1 files changed, 40 insertions, 28 deletions
diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c
index bde02fc03..b2915a75a 100644
--- a/nuttx/examples/nsh/nsh_main.c
+++ b/nuttx/examples/nsh/nsh_main.c
@@ -321,7 +321,7 @@ char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr)
return NULL;
}
- /* Does the token begin with '>' */
+ /* Does the token begin with '>' -- redirection of output? */
if (*pbegin == '>')
{
@@ -330,17 +330,29 @@ char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr)
if (*(pbegin + 1) == '>')
{
*saveptr = pbegin + 2;
- pbegin = (char*)g_redirect2;
+ pbegin = (char*)g_redirect2;
}
else
{
*saveptr = pbegin + 1;
- pbegin = (char*)g_redirect1;
+ pbegin = (char*)g_redirect1;
}
}
+
+ /* Does the token begin with '#' -- comment */
+
+ else if (*pbegin == '#')
+ {
+ /* Return NULL meaning that we are at the end of the line */
+
+ *saveptr = pbegin;
+ pbegin = NULL;
+ }
else
{
- /* Does the token begin with '"'? */
+ /* Otherwise, we are going to have to parse to find the end of
+ * the token. Does the token begin with '"'?
+ */
if (*pbegin == '"')
{
@@ -379,41 +391,41 @@ char *nsh_argument(FAR struct nsh_vtbl_s *vtbl, char **saveptr)
/* Save the pointer where we left off */
*saveptr = pend;
- }
- /* Check for references to environment variables */
+ /* Check for references to environment variables */
- if (pbegin[0] == '$' && !quoted)
- {
- /* Check for built-in variables */
-
- if (strcmp(pbegin, g_exitstatus) == 0)
+ if (pbegin[0] == '$' && !quoted)
{
- if (vtbl->np.np_fail)
- {
- return (char*)g_failure;
- }
- else
+ /* Check for built-in variables */
+
+ if (strcmp(pbegin, g_exitstatus) == 0)
{
- return (char*)g_success;
+ if (vtbl->np.np_fail)
+ {
+ return (char*)g_failure;
+ }
+ else
+ {
+ return (char*)g_success;
+ }
}
- }
- /* Not a built-in? Return the value of the environment variable with this name */
+ /* Not a built-in? Return the value of the environment variable with this name */
#ifndef CONFIG_DISABLE_ENVIRON
- else
- {
- char *value = getenv(pbegin+1);
- if (value)
- {
- return value;
- }
else
{
- return (char*)"";
+ char *value = getenv(pbegin+1);
+ if (value)
+ {
+ return value;
+ }
+ else
+ {
+ return (char*)"";
+ }
}
- }
#endif
+ }
}
/* Return the beginning of the token. */