[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Better locale macro file handling?
From: |
Colin Watson |
Subject: |
Re: [Groff] Better locale macro file handling? |
Date: |
Thu, 19 Feb 2009 17:19:40 +0000 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Thu, Feb 19, 2009 at 12:11:15PM +0000, Colin Watson wrote:
> On Wed, Feb 18, 2009 at 08:10:24AM +0100, Werner LEMBERG wrote:
> > Colin Watson wrote:
> > > And, as you say, it is unfortunate from a backward compatibility
> > > point of view: man-db would probably end up having to detect the
> > > version of groff, since otherwise it would cause a warning on every
> > > single manual page unless the macro file is present (which will be
> > > the clear majority of pages).
> >
> > Then use the `.warn' request directly. If the `range' warning
> > (value 64) isn't set, `.warn' doesn't emit a warning if you supply a
> > value larger than WARN_TOTAL.
>
> I hadn't thought of .warn; thanks. In that case simply feeding in this
> preamble will work:
>
> .warn (\n[.warn] - (\n[.warn] / 64 % 2 * 64))
> .warn (\n[.warn] + 1048576 - (\n[.warn] / 1048576 % 2 * 1048576))
Of course this enables the new 'file' warning rather than disabling it;
which further reminds me that I forgot to enable WARN_FILE by default in
my previous patch. I've appended an updated patch to this mail.
That said: even with this, .warn alone doesn't help to avoid stderr spew
with older versions of groff. Since .mso currently emits an error, that
means old groff will still say:
.warn (\n[.warn] - (\n[.warn] / 64 % 2 * 64))
.warn (\n[.warn] - (\n[.warn] / 1048576 % 2 * 1048576))
.mso foo.tmac
<standard input>:3: can't find macro file `foo.tmac'
I think I need to do something like this instead (having discovered that
I can check groff's version at run-time):
.if (\n[.g] & (\n[.x] > 1) & ((\n[.x] == 1) & (\n[.y] >= 20)) & ((\n[.x] ==
1) & (\n[.y] == 20) & (\n[.Y] >= 2))) \{
. warn (\n[.warn] - (\n[.warn] / 1048576 % 2 * 1048576))
. mso foo.tmac
.\}
2009-02-19 Colin Watson <address@hidden>
Add a new `file' warning category.
* src/roff/troff/troff.h (warning_type): Add WARN_FILE.
* src/roff/troff/input.cpp (DEFAULT_WARNING_MASK): Include
WARN_FILE.
(macro_source): Convert error on missing macro file to a
warning.
* NEWS, doc/groff.texinfo (I/O, Warnings): Document new warning
category.
=== modified file 'NEWS'
--- NEWS 2009-02-14 17:21:35 +0000
+++ NEWS 2009-02-19 16:52:02 +0000
@@ -20,6 +20,10 @@ o The new `lsm' request specifies a macr
registers `lsn' and `lss' hold the number of removed leading spaces and
the corresponding horizontal space, respectively.
+o There is a new warning category `file', enabled by default. The `mso'
+ request emits warnings in this category when the requested macro file does
+ not exist.
+
VERSION 1.20.1
==============
=== modified file 'doc/groff.texinfo'
--- doc/groff.texinfo 2009-02-14 17:21:35 +0000
+++ doc/groff.texinfo 2009-02-19 16:37:08 +0000
@@ -13122,6 +13122,8 @@ for the specified @var{file} in the same
the the @option{-m} command line option. If the file name to be
included has the form @address@hidden and it isn't found,
@code{mso} tries to include @address@hidden and vice versa.
+If the file does not exist, a warning of type @samp{file} is emitted.
address@hidden, for information about warnings.
@endDefreq
@DefreqList {trf, file}
@@ -14172,6 +14174,11 @@ conditions that are errors when they do
@itemx 524288
Color related warnings.
address@hidden file
address@hidden 1048576
+Missing files. The @code{mso} request gives this warning when the
+requested macro file does not exist. This is enabled by default.
+
@item all
All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
intended that this covers all warnings that are useful with traditional
=== modified file 'src/roff/troff/input.cpp'
--- src/roff/troff/input.cpp 2009-02-14 17:21:35 +0000
+++ src/roff/troff/input.cpp 2009-02-19 16:37:30 +0000
@@ -59,7 +59,7 @@ extern "C" {
#ifndef DEFAULT_WARNING_MASK
// warnings that are enabled by default
#define DEFAULT_WARNING_MASK \
- (WARN_CHAR|WARN_NUMBER|WARN_BREAK|WARN_SPACE|WARN_FONT)
+ (WARN_CHAR|WARN_NUMBER|WARN_BREAK|WARN_SPACE|WARN_FONT|WARN_FILE)
#endif
// initial size of buffer for reading names; expanded as necessary
@@ -7367,7 +7367,7 @@ void macro_source()
a_delete path;
}
else
- error("can't find macro file `%1'", nm.contents());
+ warning(WARN_FILE, "can't find macro file `%1'", nm.contents());
tok.next();
}
}
=== modified file 'src/roff/troff/troff.h'
--- src/roff/troff/troff.h 2009-01-05 20:10:29 +0000
+++ src/roff/troff/troff.h 2009-02-17 11:37:40 +0000
@@ -75,11 +75,12 @@ enum warning_type {
WARN_SPACE = 0200000,
WARN_FONT = 0400000,
WARN_IG = 01000000,
- WARN_COLOR = 02000000
+ WARN_COLOR = 02000000,
+ WARN_FILE = 04000000
// change WARN_TOTAL if you add more warning types
};
-const int WARN_TOTAL = 03777777;
+const int WARN_TOTAL = 07777777;
int warning(warning_type, const char *,
const errarg & = empty_errarg,
--
Colin Watson address@hidden
- [Groff] Better locale macro file handling?, Colin Watson, 2009/02/16
- Re: [Groff] Better locale macro file handling?, Werner LEMBERG, 2009/02/17
- Re: [Groff] Better locale macro file handling?, Colin Watson, 2009/02/17
- Re: [Groff] Better locale macro file handling?, Werner LEMBERG, 2009/02/18
- Re: [Groff] Better locale macro file handling?, Colin Watson, 2009/02/19
- Re: [Groff] Better locale macro file handling?, Ralph Corderoy, 2009/02/19
- Re: [Groff] Better locale macro file handling?,
Colin Watson <=
- Re: [Groff] Better locale macro file handling?, Werner LEMBERG, 2009/02/21
- Re: [Groff] Better locale macro file handling?, Colin Watson, 2009/02/21