aboutsummaryrefslogtreecommitdiff
path: root/src/parse.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-21 04:50:06 +0000
committer_ov4 <ov4@ov4.org>2026-09-21 04:50:06 +0000
commit1c630655b2beb0f4b84fb7e1bc034ba62520be37 (patch)
treee90e70c425813df29c8bbd5c1e84ef22f4e4a176 /src/parse.cc
parent9f5936bf64deb625a27259d778937e281ca19cea (diff)
fix name typo, and remove outdated parse
Diffstat (limited to 'src/parse.cc')
-rw-r--r--src/parse.cc72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/parse.cc b/src/parse.cc
deleted file mode 100644
index f61913a..0000000
--- a/src/parse.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "parse.h"
-
-namespace ov4
-{
-
-/*
- * parseline - Parse the command line and build the argv array.
- *
- * Characters enclosed in single quotes are treated as a single
- * argument. Return true if the user has requested a BG job, false if
- * the user has requested a FG job.
- */
-int parseline(const char *cmdline, char **argv)
-{
- static char array[MAXLINE]; /* holds local copy of command line */
- char *buf = array; /* ptr that traverses command line */
- char *delim; /* points to first space delimiter */
- int argc; /* number of args */
- int bg; /* background job? */
-
- strcpy(buf, cmdline);
- if (buf[strlen(buf)-1] == '\n')
- buf[strlen(buf)-1] = ' '; /* replace trailing '\n' with space */
- else
- {
- // if buffer is not large enough
- // might be UB
- // TODO: fix UB
- buf[strlen(buf)] = ' ';
- buf[strlen(buf)+1] = '\0';
- }
- while (*buf && (*buf == ' ')) /* ignore leading spaces */
- buf++;
-
- /* Build the argv list */
- argc = 0;
- if (*buf == '\'') {
- buf++;
- delim = strchr(buf, '\'');
- }
- else {
- delim = strchr(buf, ' ');
- }
-
- while (delim) {
- argv[argc++] = buf;
- *delim = '\0';
- buf = delim + 1;
- while (*buf && (*buf == ' ')) /* ignore spaces */
- buf++;
-
- if (*buf == '\'') {
- buf++;
- delim = strchr(buf, '\'');
- }
- else {
- delim = strchr(buf, ' ');
- }
- }
- argv[argc] = NULL;
-
- if (argc == 0) /* ignore blank line */
- return 1;
-
- /* should the job run in the background? */
- if ((bg = (*argv[argc-1] == '&')) != 0) {
- argv[--argc] = NULL;
- }
- return bg;
-}
-
-}