diff options
| author | wiz <wiz@NetBSD.org> | 2004-07-30 14:44:08 +0000 |
|---|---|---|
| committer | wiz <wiz@NetBSD.org> | 2004-07-30 14:44:08 +0000 |
| commit | 48af41221fbe020e8450a03ff592db7e31ecfec4 (patch) | |
| tree | b38c984775ddeca9c50226f71bd29870c4890a22 /gnu/dist/groff/src/libs/libgroff/searchpath.cpp | |
| parent | adda7c4307676809026dc5296e39d4c4543a9ddf (diff) | |
Import groff-1.19.1. Changes since 1.19:
Groff
-----
o The argument of the command line option `-I' is now also passed to troff
and grops, specifying a directory to search for files on the command line,
files named in `so' and `psbb' requests, and files named in \X'ps: file'
and \X'ps: import' escapes.
o If option `-V' is used more than once, the commands will be both printed
on standard error and run.
Troff
-----
o Two new read-only, string-valued registers `.m' and `.M' return the
name of the current drawing and background color, respectively.
o New read-only register `.U' which is set to 1 if in safer mode and set
to 0 if in unsafe mode.
o An input encoding file for latin-5 (a.k.a. ISO 8859-9) has been added.
Example use:
groff -Tdvi -mlatin5 my_file > my_file.dvi
Note that some output devices don't support all glyphs of this encoding.
o If the `return' request is called with an argument, it exits twice,
namely the current macro and the macro one level higher. This is
used to define a wrapper macro for `return' in trace.tmac.
o For completeness, two new requests have been added: `dei1' and `ami1'.
They are equivalent to `dei' and `ami', respectively, but the macros
are executed with compatibility mode off (similar to `de1' and `am1').
o New command line option `-I' to specify a directory for files (both
those on the command line and those named in `psbb' requests). This is
also handled by the groff wrapper program.
o Since version 1.19 you can say `.vs 0'. Older versions emit a warning
and convert this to `.vs \n[.V]'.
This hasn't been documented properly. Note that `.vs 0' isn't saved in a
diversion since it doesn't result in vertical motion.
Pic
___
o Dashed and dotted ellipses have been implemented.
Tbl
---
o New key character `x' to make tbl call a user-defined macro on a table
cell. Patch by Heinz-Jürgen Oertel <hj.oertel@surfeu.de>.
Grohtml
-------
o New option `-j' to emit output splitted into multiple files.
Grops
-----
o New command line option `-I' to specify a directory to search for files
on the command line and files named in \X'ps: import' and \X'ps: file'
escapes. This is also handled by the groff wrapper program.
o The default value for the `broken' keyword in the DESC file is now 0.
Grolj4
------
o A new man page `lj4_font(5)' documents how fonts are accessed with
grolj4.
o The built-in fonts for LJ4 and newer PCL 5 devices have been completely
revised, mainly to access as much glyphs as possible. The provided
metric files should be compatible with recent PCL 5 printers also.
Additionally, font description files have been added for the Arial and
Times New Roman family, the MS symbol, and Wingdings fonts.
Hpftodit
--------
o Completely revised to handle HP TrueType metric files also. See the
hpftodit manual page for more details.
Macro Packages
--------------
o www.tmac: New macro `JOBNAME' to split output into multiple files.
o In mdoc, multiple calls to `.Lb' are now supported in the LIBRARY
section.
Diffstat (limited to 'gnu/dist/groff/src/libs/libgroff/searchpath.cpp')
| -rw-r--r-- | gnu/dist/groff/src/libs/libgroff/searchpath.cpp | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/gnu/dist/groff/src/libs/libgroff/searchpath.cpp b/gnu/dist/groff/src/libs/libgroff/searchpath.cpp index 228ebb0cb36..3421b6d01f3 100644 --- a/gnu/dist/groff/src/libs/libgroff/searchpath.cpp +++ b/gnu/dist/groff/src/libs/libgroff/searchpath.cpp @@ -1,7 +1,7 @@ -/* $NetBSD: searchpath.cpp,v 1.1.1.1 2003/06/30 17:52:06 wiz Exp $ */ +/* $NetBSD: searchpath.cpp,v 1.1.1.2 2004/07/30 14:44:51 wiz Exp $ */ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -25,6 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdlib.h> #include <assert.h> +#include <errno.h> #include "searchpath.h" #include "nonposix.h" @@ -77,11 +78,11 @@ void search_path::command_line_dir(const char *s) char *p = dirs; p += old_len - init_len; if (init_len == 0) - *p++ = PATH_SEP[0]; + *p++ = PATH_SEP_CHAR; memcpy(p, s, slen); p += slen; if (init_len > 0) { - *p++ = PATH_SEP[0]; + *p++ = PATH_SEP_CHAR; memcpy(p, old + old_len - init_len, init_len); p += init_len; } @@ -105,7 +106,7 @@ FILE *search_path::open_file(const char *name, char **pathp) unsigned namelen = strlen(name); char *p = dirs; for (;;) { - char *end = strchr(p, PATH_SEP[0]); + char *end = strchr(p, PATH_SEP_CHAR); if (!end) end = strchr(p, '\0'); int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0; @@ -132,3 +133,62 @@ FILE *search_path::open_file(const char *name, char **pathp) } return 0; } + +FILE *search_path::open_file_cautious(const char *name, char **pathp, + const char *mode) +{ + if (!mode) + mode = "r"; + bool reading = (strchr(mode, 'r') != 0); + if (name == 0 || strcmp(name, "-") == 0) { + if (pathp) + *pathp = strsave(reading ? "stdin" : "stdout"); + return (reading ? stdin : stdout); + } + if (!reading || IS_ABSOLUTE(name) || *dirs == '\0') { + FILE *fp = fopen(name, mode); + if (fp) { + if (pathp) + *pathp = strsave(name); + return fp; + } + else + return 0; + } + unsigned namelen = strlen(name); + char *p = dirs; + for (;;) { + char *end = strchr(p, PATH_SEP_CHAR); + if (!end) + end = strchr(p, '\0'); + int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0; + char *path = new char[(end - p) + need_slash + namelen + 1]; + memcpy(path, p, end - p); + if (need_slash) + path[end - p] = '/'; + strcpy(path + (end - p) + need_slash, name); +#if 0 + fprintf(stderr, "trying `%s'\n", path); +#endif + FILE *fp = fopen(path, mode); + if (fp) { + if (pathp) + *pathp = path; + else + a_delete path; + return fp; + } + int err = errno; + a_delete path; + if (err != ENOENT) + { + errno = err; + return 0; + } + if (*end == '\0') + break; + p = end + 1; + } + errno = ENOENT; + return 0; +} |
