diff options
author | wlemb <wlemb> | 2001-07-12 22:11:00 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2001-07-12 22:11:00 +0000 |
commit | 555085ba5f32dffa70f3a1b1b899f2f48482b3b6 (patch) | |
tree | b7b237ac8433fc7fda641fe7e40beda55ad18ad6 /src | |
parent | 51efe4969e9cd59f8fa3ebdc9f79049c302c538b (diff) | |
download | groff-555085ba5f32dffa70f3a1b1b899f2f48482b3b6.tar.gz |
2001-07-12 Ruslan Ermilov <ru@FreeBSD.org>
Merge -xwidth into -width. Add -xwidth functionality to -column
also.
* tmac/doc.tmac (Bl): Add dummy doc-typeXXX and doc-spaceXXX to
avoid warning.
(doc-do-Bl-args): Merge -xwidth code with -width. Test whether
string immediately following a leading dot starts with a valid mdoc
argument.
Add similar code to the -column branch.
(doc-Bl-usage): Updated.
* groff_mdoc.man: s/-xwidth/-width/.
2001-07-12 Gaius Mulley <gaius@glam.ac.uk>
* src/devices/grohtml/post-html.cc (text_glob::is_br): Stop titles
running into centered or non-formatted text.
2001-07-11 Werner LEMBERG <wl@gnu.org>
Introduce short and long prefixes to have the selection at run-time
whether there is a 8+3 limit for names of temporary files.
* src/libs/libgroff/tmpfile.cc (TMPFILE_PREFIX): Replaced with...
(TMPFILE_PREFIX_SHORT, TMPFILE_PREFIX_LONG): This.
(tmpfile_prefix, tmpfile_prefix_len, use_short_prefix): New
variables.
(temp_init): New global structure to initialize above three
variables.
(xtmptemplate): Use two parameters for long and short prefix.
Simplify code use above three variables.
(xtmpfile): Use long and short prefixes as parameters.
* src/include/lib.h: Updated.
* src/preproc/html/pre-html.cc ({PAGE,PS,REGION}_TEMPLATE): Replace
with ...
({PAGE,PS,REGION}_TEMPLATE_{SHORT,LONG}): This.
(createAllPages, makeTempFiles): Updated.
2001-07-09 Werner LEMBERG <wl@gnu.org>
* REVISION: Increased to 3.
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/grohtml/post-html.cc | 5 | ||||
-rw-r--r-- | src/include/lib.h | 6 | ||||
-rw-r--r-- | src/libs/libgroff/tmpfile.cc | 80 | ||||
-rw-r--r-- | src/preproc/html/pre-html.cc | 49 |
4 files changed, 96 insertions, 44 deletions
diff --git a/src/devices/grohtml/post-html.cc b/src/devices/grohtml/post-html.cc index 0c36941a..7e1a9bf0 100644 --- a/src/devices/grohtml/post-html.cc +++ b/src/devices/grohtml/post-html.cc @@ -439,11 +439,14 @@ int text_glob::is_auto_img (void) /* * is_br - returns TRUE if the glob is a tag containing a .br + * or an implied .br */ int text_glob::is_br (void) { - return( is_a_tag() && (strcmp("html-tag:.br", text_string) == 0) ); + return( is_a_tag() && ((strcmp("html-tag:.br", text_string) == 0) || + (strcmp("html-tag:.ce", text_string) == 0) || + (strcmp("html-tag:.nf", text_string) == 0)) ); } /* diff --git a/src/include/lib.h b/src/include/lib.h index db5277c0..c424b8e8 100644 --- a/src/include/lib.h +++ b/src/include/lib.h @@ -43,8 +43,10 @@ int is_prime(unsigned); #include <strings.h> #endif -FILE *xtmpfile(char **namep = 0, char *postfix = 0, int do_unlink = 1); -char *xtmptemplate(char *extension = 0); +FILE *xtmpfile(char **namep = 0, + const char *postfix_long = 0, const char *postfix_short = 0, + int do_unlink = 1); +char *xtmptemplate(const char *postfix_long, const char *postfix_short); #ifdef NEED_DECLARATION_POPEN diff --git a/src/libs/libgroff/tmpfile.cc b/src/libs/libgroff/tmpfile.cc index 8508c595..06090156 100644 --- a/src/libs/libgroff/tmpfile.cc +++ b/src/libs/libgroff/tmpfile.cc @@ -48,11 +48,49 @@ extern "C" { # define DEFAULT_TMPDIR "/tmp" #endif // Use this as the prefix for temporary filenames. -#ifdef __MSDOS__ -#define TMPFILE_PREFIX "" -#else -#define TMPFILE_PREFIX "groff" -#endif +#define TMPFILE_PREFIX_SHORT "" +#define TMPFILE_PREFIX_LONG "groff" + +char *tmpfile_prefix; +size_t tmpfile_prefix_len; +int use_short_postfix = 0; + +struct temp_init { + temp_init(); + ~temp_init(); +} _temp_init; + +temp_init::temp_init() +{ + const char *tem = getenv(GROFF_TMPDIR_ENVVAR); + if (!tem) { + tem = getenv(TMPDIR_ENVVAR); + if (!tem) + tem = DEFAULT_TMPDIR; + } + size_t tem_len = strlen(tem); + const char *tem_end = tem + tem_len - 1; + int need_slash = strchr(DIR_SEPS, *tem_end) == NULL ? 1 : 0; + char *tem2 = new char[tem_len + need_slash + 1]; + strcpy(tem2, tem); + if (need_slash) + strcat(tem2, "/"); + const char *tem3 = TMPFILE_PREFIX_LONG; + if (file_name_max(tem2) <= 14) { + tem3 = TMPFILE_PREFIX_SHORT; + use_short_postfix = 1; + } + tmpfile_prefix_len = tem_len + need_slash + strlen(tem3); + tmpfile_prefix = new char[tmpfile_prefix_len + 1]; + strcpy(tmpfile_prefix, tem2); + strcat(tmpfile_prefix, tem3); + a_delete tem2; +} + +temp_init::~temp_init() +{ + a_delete tmpfile_prefix; +} /* * Generate a temporary name template with a postfix @@ -62,34 +100,18 @@ extern "C" { * only the *template* is returned. */ -char *xtmptemplate(char *postfix) +char *xtmptemplate(const char *postfix_long, const char *postfix_short) { - const char *dir = getenv(GROFF_TMPDIR_ENVVAR); + const char *postfix = use_short_postfix ? postfix_short : postfix_long; int postlen = 0; - if (postfix) postlen = strlen(postfix); - - if (!dir) { - dir = getenv(TMPDIR_ENVVAR); - if (!dir) - dir = DEFAULT_TMPDIR; - } - - size_t dir_len = strlen(dir); - const char *dir_end = dir + dir_len - 1; - int needs_slash = strchr(DIR_SEPS, *dir_end) == NULL; - char *templ = new char[strlen(dir) + needs_slash - + sizeof(TMPFILE_PREFIX) - 1 + 6 + 1 + postlen]; - strcpy(templ, dir); - if (needs_slash) - strcat(templ, "/"); - strcat(templ, TMPFILE_PREFIX); + char *templ = new char[tmpfile_prefix_len + postlen + 6 + 1]; + strcpy(templ, tmpfile_prefix); if (postlen > 0) strcat(templ, postfix); strcat(templ, "XXXXXX"); - - return( templ ); + return templ; } // The trick with unlinking the temporary file while it is still in @@ -136,9 +158,11 @@ static void add_tmp_file(const char *name) // Open a temporary file and with fatal error on failure. -FILE *xtmpfile(char **namep, char *postfix, int do_unlink) +FILE *xtmpfile(char **namep, + const char *postfix_long, const char *postfix_short, + int do_unlink) { - char *templ = xtmptemplate(postfix); + char *templ = xtmptemplate(postfix_long, postfix_short); #ifdef HAVE_MKSTEMP errno = 0; diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc index 2a36740d..00ccd886 100644 --- a/src/preproc/html/pre-html.cc +++ b/src/preproc/html/pre-html.cc @@ -66,15 +66,12 @@ extern "C" const char *Version_string; #define TRANSPARENT "-background \"#FFF\" -transparent \"#FFF\"" -#ifdef __MSDOS__ -#define PAGE_TEMPLATE "pg" -#define PS_TEMPLATE "ps" -#define REGION_TEMPLATE "rg" -#else -#define PAGE_TEMPLATE "-page-" -#define PS_TEMPLATE "-ps-" -#define REGION_TEMPLATE "-regions-" -#endif +#define PAGE_TEMPLATE_SHORT "pg" +#define PAGE_TEMPLATE_LONG "-page-" +#define PS_TEMPLATE_SHORT "ps" +#define PS_TEMPLATE_LONG "-ps-" +#define REGION_TEMPLATE_SHORT "rg" +#define REGION_TEMPLATE_LONG "-regions-" #if 0 # define DEBUGGING @@ -113,7 +110,6 @@ static char *troffFileName = NULL; // output of pre-html output whi static char *htmlFileName = NULL; // output of pre-html output which is sent to troff -Thtml #endif - /* * Images are generated via postscript, gs and the pnm utilities. */ @@ -854,7 +850,7 @@ static int createAllPages (void) char *s; int retries = MAX_RETRIES; - imagePageStem = xtmptemplate(PAGE_TEMPLATE); + imagePageStem = xtmptemplate(PAGE_TEMPLATE_LONG, PAGE_TEMPLATE_SHORT); strcpy(buffer, imagePageStem); do { @@ -1368,20 +1364,47 @@ static int makeTempFiles (void) troffFileName = "/tmp/prehtml-troff"; htmlFileName = "/tmp/prehtml-html"; #else + +#if 0 + FILE *f; + + f = xtmpfile(&psFileName, + PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT, + FALSE); + if (f == NULL) { + sys_fatal("xtmpfile"); + return -1; + } + fclose(f); + f = xtmpfile(®ionFileName, + REGION_TEMPLATE_LONG, REGION_TEMPLATE_SHORT, + FALSE); + if (f == NULL) { + sys_fatal("xtmpfile"); + return -1; + } + fclose(f); +#else int fd; - if ((fd = mkstemp(psFileName = xtmptemplate(PS_TEMPLATE))) == -1) { + if ((fd = mkstemp(psFileName = + xtmptemplate(PS_TEMPLATE_LONG, + PS_TEMPLATE_SHORT))) == -1) { sys_fatal("mkstemp"); return -1; } close(fd); - if ((fd = mkstemp(regionFileName = xtmptemplate(REGION_TEMPLATE))) == -1) { + if ((fd = mkstemp(regionFileName = + xtmptemplate(REGION_TEMPLATE_LONG, + REGION_TEMPLATE_SHORT))) == -1) { sys_fatal("mkstemp"); unlink(psFileName); return -1; } close(fd); #endif + +#endif return 0; } |