[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Strange error messages from Groff 1.22.3
From: |
Eli Zaretskii |
Subject: |
Re: [Groff] Strange error messages from Groff 1.22.3 |
Date: |
Mon, 17 Nov 2014 21:13:50 +0200 |
Ping!
> Date: Mon, 10 Nov 2014 17:08:21 +0200
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
>
> > Date: Sun, 09 Nov 2014 08:46:21 +0100 (CET)
> > Cc: address@hidden
> > From: Werner LEMBERG <address@hidden>
> >
> >
> > >> I was imagining something primitive, e.g. a working equivalent to
> > >>
> > >> #if defined(__MSDOS__) || (defined(_WIN32) && !defined(__CYGWIN__))
> > >> # define DOS2UNIX_FILENAME(f) dos2unix_filename(f)
> > >> #else
> > >> # define DOS2UNIX_FILENAME(f) (f)
> > >> #endif
> > >
> > > But then the non-Windows code will have to call strsave and strcpy
> > > unnecessarily, because we cannot modify 'const char *' strings. If
> > > that's okay with you, doing the above is easy; I was trying not to
> > > incur that overhead on Posix platforms.
> >
> > Well, `do_file' is the function called in the top-level loop, called
> > once per file, thus the overhead is very small – and the slight
> > degradation of efficiency in `table.cpp' is OK with me.
> >
> > I suggest to use a `string' object for the filename string so that we
> > have automatic deallocation; dos2unix_file can then use a `string &'
> > parameter to get a slight C++ touch :-)
>
> OK, here's take 2, hope you like it better:
>
> 2014-11-10 Eli Zaretskii <address@hidden>
>
> * src/preproc/soelim/soelim.cpp (do_file):
> * src/preproc/refer/refer.cpp (do_file):
> * src/preproc/preconv/preconv.cpp (do_file):
> * src/preproc/pic/main.cpp (do_file):
> * src/preproc/eqn/main.cpp (do_file): Call normalize_for_lf to
> convert backslashes in the file name being processed to forward
> slashes.
>
> * src/include/lib.h (normalize_for_lf): Add prototype.
>
> * src/preproc/eqn/eqn.h:
> * src/preproc/pic/pic.h:
> * src/preproc/refer/refer.h:
> * src/preproc/tbl/table.h: Include stringclass.h before lib.h.
>
> * src/libs/libgroff/lf.cpp (normalize_for_lf): New function.
>
> * src/roff/groff/groff.cpp (append_arg_to_string)
> [_WIN32 && !__CYGWIN__]: Use only ".." for quoting in native
> Windows builds.
>
> --- src/include/lib.h~0 2014-11-04 10:38:35.161524000 +0200
> +++ src/include/lib.h 2014-11-10 16:39:53.801000000 +0200
> @@ -99,6 +99,7 @@
> size_t path_name_max();
>
> int interpret_lf_args(const char *p);
> +void normalize_for_lf (string &fn);
>
> extern char invalid_char_table[];
>
>
>
> --- src/libs/libgroff/lf.cpp~0 2014-11-04 10:38:35.170524000 +0200
> +++ src/libs/libgroff/lf.cpp 2014-11-10 16:40:10.644750000 +0200
> @@ -19,9 +19,9 @@ along with this program. If not, see <ht
>
> #include <ctype.h>
>
> +#include "stringclass.h"
> #include "lib.h"
> #include "cset.h"
> -#include "stringclass.h"
>
> extern void change_filename(const char *);
> extern void change_lineno(int);
> @@ -60,3 +60,15 @@ int interpret_lf_args(const char *p)
> change_lineno(ln);
> return 1;
> }
> +
> +void normalize_for_lf (string &fn)
> +{
> +#if defined(__MSDOS__) || (defined(_WIN32) && !defined(__CYGWIN__))
> + int fnlen = fn.length();
> + for (int i = 0; i < fnlen; i++)
> + {
> + if (fn[i] == '\\')
> + fn[i] = '/';
> + }
> +#endif
> +}
>
>
> --- src/preproc/eqn/main.cpp~0 2014-11-04 10:38:35.232523000 +0200
> +++ src/preproc/eqn/main.cpp 2014-11-10 16:46:14.160375000 +0200
> @@ -18,7 +18,6 @@ You should have received a copy of the G
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> #include "eqn.h"
> -#include "stringclass.h"
> #include "device.h"
> #include "searchpath.h"
> #include "macropath.h"
> @@ -66,9 +65,12 @@ void do_file(FILE *fp, const char *filen
> {
> string linebuf;
> string str;
> + string fn(filename);
> + fn += '\0';
> + normalize_for_lf(fn);
> + current_filename = fn.contents();
> if (output_format == troff)
> - printf(".lf 1 %s\n", filename);
> - current_filename = filename;
> + printf(".lf 1 %s\n", current_filename);
> current_lineno = 0;
> while (read_line(fp, &linebuf)) {
> if (linebuf.length() >= 4
>
>
>
>
> --- src/preproc/pic/main.cpp~0 2014-11-04 10:38:35.226523000 +0200
> +++ src/preproc/pic/main.cpp 2014-11-10 16:29:15.113500000 +0200
> @@ -309,8 +309,11 @@ void do_file(const char *filename)
> fatal("can't open `%1': %2", filename, strerror(errno));
> }
> }
> - out->set_location(filename, 1);
> - current_filename = filename;
> + string fn(filename);
> + fn += '\0';
> + normalize_for_lf(fn);
> + current_filename = fn.contents();
> + out->set_location(current_filename, 1);
> current_lineno = 1;
> enum { START, MIDDLE, HAD_DOT, HAD_P, HAD_PS, HAD_l, HAD_lf } state =
> START;
> for (;;) {
>
>
> --- src/preproc/preconv/preconv.cpp~0 2014-11-04 10:38:35.214524000 +0200
> +++ src/preproc/preconv/preconv.cpp 2014-11-10 16:40:41.644750000 +0200
> @@ -17,6 +17,7 @@ for more details.
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +#include "stringclass.h"
> #include "lib.h"
>
> #include <assert.h>
> @@ -26,7 +27,6 @@ along with this program. If not, see <ht
> #include "error.h"
> #include "localcharset.h"
> #include "nonposix.h"
> -#include "stringclass.h"
>
> #include <locale.h>
>
> @@ -1065,8 +1065,12 @@ do_file(const char *filename)
> }
> if (debug_flag)
> fprintf(stderr, " encoding used: `%s'\n", encoding);
> - if (!raw_flag)
> - printf(".lf 1 %s\n", filename);
> + if (!raw_flag) {
> + string fn(filename);
> + fn += '\0';
> + normalize_for_lf(fn);
> + printf(".lf 1 %s\n", fn.contents());
> + }
> int success = 1;
> // Call converter (converters write to stdout).
> if (!strcasecmp(encoding, "ISO-8859-1"))
>
>
> --- src/preproc/refer/refer.cpp~0 2014-11-04 10:38:35.245523000 +0200
> +++ src/preproc/refer/refer.cpp 2014-11-10 16:45:51.019750000 +0200
> @@ -432,8 +432,11 @@ static void do_file(const char *filename
> return;
> }
> }
> - current_filename = filename;
> - fprintf(outfp, ".lf 1 %s\n", filename);
> + string fn(filename);
> + fn += '\0';
> + normalize_for_lf(fn);
> + current_filename = fn.contents();
> + fprintf(outfp, ".lf 1 %s\n", current_filename);
> string line;
> current_lineno = 0;
> for (;;) {
>
>
> --- src/preproc/soelim/soelim.cpp~0 2014-11-04 10:38:35.250523000 +0200
> +++ src/preproc/soelim/soelim.cpp 2014-11-10 16:46:51.394750000 +0200
> @@ -17,6 +17,7 @@ for more details.
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +#include "stringclass.h"
> #include "lib.h"
>
> #include <ctype.h>
> @@ -25,7 +26,6 @@ along with this program. If not, see <ht
> #include <errno.h>
> #include "errarg.h"
> #include "error.h"
> -#include "stringclass.h"
> #include "nonposix.h"
> #include "searchpath.h"
>
> @@ -161,6 +161,7 @@ int do_file(const char *filename)
> error("can't open `%1': %2", whole_filename.contents(), strerror(err));
> return 0;
> }
> + normalize_for_lf(whole_filename);
> current_filename = whole_filename.contents();
> current_lineno = 1;
> set_location();
>
>
> --- src/preproc/tbl/main.cpp~0 2014-11-04 10:38:35.220524000 +0200
> +++ src/preproc/tbl/main.cpp 2014-11-10 16:31:23.629125000 +0200
> @@ -1615,7 +1615,10 @@ int main(int argc, char **argv)
> fatal("can't open `%1': %2", argv[i], strerror(errno));
> else {
> current_lineno = 1;
> - current_filename = argv[i];
> + string fn(argv[i]);
> + fn += '\0';
> + normalize_for_lf(fn);
> + current_filename = fn.contents();
> printf(".lf 1 %s\n", current_filename);
> process_input_file(fp);
> }
>
>
> --- src/preproc/tbl/table.cpp~0 2014-11-04 10:38:35.221524000 +0200
> +++ src/preproc/tbl/table.cpp 2014-11-10 16:33:40.785375000 +0200
> @@ -2966,7 +2966,10 @@ void set_troff_location(const char *fn,
> && strcmp(fn, last_filename) == 0)
> printfs(".lf %1\n", as_string(ln));
> else {
> - printfs(".lf %1 %2\n", as_string(ln), fn);
> + string filename(fn);
> + filename += '\0';
> + normalize_for_lf(filename);
> + printfs(".lf %1 %2\n", as_string(ln), filename.contents());
> last_filename = fn;
> location_force_filename = 0;
> }
>
>
> --- src/roff/groff/groff.cpp~0 2014-11-04 10:38:35.195524000 +0200
> +++ src/roff/groff/groff.cpp 2014-11-08 11:45:38.738500000 +0200
> @@ -701,7 +701,13 @@ void append_arg_to_string(const char *ar
> {
> str += ' ';
> int needs_quoting = 0;
> + // Native Windows programs don't support '..' style of quoting, so
> + // always behave as if ARG included the single quote character.
> +#if defined(_WIN32) && !defined(__CYGWIN__)
> + int contains_single_quote = 1;
> +#else
> int contains_single_quote = 0;
> +#endif
> const char*p;
> for (p = arg; *p != '\0'; p++)
> switch (*p) {
> @@ -731,10 +737,17 @@ void append_arg_to_string(const char *ar
> str += '"';
> for (p = arg; *p != '\0'; p++)
> switch (*p) {
> +#if !(defined(_WIN32) && !defined(__CYGWIN__))
> case '"':
> case '\\':
> case '$':
> str += '\\';
> +#else
> + case '"':
> + case '\\':
> + if (*p == '"' || (*p == '\\' && p[1] == '"'))
> + str += '\\';
> +#endif
> // fall through
> default:
> str += *p;
> --- src/preproc/eqn/eqn.h~0 2014-11-04 10:38:35.232523000 +0200
> +++ src/preproc/eqn/eqn.h 2014-11-10 16:46:06.707250000 +0200
> @@ -17,6 +17,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +#include "stringclass.h"
> #include "lib.h"
>
> #include <assert.h>
>
>
> --- src/preproc/pic/pic.h~0 2014-11-04 10:38:35.226523000 +0200
> +++ src/preproc/pic/pic.h 2014-11-10 16:43:16.426000000 +0200
> @@ -17,6 +17,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +#include "stringclass.h"
> #include "lib.h"
>
> #include <math.h>
> @@ -49,7 +50,6 @@
>
> #include "assert.h"
> #include "cset.h"
> -#include "stringclass.h"
> #include "errarg.h"
> #include "error.h"
> #include "position.h"
>
>
> --- src/preproc/refer/refer.h~0 2014-11-04 10:38:35.245523000 +0200
> +++ src/preproc/refer/refer.h 2014-11-10 16:45:55.613500000 +0200
> @@ -17,6 +17,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +#include "stringclass.h"
> #include "lib.h"
>
> #include <stdlib.h>
> @@ -25,7 +26,6 @@
>
> #include "errarg.h"
> #include "error.h"
> -#include "stringclass.h"
> #include "cset.h"
> #include "cmap.h"
>
>
>
> --- src/preproc/tbl/table.h~0 2014-11-04 10:38:35.221524000 +0200
> +++ src/preproc/tbl/table.h 2014-11-10 16:41:24.972875000 +0200
> @@ -17,6 +17,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> +#include "stringclass.h"
> #include "lib.h"
>
> #include <stdlib.h>
> @@ -26,7 +27,6 @@
>
> #include "cset.h"
> #include "cmap.h"
> -#include "stringclass.h"
> #include "errarg.h"
> #include "error.h"
>
>
>
>
- Re: [Groff] Strange error messages from Groff 1.22.3, (continued)
- Re: [Groff] Strange error messages from Groff 1.22.3, Werner LEMBERG, 2014/11/09
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/10
- Re: [Groff] Strange error messages from Groff 1.22.3, Ralph Corderoy, 2014/11/10
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3, Ralph Corderoy, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3, Keith Marshall, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3, Ralph Corderoy, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/11
- Re: [Groff] Strange error messages from Groff 1.22.3,
Eli Zaretskii <=
- Re: [Groff] Strange error messages from Groff 1.22.3, Werner LEMBERG, 2014/11/19
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/20
- Re: [Groff] Strange error messages from Groff 1.22.3, Werner LEMBERG, 2014/11/20
- Re: [Groff] Strange error messages from Groff 1.22.3, Keith Marshall, 2014/11/20
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/20
- Re: [Groff] Strange error messages from Groff 1.22.3, Werner LEMBERG, 2014/11/21
- Re: [Groff] Strange error messages from Groff 1.22.3, Ralph Corderoy, 2014/11/21
- Re: [Groff] Strange error messages from Groff 1.22.3, Jones, Larry, 2014/11/21
- Re: [Groff] Strange error messages from Groff 1.22.3, Mike Bianchi, 2014/11/21
- Re: [Groff] Strange error messages from Groff 1.22.3, Eli Zaretskii, 2014/11/22