aboutsummaryrefslogtreecommitdiff
path: root/src
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
parenta52c8c88cbd7c802b31cec524617161b26c5268f (diff)
parse
Diffstat (limited to 'src')
-rw-r--r--src/global.cc (renamed from src/setting.cc)2
-rw-r--r--src/main.cc51
-rw-r--r--src/parse.cc56
3 files changed, 58 insertions, 51 deletions
diff --git a/src/setting.cc b/src/global.cc
index 0461c16..e2a17ab 100644
--- a/src/setting.cc
+++ b/src/global.cc
@@ -1,4 +1,4 @@
-#include "setting.h"
+#include "global.h"
namespace ov4
{
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
diff --git a/src/parse.cc b/src/parse.cc
new file mode 100644
index 0000000..abb80d9
--- /dev/null
+++ b/src/parse.cc
@@ -0,0 +1,56 @@
+#include "parse.h"
+
+namespace ov4
+{
+
+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;
+}
+
+}