summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorwlemb <wlemb>2003-02-11 06:13:24 +0000
committerwlemb <wlemb>2003-02-11 06:13:24 +0000
commitd3814db0947c5475b56b975c30a9f0b914588381 (patch)
treec208231dac6d0e645f068405228bbfc4e3acb975 /src/include
parent4d6149fde2dce77b3787b54c5db9793c6d7a47c6 (diff)
downloadgroff-d3814db0947c5475b56b975c30a9f0b914588381.tar.gz
Improve error messages for `x F' (and `F') commands.
* src/include/error.h: Add declaration for `current_source_filename'. * src/libs/libgroff/filename.cc: Add `current_source_filename'. * src/libs/libgroff/error.cc (do_error_with_file_and_line): Add parameter for source file string. Updated all callers. * src/libs/libdriver/input.cc: Add `current_source_filename'. (remember_source_filename): New function. (parse_x_command <'F'>, do_file <'F'>): Use it. Make grotty not emit warnings about unknown colors more than necessary. * src/devices/grotty/tty.cc: Include `ptable.h'. (TTY_MAX_COLORS): Removed. (DEFAULT_COLOR_IDX): Defined to -1. (glyph): Change `back_color_idx' and `fore_color_idx' to `char'. (tty_printer): Change `curr_back_idx' and `curr_fore_idx' to `char'. Change `tty_colors' to be a ptable. First arg of `put_color' is now `char'. New functions `make_rgb_string' and `tty_color'. (tty_printer::tty_printer): Use `tty_color'. (tty_printer::color_to_idx): Return value is now `char'. Use `tty_color'. * src/include/color.h (color): Add `print_color' member function. * src/libs/libgroff/color.cc (color::print_color): Implement it. Valgrind fixes. * src/devices/grops/ps.cc (ps_printer::define_encoding): Close encoding file. * src/include/ptable.h (PTABLE::~PTABLE, PTABLE::define): Always assume that value has been allocated with `new[]', thus use `a_delete' for deallocation. * src/libs/libdriver/input.cc (get_integer_arg, get_possibly_int_args, parse_x_command, do_file): Use `a_delete' where appropriate. * src/libs/libgroff/new.cc (delete) [!COOKIE_BUG]: Define. * src/libs/libgroff/nametoindex.cc (character_indexer::named_char_index): Use `new <type>[1]'. * src/preproc/eqn/lex.cc (init_table, do_definition): Use `new <type>[1]'. * src/preproc/eqn/text.cc (set_special_char_type): Ditto. (split_text): Use `a_delete'. * src/preproc/pic/pic.y (define_label, define_variable): Use `new <type>[1]'. * src/roff/troff/env.cc (environment::choose_breakpoint): Avoid harmless memory leak. (hyphen_trie::read_patterns_file): Initialize `buf'. * src/roff/troff/node.cc (troff_output_file::troff_output_file): Initialize `current_fill_color'and `current_glyph_color'. * src/roff/troff/glyphuni.cc (glyph_to_unicode_init::glyph_to_unicode_init): Use `new <type>[1]'. * src/roff/troff/uniuni.cc (unicode_decompose_init::unicode_decompose_init): Ditto. * src/roff/troff/uniglyph.cc (unicode_to_glyph_init::unicode_to_glyph_init): Ditto.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/color.h6
-rw-r--r--src/include/error.h4
-rw-r--r--src/include/ptable.h11
3 files changed, 13 insertions, 8 deletions
diff --git a/src/include/color.h b/src/include/color.h
index 6888da17..2985647e 100644
--- a/src/include/color.h
+++ b/src/include/color.h
@@ -2,9 +2,9 @@
/* <groff_src_dir>/src/include/color.h
-Last update: 10 Apr 2002
+Last update: 9 Feb 2003
-Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Gaius Mulley <gaius@glam.ac.uk>
This file is part of groff.
@@ -71,6 +71,8 @@ public:
void get_cmyk(unsigned int *c, unsigned int *m,
unsigned int *y, unsigned int *k) const;
void get_gray(unsigned int *g) const;
+
+ char *print_color();
};
#define Cyan components[0]
diff --git a/src/include/error.h b/src/include/error.h
index d26e2c70..e227682b 100644
--- a/src/include/error.h
+++ b/src/include/error.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -55,4 +55,4 @@ extern void warning(const char *,
extern const char *program_name;
extern int current_lineno;
extern const char *current_filename;
-
+extern const char *current_source_filename;
diff --git a/src/include/ptable.h b/src/include/ptable.h
index dc56add0..ffbe8e6f 100644
--- a/src/include/ptable.h
+++ b/src/include/ptable.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1990, 1991, 1992, 2003 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -67,6 +67,10 @@ public: \
};
+// Keys (which are strings) are allocated and freed by PTABLE.
+// Values must be allocated by the caller (always using new[], not new)
+// and are freed by PTABLE.
+
#define implement_ptable(T) \
\
PASSOC(T)::PASSOC(T)() \
@@ -84,7 +88,7 @@ PTABLE(T)::~PTABLE(T)() \
{ \
for (unsigned i = 0; i < size; i++) { \
a_delete v[i].key; \
- delete v[i].val; \
+ a_delete v[i].val; \
} \
a_delete v; \
} \
@@ -98,7 +102,7 @@ void PTABLE(T)::define(const char *key, T *val) \
v[n].key != 0; \
n = (n == 0 ? size - 1 : n - 1)) \
if (strcmp(v[n].key, key) == 0) { \
- delete v[n].val; \
+ a_delete v[n].val; \
v[n].val = val; \
return; \
} \
@@ -165,4 +169,3 @@ int PTABLE_ITERATOR(T)::next(const char **keyp, T **valp) \
} \
return 0; \
}
-