summaryrefslogtreecommitdiff
path: root/src/roff/groff/groff.cc
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-07-20 07:43:28 +0000
committerwlemb <wlemb>2001-07-20 07:43:28 +0000
commit8ec25476b88dc3138d74c285cf249a90200ae6ac (patch)
treeed562945d84990b5a5357ec74702db60cc7f87f7 /src/roff/groff/groff.cc
parent3a40558a18508ccef13f9d14a54d8932db37cca7 (diff)
downloadgroff-8ec25476b88dc3138d74c285cf249a90200ae6ac.tar.gz
* src/preproc/html/pre-html.cc (scanArguments): Use getopt_long()
instead of current code. * src/devices/grohtml/post-html.cc (main): Handle `-d' option. * src/roff/groff/groff.cc (possible_command::insert_args): New function. (main): Use it for predriver handling instead of insert_arg(). * src/include/posix.h: Define S_IWUSR if not yet defined.
Diffstat (limited to 'src/roff/groff/groff.cc')
-rw-r--r--src/roff/groff/groff.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/roff/groff/groff.cc b/src/roff/groff/groff.cc
index 6e45edfa..b35a4ffa 100644
--- a/src/roff/groff/groff.cc
+++ b/src/roff/groff/groff.cc
@@ -77,6 +77,7 @@ public:
const char *get_name();
void append_arg(const char *, const char * = 0);
void insert_arg(const char *);
+ void insert_args(string s);
void clear_args();
char **get_argv();
void print(int is_last, FILE *fp);
@@ -283,14 +284,9 @@ int main(int argc, char **argv)
if (predriver && !zflag) {
commands[TROFF_INDEX].insert_arg(commands[TROFF_INDEX].get_name());
- const char *p = Pargs.contents();
- const char *end = p + Pargs.length();
- while (p < end) {
- // pass the device arguments to the predrivers as well
- commands[TROFF_INDEX].insert_arg(p);
- p = strchr(p, '\0') + 1;
- }
commands[TROFF_INDEX].set_name(predriver);
+ // pass the device arguments to the predrivers as well
+ commands[TROFF_INDEX].insert_args(Pargs);
}
const char *real_driver = 0;
@@ -549,6 +545,27 @@ void possible_command::insert_arg(const char *s)
args = str;
}
+void possible_command::insert_args(string s)
+{
+ const char *p = s.contents();
+ const char *end = p + s.length();
+ int l = 0;
+ if (p >= end)
+ return;
+ // find the total number of arguments in our string
+ do {
+ l++;
+ p = strchr(p, '\0') + 1;
+ } while (p < end);
+ // now insert each argument preserving the order
+ for (int i = l - 1; i >= 0; i--) {
+ p = s.contents();
+ for (int j = 0; j < i; j++)
+ p = strchr(p, '\0') + 1;
+ insert_arg(p);
+ }
+}
+
void possible_command::build_argv()
{
if (argv)