aboutsummaryrefslogtreecommitdiff
path: root/toys/sed.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-01-10 14:34:15 -0600
committerRob Landley <rob@landley.net>2008-01-10 14:34:15 -0600
commit6a9e5b4654e76585e38c6c6002eccba9b4b1b310 (patch)
treeec7422e6973812bd09f1b781197330f5c9c7c326 /toys/sed.c
parentbd9155198f000037ec5b9d1e4ef26eae80bbb202 (diff)
downloadtoybox-6a9e5b4654e76585e38c6c6002eccba9b4b1b310.tar.gz
Very early stub of sed, does nothing yet.
Diffstat (limited to 'toys/sed.c')
-rw-r--r--toys/sed.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/toys/sed.c b/toys/sed.c
new file mode 100644
index 00000000..39753399
--- /dev/null
+++ b/toys/sed.c
@@ -0,0 +1,46 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * sed.c - Stream editor.
+ *
+ * See http://www.opengroup.org/onlinepubs/009695399/utilities/sed.c
+ */
+
+#include "toys.h"
+#include "lib/xregcomp.h"
+
+#define TT toy.sed
+
+struct sed_command {
+ // Doubly linked list of commands.
+ struct sed_command *next, *prev;
+
+ // Regexes for s/match/data/ and /match_begin/,/match_end/command
+ regex_t *match, *match_begin, *match_end;
+
+ // For numeric ranges ala 10,20command
+ int first_line, last_line;
+
+ // Which match to replace, 0 for all.
+ int which;
+
+ // s and w commands can write to a file. Slight optimization: we use 0
+ // instead of -1 to mean no file here, because even when there's no stdin
+ // our input file would take fd 0.
+ int outfd;
+
+ // Data string for (saicytb)
+ char *data;
+
+ // Which command letter is this?
+ char command;
+};
+
+void sed_main(void)
+{
+ struct arg_list *test;
+
+ for (test = TT.commands; test; test = test->next)
+ dprintf(2,"command=%s\n",test->arg);
+
+ printf("Hello world\n");
+}