From c5ce9ec6d60e78142ca9adc41fae3f72f1288468 Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Tue, 9 Jun 2015 15:36:13 +0200 Subject: [PATCH] Sync-to-go: src/pre-html.. Some stuff that should have been happened during adaption, yet i'm too lazy to rebase so much. Do take [e4b474d] ([grohtml] Don't ignore return value of `dup'., 2013-02-02). --- src/pre-html/html-config.h.in | 11 ++++++++++- src/pre-html/pre-html.cpp | 23 +++++------------------ src/pre-html/pushback.cpp | 6 ++++-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/pre-html/html-config.h.in b/src/pre-html/html-config.h.in index 9451610e..330ff103 100644 --- a/src/pre-html/html-config.h.in +++ b/src/pre-html/html-config.h.in @@ -3,7 +3,16 @@ #define _HTML_CONFIG_H /* maximum number of character that can be pushed back */ -#define MAXPUSHBACKSTACK 4096 +#define MAXPUSHBACKSTACK 4096 + +/* Images are generated via postscript, gs, and the pnm utilities */ +#define IMAGE_DEVICE "-Tps" + +// Inches wide +#define DEFAULT_LINE_LENGTH 7 +// Number of pixels per inch resolution +#define DEFAULT_IMAGE_RES 100 +#define IMAGE_BOARDER_PIXELS 0 #endif // _HTML_CONFIG_H // s-it2-mode diff --git a/src/pre-html/pre-html.cpp b/src/pre-html/pre-html.cpp index 717daa90..dac698bb 100644 --- a/src/pre-html/pre-html.cpp +++ b/src/pre-html/pre-html.cpp @@ -143,9 +143,6 @@ # define DEBUG_FILE(name) DEBUG_NAME(DEBUG_FILE_DIR) "/" name #endif -#define DEFAULT_LINE_LENGTH 7 // inches wide -#define DEFAULT_IMAGE_RES 100 // number of pixels per inch resolution -#define IMAGE_BOARDER_PIXELS 0 #define INLINE_LEADER_CHAR '\\' // Don't use colour names here! Otherwise there is a dependency on @@ -210,11 +207,6 @@ const char *const FONT_ENV_VAR = U_ROFF_FONT_PATH; static search_path font_path(FONT_ENV_VAR, FONTPATH, 0, 0); static html_dialect dialect = html4; -/* - * Images are generated via postscript, gs, and the pnm utilities. - */ -#define IMAGE_DEVICE "-Tps" - static int do_file(const char *filename); /* @@ -1192,19 +1184,14 @@ static void alterDeviceTo(int argc, char *argv[], int toImage) argv[i] = (char *)IMAGE_DEVICE; i++; } - argv[troff_arg] = (char*)L_ROFF; // rather than troff - } - else { + } else { while (i < argc) { if (strcmp(argv[i], IMAGE_DEVICE) == 0) - if (dialect == xhtml) - argv[i] = (char *)"-Txhtml"; - else - argv[i] = (char *)"-Thtml"; + argv[i] = UNCONST((dialect == xhtml) ? "-Txhtml" : "-Thtml"); i++; } - argv[troff_arg] = (char*)L_ROFF; // use groff -Z } + argv[troff_arg] = UNCONST(L_ROFF); // use groff -Z } /* @@ -1762,10 +1749,10 @@ int main(int argc, char **argv) #endif /* CAPTURE_MODE */ device = "html"; if (!font::load_desc()) - fatal("cannot find html/DESC exiting"); + fatal("cannot find dev-html/DESC exiting"); image_gen = font::image_generator; if (image_gen == NULL || (strcmp(image_gen, "") == 0)) - fatal("html/DESC must set the image_generator field, exiting"); + fatal("dev-html/DESC must set the image_generator field, exiting"); postscriptRes = get_resolution(); i = scanArguments(argc, argv); setupAntiAlias(); diff --git a/src/pre-html/pushback.cpp b/src/pre-html/pushback.cpp index e0c333e2..6bf0be54 100644 --- a/src/pre-html/pushback.cpp +++ b/src/pre-html/pushback.cpp @@ -56,7 +56,8 @@ pushBackBuffer::pushBackBuffer (char *filename) eofFound = false; lineNo = 1; if (strcmp(filename, "") != 0) { - stdIn = dup(0); + if ((stdIn = dup(0)) == -1) + sys_fatal("cannot dup(2)licate standard input"); close(0); if (open(filename, O_RDONLY) != 0) { sys_fatal("when trying to open file"); @@ -73,7 +74,8 @@ pushBackBuffer::~pushBackBuffer () } close(0); /* restore stdin in file descriptor 0 */ - dup(stdIn); + if (dup(stdIn) == -1) /* FIXME use dup2() if possible, not close(0)+dup(2)! */ + sys_fatal("cannot restore dup(2)licated standard input"); close(stdIn); } -- 2.11.4.GIT