aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-08-31 06:59:47 +0000
committer_ov4 <ov4@ov4.org>2026-08-31 06:59:47 +0000
commitb48f96db8e80e1866be8b92132ece590b3a9ffb9 (patch)
treeda550823a455070e042ea3fcc7d0b053f172b8ed /src/main.cc
parenta52c8c88cbd7c802b31cec524617161b26c5268f (diff)
parse
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc51
1 files changed, 1 insertions, 50 deletions
diff --git a/src/main.cc b/src/main.cc
index 22395fb..ffcf52d 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -18,6 +18,7 @@
#include "util.h"
#include "job.h"
+#include "parse.h"
using namespace std;
using namespace ov4;
@@ -66,8 +67,6 @@ void sigchld_handler(int sig);
void sigtstp_handler(int sig);
void sigint_handler(int sig);
-/* Here are helper routines that we've provided for you */
-int parseline(const char *cmdline, char **argv);
void sigquit_handler(int sig);
@@ -233,55 +232,7 @@ void eval(char *cmdline)
* 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);
- buf[strlen(buf)-1] = ' '; /* replace trailing '\n' with space */
- 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;
-}
/*
* builtin_cmd - If the user has typed a built-in command then execute