diff options
author | wlemb <wlemb> | 2001-07-20 07:43:28 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2001-07-20 07:43:28 +0000 |
commit | 8ec25476b88dc3138d74c285cf249a90200ae6ac (patch) | |
tree | ed562945d84990b5a5357ec74702db60cc7f87f7 | |
parent | 3a40558a18508ccef13f9d14a54d8932db37cca7 (diff) | |
download | groff-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.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | doc/.cvsignore | 6 | ||||
-rw-r--r-- | src/devices/grohtml/post-html.cc | 3 | ||||
-rw-r--r-- | src/include/posix.h | 4 | ||||
-rw-r--r-- | src/preproc/html/pre-html.cc | 74 | ||||
-rw-r--r-- | src/roff/groff/groff.cc | 31 |
6 files changed, 94 insertions, 35 deletions
@@ -1,8 +1,19 @@ +2001-07-20 Gaius Mulley <gaius@glam.ac.uk> + + * 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(). + 2001-07-19 Werner LEMBERG <wl@gnu.org> * doc/Makefile: Added GROFF_BIN_PATH to make it work with uninstalled groff also. + * src/include/posix.h: Define S_IWUSR if not yet defined. + 2001-07-18 Werner LEMBERG <wl@gnu.org> * NEWS: Updated. diff --git a/doc/.cvsignore b/doc/.cvsignore new file mode 100644 index 00000000..21321904 --- /dev/null +++ b/doc/.cvsignore @@ -0,0 +1,6 @@ +grohtml-*-*.png +homepage.html +meintro.ps +meref.ps +pic.html +pic.ps diff --git a/src/devices/grohtml/post-html.cc b/src/devices/grohtml/post-html.cc index 7e1a9bf0..1323b282 100644 --- a/src/devices/grohtml/post-html.cc +++ b/src/devices/grohtml/post-html.cc @@ -2900,6 +2900,9 @@ int main(int argc, char **argv) case 'r': auto_rule = FALSE; break; + case 'd': + /* handled by pre-html */ + break; case 'o': /* handled by pre-html */ break; diff --git a/src/include/posix.h b/src/include/posix.h index 1b7d5cdc..80f59cad 100644 --- a/src/include/posix.h +++ b/src/include/posix.h @@ -42,6 +42,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define S_IROTH 0004 #endif +#ifndef S_IWUSR +#define S_IWUSR 0200 +#endif + #ifndef S_ISREG #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc index dd9ee0af..6f2b9789 100644 --- a/src/preproc/html/pre-html.cc +++ b/src/preproc/html/pre-html.cc @@ -1151,7 +1151,7 @@ static void alterDeviceTo (int argc, char *argv[], int toImage) char **addZ (int argc, char *argv[]) { char **new_argv = (char **)malloc((argc+2)*sizeof(char *)); - int i=0; + int i=0; if (new_argv == NULL) sys_fatal("malloc"); @@ -1241,7 +1241,7 @@ int char_buffer::do_html(int argc, char *argv[]) char **addps4html (int argc, char *argv[]) { char **new_argv = (char **)malloc((argc+2)*sizeof(char *)); - int i=0; + int i=0; if (new_argv == NULL) sys_fatal("malloc"); @@ -1329,43 +1329,61 @@ void usage(FILE *stream) } /* - * scanArguments - scans for -P-i, -P-o, -P-D and -P-I arguments. + * scanArguments - scans for all arguments including -P-i, -P-o, -P-D and -P-I. It returns + * the argument index of the first non option. */ int scanArguments (int argc, char **argv) { - int i=1; - - while (i<argc) { - if (strncmp(argv[i], "-D", 2) == 0) { - image_dir = (char *)(argv[i]+2); - } else if (strncmp(argv[i], "-I", 2) == 0) { - image_template = (char *)(argv[i]+2); - } else if (strncmp(argv[i], "-i", 2) == 0) { - image_res = atoi((char *)(argv[i]+2)); - } else if (strncmp(argv[i], "-o", 2) == 0) { - vertical_offset = atoi((char *)(argv[i]+2)); - } else if ((strcmp(argv[i], "-v") == 0) - || (strcmp(argv[i], "--version") == 0)) { + int c; + static const struct option long_options[] = { + { "help", no_argument, 0, CHAR_MAX + 1 }, + { "version", no_argument, 0, 'v' }, + { NULL, 0, 0, 0 } + }; + while ((c = getopt_long(argc, argv, "+o:i:I:D:F:vd?lrn", long_options, NULL)) + != EOF) + switch(c) { + case 'v': printf("GNU pre-grohtml (groff) version %s\n", Version_string); exit(0); - } else if ((strcmp(argv[i], "-h") == 0) - || (strcmp(argv[i], "--help") == 0) - || (strcmp(argv[i], "-?") == 0)) { - usage(stdout); - exit(0); - } else if (strcmp(argv[i], TROFF_COMMAND) == 0) { - /* remember troff argument number */ - troff_arg = i; + case 'D': + image_dir = optarg; + break; + case 'I': + image_template = optarg; + break; + case 'i': + image_res = atoi(optarg); + break; + case 'o': + vertical_offset = atoi(optarg); + break; + case 'd': #if defined(DEBUGGING) - } else if (strcmp(argv[i], "-d") == 0) { debug = TRUE; #endif - } else if (argv[i][0] != '-') { - return( i ); + break; + case CHAR_MAX + 1: // --help + usage(stdout); + exit(0); + break; + case '?': + usage(stderr); + exit(1); + break; + default: + break; } - i++; + + while (optind < argc) { + if (strcmp(argv[optind], "troff") == 0) + troff_arg = optind; + else if (argv[optind][0] != '-') + return optind; + optind++; } + return( argc ); } 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) |