summaryrefslogtreecommitdiff
path: root/src/roff/troff/env.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [troff]: Trivially refactor ("number_reg_dic...").G. Branden Robinson2022-12-071-14/+14
| | | | | | | | | | | | | | | | | | Rename `number_reg_dictionary` to `register_dictionary`. It's shorter _and_ non-abbreviated _and_ matches our documentation. * src/roff/troff/column.cpp (init_column_requests): * src/roff/troff/div.cpp (page_number, init_div_requests): * src/roff/troff/env.cpp (print_env, init_env_requests) (init_hyphen_requests): * src/roff/troff/input.cpp (length_request, interpolate_number_format) (do_register, do_if_request, main, init_registers) (init_input_requests): * src/roff/troff/node.cpp (get_register, init_node_requests): * src/roff/troff/reg.cpp (top level, define_number_reg (inline_define_reg, alter_format, remove_reg, alias_reg, rename_reg) (print_number_regs): * src/roff/troff/reg.h: Do it.
* [troff]: Implement new `.nn` registerG. Branden Robinson2022-11-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ...to report the remaining count of lines to have their numbering suppressed. * src/roff/troff/env.h (class environment): Declare new member function `get_no_number_count()`. * src/roff/troff/env.cpp (get_no_number_count): Define new member function, returning value of member variable `no_number_count`. (init_env_requests): Define new ".nn" register and attach it to `get_no_number_count()`. * doc/groff.texi (Miscellaneous): Document it. Include example of use to determine whether current output line will be numbered. Also clarify meaning of register; `.nn` is not decremented except when output line numbering is enabled. * man/groff.7.man (Read-only registers): Document it. * src/roff/groff/tests/dot-nn_register_works.sh: Test it. * src/roff/groff/groff.am (groff_TESTS): Run test. * NEWS: Add item. See <https://lists.gnu.org/archive/html/groff/2022-11/msg00153.html>.
* [troff, ...]: Trivially refactor.G. Branden Robinson2022-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | | Boolify and rename internal library function from `invalid_input_char` to `is_invalid_input_char`. * src/include/lib.h: Do it. * src/libs/libgroff/font.cpp (text_file::next_line): * src/preproc/eqn/lex.cpp (file_input::read_line): * src/preproc/eqn/main.cpp (read_line, main): * src/preproc/pic/lex.cpp (file_input::read_line, simple_file_input::get, simple_file_input::peek): * src/preproc/pic/main.cpp (top_input::get, top_input::peek, do_file): * src/preproc/refer/command.cpp (input_stack::push_file): * src/preproc/refer/refer.cpp (do_file, do_bib): * src/roff/troff/env.cpp (environment::make_tag): * src/roff/troff/input.cpp (file_iterator::fill, file_iterator::peek) (get_char_for_escape_parameter, transparent_translate, read_request) (asciify, input_char_description, read_string, transparent_file) (set_string): Update call sites.
* [troff]: Tweak diagnostic messages.G. Branden Robinson2022-09-251-3/+3
| | | | | | | | | | | | | | | | * src/roff/troff/input.cpp (non_empty_name_warning): Say "identifier", not "name", in diagnostic message; it can be thrown for attempted assignments to invalid register identifiers, and some of our documentation refers to identifiers in the name space shared by requests, macros, strings, and diversions as "names". * src/roff/troff/env.cpp (hyphen_trie::read_patterns_file): * src/roff/troff/input.cpp (get_char_for_escape_parameter) (token::usable_as_delimiter, non_empty_name_warning, pipe_source) (psbb_locator::psbb_locator, open_request, opena_request) (define_class, pipe_output, system_request): Consistently say "_is_ not allowed". The zero copula poses too great a risk of incomprehension IMO.
* [troff]: Fix Savannah #62941.G. Branden Robinson2022-08-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/roff/troff/env.cpp (environment::set_family): Throw error if user requests a font family that (when combined with the current style) can't be resolved to a real font name. Fixes a regression introduced by me in commit d8cb8cf9d8, 2021-09-15, arising from a revision of font selection logic in node.cpp to enable a bunch of _other_ font error diagnostics. Fixes <https://savannah.gnu.org/bugs/?62941>. Thanks to Dave Kemper for the report and two useful end points for a bisection. Here's an illustration of groff 1.22.4 and Git HEAD diagnostics. $ nl EXPERIMENTS/font-errors.groff 1 .uf Z 2 .uf 99 3 .fschar Z \[co] COPYRIGHT 4 .fschar 99 \[co] COPYRIGHT 5 .rfschar Z \[co] 6 .rfschar 99 \[co] 7 .special Y 8 .special 98 9 .fspecial Z Y 10 .fspecial 99 Y 11 .fzoom Z 12 .fzoom 99 13 .bd Z 3 14 .bd 99 3 15 .bd S Z 3 16 .bd S 99 3 17 .bd 98 Z 3 18 .bd 98 99 3 19 .tkf Z 20 .tkf 99 21 .cs Z 22 .cs 99 23 .fam BOGUS $ groff -z EXPERIMENTS/font-errors.groff troff: EXPERIMENTS/font-errors.groff:1: warning: can't find font 'Z' troff: EXPERIMENTS/font-errors.groff:2: bad font number troff: EXPERIMENTS/font-errors.groff:4: bad font number troff: EXPERIMENTS/font-errors.groff:6: bad font number troff: EXPERIMENTS/font-errors.groff:7: warning: can't find font 'Y' troff: EXPERIMENTS/font-errors.groff:8: bad font number troff: EXPERIMENTS/font-errors.groff:10: bad font number troff: EXPERIMENTS/font-errors.groff:12: bad font number troff: EXPERIMENTS/font-errors.groff:14: bad font number troff: EXPERIMENTS/font-errors.groff:17: bad font number troff: EXPERIMENTS/font-errors.groff:18: bad font number troff: EXPERIMENTS/font-errors.groff:20: bad font number troff: EXPERIMENTS/font-errors.groff:22: bad font number troff: EXPERIMENTS/font-errors.groff:23: warning: can't find font 'BOGUSR' $ ./build/test-groff -z EXPERIMENTS/font-errors.groff troff:EXPERIMENTS/font-errors.groff:1: error: cannot load font 'Z' to make it the underline font troff:EXPERIMENTS/font-errors.groff:2: error: cannot load font at position 99 to make it the underline font troff:EXPERIMENTS/font-errors.groff:3: error: cannot load font 'Z' to define font-specific fallback glyph troff:EXPERIMENTS/font-errors.groff:4: error: cannot load font at position 99 to define font-specific fallback glyph troff:EXPERIMENTS/font-errors.groff:5: error: cannot load font 'Z' to remove font-specific fallback glyph troff:EXPERIMENTS/font-errors.groff:6: error: cannot load font at position 99 to remove font-specific fallback glyph troff:EXPERIMENTS/font-errors.groff:7: error: cannot load font 'Y' to mark it as special troff:EXPERIMENTS/font-errors.groff:8: error: cannot load font at position 98 to mark it as special troff:EXPERIMENTS/font-errors.groff:9: error: cannot load font 'Z' to mark other fonts as special contingently upon it troff:EXPERIMENTS/font-errors.groff:10: error: cannot load font at position 99 to mark other fonts as special contingently upon it troff:EXPERIMENTS/font-errors.groff:11: error: cannot load font 'Z' to set a zoom factor for it troff:EXPERIMENTS/font-errors.groff:12: error: cannot load font at position 99 to set a zoom factor for it troff:EXPERIMENTS/font-errors.groff:13: error: cannot load font 'Z' for emboldening troff:EXPERIMENTS/font-errors.groff:14: error: cannot load font at position 99 for emboldening troff:EXPERIMENTS/font-errors.groff:15: error: cannot load font 'Z' for conditional emboldening troff:EXPERIMENTS/font-errors.groff:16: error: cannot load font at position 99 for conditional emboldening troff:EXPERIMENTS/font-errors.groff:17: error: cannot load font at position 98 for emboldening troff:EXPERIMENTS/font-errors.groff:18: error: cannot load font at position 98 for emboldening troff:EXPERIMENTS/font-errors.groff:19: error: cannot load font 'Z' for track kerning troff:EXPERIMENTS/font-errors.groff:20: error: cannot load font at position 99 for track kerning troff:EXPERIMENTS/font-errors.groff:21: error: cannot load font 'Z' for constant spacing troff:EXPERIMENTS/font-errors.groff:22: error: cannot load font at position 99 for constant spacing troff:EXPERIMENTS/font-errors.groff:23: error: no font family named 'BOGUS' exists
* src/roff/troff/env.cpp: Add some paranoia.G. Branden Robinson2022-08-231-1/+10
| | | | | | | | * src/roff/troff/env.cpp (environment::set_family): Add some paranoia. Add `assert()`s on the previous font mounting position still being valid and the font family dictionary lookup not returning a null pointer. Add an early return for the latter case (which should be impossible).
* [troff]: Throw warning when ignoring font change.G. Branden Robinson2022-06-211-1/+3
| | | | | | | | | | | [troff]: Throw warning in font category when a font selection escape sequence is used after the output line continuation escape sequence on an input line, because it is ignored. * src/roff/troff/env.cpp (environment::set_font): Do it. * doc/groff.texi (Warnings): * src/roff/troff/troff.1.man (Warnings): Document it.
* src/roff/troff/env.cpp (font_change): Boolify.G. Branden Robinson2022-06-211-3/+3
|
* [troff]: Warn if nonexistent font name selected.G. Branden Robinson2022-06-211-2/+5
| | | | | | | | | | | * src/roff/troff/env.cpp (font_change): * src/roff/troff/input.cpp (token::next): Warn upon selection of a nonexistent font name. Fixes <https://savannah.gnu.org/bugs/?62656>. Also annotate a null pointer to ease any future transition to C++11, which defines a keyword for it.
* [troff]: Make environment::set_font return a bool.G. Branden Robinson2022-06-211-8/+12
| | | | | | | | | | [troff]: Revise `environment::set_font` to return Boolean value indicating success of font selection operation. * src/roff/troff/env.cpp (environment::set_font): * src/roff/troff/env.h (environment::set_font): Do it. This prepares the way for a fix for Savannah #62656.
* [troff,grohtml,grops,grotty]: Update diag msgs.G. Branden Robinson2022-06-061-2/+2
| | | | | | | | | | | [troff, grohtml, grops, grotty]: Update wording of diagnostic messages to refer to "motion quantum" rather than "resolution" where appropriate. * src/devices/grohtml/post-html.cpp (html_printer::html_printer): * src/devices/grops/ps.cpp (ps_printer::ps_printer): * src/devices/grotty/tty.cpp (tty_printer::set_char, tty_printer::add_char, tty_printer::end_page): * src/roff/troff/env.cpp (line_length, title_length): Do it.
* [troff]: Tweak diagnostic message.G. Branden Robinson2022-05-211-1/+1
| | | | | | | * src/roff/troff/env.cpp (environment::choose_breakpoint): Tweak diagnostic message ("can't" -> "cannot"). * doc/groff.texi (Breaking): Update example.
* [troff]: Slightly refactor (boolify).G. Branden Robinson2021-12-251-1/+1
| | | | | | | | | | | | | * src/roff/troff/div.cpp: * src/roff/troff/env.cpp: * src/roff/troff/input.cpp: Rename variables and demote from `int` to `bool`. Initialize and assign them using Boolean literals. The new names try harder to express a logical predicate, and start with verbs to resist interpretation as noun phrases. - exit_started -> is_exit_underway - done_end_macro -> is_end_macro_finished - seen_last_page_ejector (demoted but not renamed) - began_page_in_end_macro (demoted but not renamed)
* [troff]: Clarify diagnostic warning.G. Branden Robinson2021-11-051-1/+1
| | | | | | | | * src/roff/troff/env.cpp (environment::set_font): Clarify diagnostic warning. Also tweak style in libgroff diagnostic message; we say "non-negative" (with a hard hyphen) everywhere else.
* Fix Savannah #61348.G. Branden Robinson2021-10-191-2/+3
| | | | | | | | | | | * src/roff/troff/env.cpp (distribute_space): Revert an `assert()` I added in commit b93eacd8d7 (5 September); we can indeed reach this code with a negative amount of desired space, and in fact the "show hyphenation points" trick <https://froude.eu/groff/examples/hyphenation-points.html> relies upon it. Add explanatory comment. Fixes <https://savannah.gnu.org/bugs/?61348>.
* [troff]: Tweak diagnostic message.G. Branden Robinson2021-09-231-1/+2
| | | | The novice user might wonder "family of what?".
* [troff]: Clamp negative tab stop positions to 0.G. Branden Robinson2021-09-111-4/+7
| | | | | | | | | | | | | | | | | ...instead of throwing an assertion failure. * src/roff/troff/env.cpp (tab_stops::distance_to_next_tab): Replace `assert` with clamping logic, ensuring that `lastpos` can never be negative. While negative tab stop positions don't make much sense (they result in zero horizontal motion), user input like `.ta T -5` should never provoke an assertion failure. (set_tabs): Throw range warning in additional scenario, viz., if a repeating tab offset is negative. Fixes <https://bugs.debian.org/990406>. Thanks to наб for the report. Also wrap nearby long source lines.
* [troff]: Boolify `set_tabs` function.G. Branden Robinson2021-09-111-6/+6
| | | | | | | | * src/roff/troff/env.cpp (set_tabs): Demote local variables from `int` to `bool` and give them predicate-like names. - `first` -> `is_first_stop` - `repeated` -> `is_repeating_stop` Use Boolean instead of integer literals in assignments to them.
* [troff]: Boolify members of `token` class.G. Branden Robinson2021-09-061-24/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/roff/troff/token.h (class token): Demote return type of several member functions from `int` to `bool` and rename them. - `backspace` -> `is_backspace` - `delimiter` -> `usable_as_delimiter` - `dummy` -> `is_dummy` - `eof` -> `is_eof` - `horizontal_space` -> `is_horizontal_space` - `hyphen_indicator` -> `is_hyphen_indicator` - `leader` -> `is_leader` - `left_brace` -> `is_left_brace` - `newline` -> `is_newline` - `page_ejector` -> `is_page_ejector` - `right_brace` -> `is_right_brace` - `space` -> `is_space` - `special` -> `is_special` - `stretchable_space` -> `is_stretchable_space` - `tab` -> `is_tab` - `transparent_dummy` -> `is_transparent_dummy` - `transparent` -> `is_transparent` - `unstretchable_space` -> `is_unstretchable_space` - `white_space` -> `is_white_space` - `zero_width_break` -> `is_zero_width_break` (class token): Drop 1991 comment anticipating that member function `nspaces` could return "2" for a "double space"; this was apparently never implemented. (class token): Drop parameter names from declarations; the prevailing style (familiar from Stroustrup) is not to use them. (token::is_special): Simplify implementation. * src/roff/troff/input.cpp (has_arg, token::usable_as_delimiter): Update definitions of above member functions not defined in token.h. * src/roff/troff/div.cpp (begin_page, space_request, need_space, output_saved_vertical_space, flush_output): * src/roff/troff/env.cpp (fill, no_fill, center, right_justify, indent, temporary_indent, margin_character, number_lines, do_break_request, hyphen_word): * src/roff/troff/input.cpp (next_file, do_overstrike, do_bracket, do_name_test, do_expr_test, do_zero_width, token::skip, has_arg, skip_line, empty_name_warning, non_empty_name_warning, do_get_long_name, process_input_stack, flush_pending_lines, decode_args, read_request, do_define_string, do_define_character, remove_character, do_define_macro, length_request, get_delim_number, get_line_arg, read_size, get_delim_name, do_register, do_width, read_title_parts, encode_char, do_special, device_request, output_request, skip_alternative, begin_alternative, nop_request, do_if_request, do_source, pipe_source, ps_bbox_request, tag, taga, do_terminal, do_translate, hyphenation_code, hyphenation_patterns_file_code, define_class, get_optional_char, check_missing_character, abort_request, copy_file, transparent_file, do_macro_source, charinfo_to_node_list, read_draw_node, read_color_draw_node): * src/roff/troff/node.cpp (get_fontno, remove_font_special_character, bold_font): * src/roff/troff/number.cpp (start_number, parse_term): * src/roff/troff/reg.cpp (define_number_reg, alter_format): Update call sites to use new names. * src/roff/troff/input.cpp (token::usable_as_delimiter, read_draw_node): Return Boolean, not integer, literals. Also add editor aid comments to ends of files lacking them. Remove old-style Emacs file-local local variable at file beginnings. Also fix white space nits.
* [troff]: Clamp line, title lengths to hor res.G. Branden Robinson2021-09-061-6/+10
| | | | | | | | [troff]: Clamp line and title lengths to device horizontal resolution. * src/roff/troff/env.cpp (line_length, title_length): Do it. Prompted by <https://savannah.gnu.org/bugs/?61089>.
* src/roff/troff/env.cpp: Refactor slightly.G. Branden Robinson2021-09-061-3/+3
| | | | | | | | * src/roff/troff/env.cpp (do_hyphenation_patterns_file): Refactor slightly. Demote `append` from `int` to `bool`. (hyphenation_patterns_file, hyphenation_patterns_file_append): Update call sites to use Boolean, not integer, literals.
* src/roff/troff/env.cpp: Further slightly refactor.G. Branden Robinson2021-09-061-9/+7
| | | | | | | * src/roff/troff/env.cpp (do_underline_special): - Relocate function to avoid forward reference. - Mark function as static to eliminate external linkage. Remove now-unnecessary prototype.
* src/roff/troff/env.cpp: Refactor slightly.G. Branden Robinson2021-09-061-8/+8
| | | | | | | | | | * src/roff/troff/env.cpp (do_underline_special): Refactor slightly. - Rename `underline_spaces` -> `do_underline_spaces`. - Demote it from an `int` to a `bool`. Update prototype. - Use ternary operator and explicit character literals when writing device control command instead of doing arithmetic on a character literal. - Update call sites to use Boolean literals.
* src/roff/troff/env.cpp: Refactor slightly.G. Branden Robinson2021-09-051-11/+24
| | | | | | | | | | | | | | | * src/roff/troff/env.cpp (distribute_space): Refactor slightly. - Rename `force_reverse` to `force_reverse_node_list`. - Rename `reverse` to `do_reverse`. - Demote both of the above from `int` to `bool`. - Use Boolean literals with them. - Add assertions to enforce positive values of `nspaces` and `desired_space`. - Remove now-rendundant test for `nspaces` being positive. - Add explanatory comments. (environment::wrap_up_field): Update call sites of `distribute_space` when non-default value of `force_reverse_node_list` is supplied.
* [troff]: Don't adjust nonadjustable lines.G. Branden Robinson2021-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This means that the direction from which an output line in adjustment mode "b" (or its "n" synonym) is filled with supplemental space is not changed if that output line does not require adjustment. This will result in whitespace changes to documents using that adjustment mode, and these changes will be plainly visible on low-resolution output devices like terminals. To illustrate, in the following "A" means an output line requiring adjustment; "F" a line that is "full" and does not; and "L" and "R" indicate distribution of adjustment spaces from the left and right, respectively. groff 1.22.4 groff 1.23.0 ------------ ------------ A L A L A R A R F L F R A R A L * src/roff/troff/env.cpp (distribute_space): Return early if either the amount of desired space to be distributed or the count of space nodes in the output line to distribute it among is zero. * tmac/tests/an_TH-repairs-ad-damage.sh: Update test to expect space to be distributed differently. Fixes <https://savannah.gnu.org/bugs/?61089> and <https://savannah.gnu.org/bugs/index.php?60673>.
* [troff]: Tweak diagnostic message.G. Branden Robinson2021-08-291-1/+1
| | | | | * src/roff/troff/env.cpp (environment::environment): Use terminology more rigorously in diagnostic.
* [libgroff]: Drop `a_delete` preprocessor wrapper.G. Branden Robinson2021-08-281-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... for the `delete` operator. It has been rendered unnecessary by the removal of support for ancient C++ compilers. * src/include/lib.h (a_delete): Drop symbol definition. * src/devices/grohtml/output.cpp (word::~word): * src/devices/grohtml/post-html.cpp (char_block::char_block, assert_state::~assert_state, assert_state::add, assert_state::close, replace_negate_str): * src/devices/grops/ps.cpp (ps_font::ps_font, subencoding::subencoding, ps_printer::define_encoding, ps_printer::encode_fonts): * src/devices/grops/psrm.cpp (resource_manager::document_setup, resource_manager::supply_resource): * src/devices/grotty/tty.cpp (tty_printer::tty_color, tty_printer::tty_printer, tty_printer::color_to_idx, tty_printer::add_char): * src/include/itable.h (ITABLE(T)::~ITABLE(T), ITABLE(T)::define): * src/include/ptable.h (PTABLE(T)::~PTABLE(T), PTABLE(T)::define): * src/libs/libbib/index.cpp (index_search_item::~index_search_item, make_index_search_item, index_search_item_iterator::index_search_item_iterator, index_search_item::get_tag, index_search_item::munge_filename, index_search_item::search): * src/libs/libbib/linear.cpp (bmpattern::~bmpattern, file_buffer::file_buffer, file_buffer::load, linear_searcher::linear_searcher, linear_searcher::~linear_searcher): * src/libs/libbib/search.cpp (search_list_iterator::search_list_iterator, search_item::search_item): * src/libs/libdriver/input.cpp (IntArray::~IntArray, IntArray::append, StringBuf::~StringBuf, StringBuf::append, get_integer_arg, parse_x_command, do_file): * src/libs/libdriver/printer.cpp (printer::printer, printer::load_font, text_file::~text_file, text_file::next, font::~font, font_widths_cache::~font_widths_cache, font:alloc_ch_index, font::extend_ch, font::compact, font::load_desc): * src/libs/libgroff/fontfile.cpp (font::open_file): * src/libs/libgroff/relocate.cpp (searchpath, searchpathext, set_current_prefix): * src/libs/libgroff/searchpath.cpp (search_path::search_path, search_path::command_line_dir, search_path::open_file, search_path::open_file_cautious): * src/libs/libgroff/string.cpp (sfree, srealloc, string::remove_spaces): * src/libs/libgroff/symbol.cpp (symbol::symbol, concat): * src/libs/libgroff/tmpfile.cpp (temp_init::temp_init, xtmpfile_list_init::~xtmpfile_list_init, xtmpfile): * src/preproc/eqn/box.cpp (set_gfont, set_grfont, set_gbfont, box_list::append, box_list::~box_list): * src/preproc/eqn/delim.cpp (make_delim_box, delim_box::~delim_box): * src/preproc/eqn/eqn.ypp (number): * src/preproc/eqn/lex.ypp (file_input::~file_input, argument_macro_input::~argument_macro_input): * src/preproc/eqn/pile.ypp (matrix_box::~matrix_box, matrix_box::append): * src/preproc/eqn/special.cpp (special_box::~special_box): * src/preproc/eqn/text.ypp (set_char_type): * src/preproc/html/pre-html.cpp (get_line, scanArguments): * src/preproc/pic/object.cpp (output::~output, output::set_args, text_item::~text_item, object_spec::~object_spec, command_object::~command_object, line_object::~line_object): * src/preproc/pic/pic.ypp (placeless_element, reset_variables, print_args, text_expr, object_spec, text, sprintf_args, path): * src/preproc/refer/command.cpp (input_item::~input_item, input_item::peek_char): * src/preproc/refer/label.ypp (lookup_label): * src/preproc/refer/refer.cpp (store_citation, store_reference): * src/preproc/tbl/main.cpp (format::add_rows, format::~format): * src/preproc/tbl/table.cpp (block_entry::~block_entry, table::~table, table::allocate): * src/roff/groff/groff.cpp (possible_command::~possible_command, possible_command::clear_name): * src/roff/troff/column.cpp (justification_spec::~justification_spec, justification_spec::append): * src/roff/troff/dictionary.cpp (dictionary::lookup): * src/roff/troff/env.cpp (override_sizes, tab_stops::to_string, hyphen_word, hyphen_trie::insert_hyphenation): * src/roff/troff/input.cpp (read_long_escape_name, token::next, do_get_long_name, temp_iterator::~temp_iterator, get_delim_name, pipe_source, read_string, pipe_output, system_request, open_mac_file, do_macro_source, do_register_assignment, do_string_assignment, read_draw_node, copy_mode_error): * src/roff/troff/node.cpp (troff_output_file::set_font, troff_output_file::~troff_output_file, draw_node::is_tag, grow_font_table, font_family::~font_family, font_family::make_definite): * src/utils/hpftodit/hpftodit.cpp (name_list::~name_list, read_map): * src/utils/indxbib/indxbib.cpp (main, get_cwd): * src/utils/tfmtodit/tfmtodit.cpp (tfm::~tfm, tfm::load): Port uses of `a_delete(xxx)` to `delete[]`.
* Resolve GCC compiler warnings.G. Branden Robinson2021-08-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Resolve compiler warnings relating to format string security and ISO C++98 conformance. * src/preproc/eqn/delim.cpp (define_extensible_string): * src/preproc/pic/pic.ypp (do_sprintf): Use #pragma to silence GCC "format-nonliteral" warning and explain why our usage is safe in a comment. * src/preproc/preconv/preconv.cpp (detect_file_encoding): Use `l` modifier to `%u` `fprintf()` conversion instead of `z`, and cast return values of `size_t` to unsigned long; "ISO C++98 does not support the ‘z’ gnu_printf length modifier" (it doesn't support `ll` either). N.B. this is debugging output only. * src/roff/groff/groff.cpp (synopsis): * src/roff/troff/input.cpp (usage): Repeat variadic argument for `%s` conversion in `fprintf()` call because "ISO C++98 does not support %n$ operand number formats". * src/roff/troff/env.cpp: Initialize adjustment and hyphenation mode enums without commas at the end of the enumeration lists.
* [troff]: Refactor `get_value` member functions.G. Branden Robinson2021-07-291-12/+12
| | | | | | | | | | | | | | | | | | | Given their names and popular "getter/setter" paradigms from many OO languages, the return type is misleading. Change it from `int` to `bool` since it returns only a success/failure status and modifies an argument (passed by reference) to deliver the requested data. * src/roff/troff/reg.h (reg, variable_reg): * src/roff/troff/div.cpp (page_offset_reg, page_length_reg, vertical_position_reg, high_water_mark_reg, distance_to_next_trap_reg, page_number_reg, no_space_mode_reg): * src/roff/troff/env.cpp (int_env_reg, vunits_env_reg, hunits_env_reg, horizontal_place_reg): * src/roff/troff/input.cpp (writable_lineno_reg): * src/roff/troff/reg.cpp (reg, number_reg, variable_reg): Update class and member function definitions to reflect the new type. Update member function definitions to return appropriate Boolean literals instead of 0 and 1.
* [troff]: Refactor environment handling.G. Branden Robinson2021-07-131-78/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [troff]: Refactor environment initialization, switching, and copying. * src/roff/troff/env.cpp: Rename struct `env_list` to `env_list_node` since it describes a node of a singly-linked list. Remove constant `NENVIRONMENTS` and array `env_table`. Add static symbol `default_environment_name` to replace string literal. (init_environments): Stop initializing `curenv` through `env_table`. Use `default_environment_name` for that initialization and add the default environment to `env_dictionary`. (environment_switch): Simplify. Shorten "dummy environment" diagnostic message. Stop creating an integer-named environment inside the `env_table` array, only falling through to use the `env_dictionary` if the named environment is not a valid integer or if the array is full. Instead use `env_dictionary` always. Drop no longer needed `pop` quasi-Boolean integer with extra state to suppress environment stack underflow errors. Instead report the error if underflow occurs, regardless of any other circumstance. (environment_copy): Simplify. Stop searching the `env_table` array for an environment to copy from, only falling through to use the `env_dictionary` if the named environment is not a valid integer or if the array is full. Instead search `env_dictionary` always. Emit "no environment specified to copy from" diagnostic only if the `evc` request is given no argument. If the source environment to copy from is given but not found, emit a new diagnostic naming the nonexistent environment. Fix bug: stop returning early if no copying could be done; instead fall through to the end of the function, which calls `skip_line()` and prevents anything on the remainder of the (invalid) control line from being interpreted. Problem dates back to commit da3b7137, 6 March 2000 (groff 1.16). Fixes <https://savannah.gnu.org/bugs/?60913>.
* [troff]: Slightly refactor.G. Branden Robinson2021-07-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the source code slightly more accessible by using a `bool` type for a function's default parameter used as a Boolean, and comment it at call sites where the default is overridden. See also commit d56e0f1d, 25 June. * src/roff/troff/token.h (get_name, get_long_name): Change type of parameter from `int` to `bool` and default from 0 to `false`. * src/roff/troff/input.cpp (do_get_long_name, empty_name_warning, get_name, get_long_name): Change type of parameter from `int` to `bool` in declarations and definitions. * src/roff/troff/column.cpp (column_justify): * src/roff/troff/div.cpp (diversion_trap): * src/roff/troff/env.cpp (environment_switch, environment_copy, do_input_trap, set_hyphenation_language, do_hyphenation_patterns_file): * src/roff/troff/input.cpp (define_color, composite_request, do_define_string, do_define_macro, rename_macro, alias_macro, chop_macro, do_string_case_transform, substring_request, length_request, asciify_macro, unformat_macro, do_register, device_macro_request, do_if_request, do_source, ps_bbox_request, do_open, close_request, do_write_request, write_macro_request, define_class, copy_file, vjustify, transparent_file, do_macro_source): * src/roff/troff/node.cpp (font_translate, font_position, style, get_fontno): * src/roff/troff/reg.cpp (define_number_reg, inline_define_reg, alter_format, alias_reg, rename_reg): Update call sites. Add comment indicating meaning of parameter.
* [troff]: Slightly refactor token::get_char().G. Branden Robinson2021-06-251-1/+1
| | | | | | | | | | | | | | | | | | [troff]: Slightly refactor. Make the source code slightly more accessible by using a `bool` type for a member function's default parameter used as a Boolean, and comment it at call sites where the default is overridden. * src/roff/troff/token.h (token::get_char): Change type of parameter from `int` to `bool` and default from 0 to `false`. * src/roff/troff/input.cpp (token::get_char): Update definition. * src/roff/troff/env.cpp (hyphen_word): * src/roff/troff/node.cpp (remove_font_special_character): * src/roff/troff/input.cpp (do_overstrike, do_bracket, next, do_define_character, remove_character, get_line_arg, encode_char, do_if_request, do_translate, char_flags, hyphenation_code, define_class): Update call sites. Add comment indicating meaning of parameter.
* Implement new read-only register ".nm".G. Branden Robinson2021-02-251-0/+6
| | | | | | | | | | | | | | | | | | | | | It reports the enablement status of output line numbering (caused by the .nm request) irrespective of the temporary suspension of numbering with the .nn request. Needed because there was no way to introspect its state, tbl(1) needs to do so, and the writable line number register \n[ln] is not a reliable proxy for it. * src/roff/troff/env.h: Add get_numbering_nodes(), returning `int`, to public interface of `environment` class. * src/roff/troff/env.cpp: Implement get_numbering_nodes(). * src/roff/groff/tests/dot-nm_register_works.sh: Test it. * src/roff/groff/groff.am (groff_TESTS): Run test. * doc/groff.texi (Miscellaneous): * man/groff_diff.7.man (Language/New number registers): * man/groff.7.man (Registers/Read-only registers): Document it. * NEWS: Add item.
* [troff]: Ignore out-of-range .ad argument.G. Branden Robinson2021-01-261-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/roff/troff/env.cpp: Add ADJUST_MAX enumeration constant to record maximum valid numerical adjustment mode. (adjust): Verify numeric argument against ADJUST_MAX instead of numeric literal. Ignore excessively large values instead of setting adjustment mode to "right". Update warning diagnostic. This is a behavior change, albeit to how an invalid argument is interpreted. What we call "AT&T troff" in our documentation is a reference to CSTR #54 in its 1992 revision, which we use as a specification because source code to the implementations was not freely available. Because the above circumstance is out-of-spec, "AT&T troff" says nothing about it and offers no precedent. Given that, let's have a look at what other *roffs do. * V7 Unix troff ignored invalid adjustment modes of all kinds, falling off the end of a switch with no default case. * DWB, Plan 9, and Solaris troff make no changes to V7 Unix troff here. * Heirloom Doctools troff and Neatroff extend the range of valid numeric arguments to support paragraph-at-a-time formatting. * Neatroff furthermore supports an '.ad k' mode for support of keshideh/kadisha justification of cursive scripts. GNU troff's historical behavior here does not seem useful, and prepares users poorly for adjustment modes groff may support in the future.
* Update copyright1.23.0.rc1Bertrand Garrigues2020-11-111-1/+1
| | | | | | | | * update-copyright.sh: use gnulib's 'update-copyright' script. Pass this script in directories 'arch', 'contrib', 'font', 'man', 'tmac', 'src' and on a list of extra files. * FOR-RELEASE: mention this point.
* Revert "Update copyright"Bertrand Garrigues2020-10-251-1/+1
| | | | | | This reverts commit a2e955e07354c83939fabffebcf720d3333d1f6b. Some files (COPYING, FDL, bootstrap) should not have been updated
* Update copyrightBertrand Garrigues2020-10-251-1/+1
| | | | | | | | Use gnulib's update-copyright script. * src/roff/groff/groff.cpp: update the printf displayed when 'groff -v' is invoked. * FOR-RELEASE: mention this point.
* src/roff/troff/env.cpp: Remove straggling line.G. Branden Robinson2020-10-221-1/+0
| | | | | Should have been part of commit bcdf2f4c7c28328c711c6a7ac2ea17f2ecd5cdd4 on 21 October.
* src/roff/troff/env.cpp: Avoid infinite loop.G. Branden Robinson2020-10-211-0/+14
| | | | | | | | | | * src/roff/troff/env.cpp (environment::possibly_break_line): Emit break warning and return if the output width is not positive. The code assumes that it will be and loops infinitely if it isn't. I _think_ this is because we're not able to get width data for (some?) CJK glyphs. Based on a patch by Osamu Sayama. Fixes <https://savannah.gnu.org/bugs/index.php?44018>.
* Fix assertion failure on negative space size.G. Branden Robinson2020-05-091-2/+9
| | | | | | | | | | | * src/roff/troff/env.cpp (space_size): If an argument to the .ss request is negative, throw a range warning and ignore it. * src/roff/groff/tests/regression_savannah_58337.sh: Add test. * src/roff/groff/groff.am: Run test. Fixes https://savannah.gnu.org/bugs/index.php?58337.
* s/legal/valid/.Werner Lemberg2018-11-051-1/+1
|
* Update copyright (use gnulib's update-copyright script)Bertrand Garrigues2018-07-031-1/+1
|
* Improve diagnostics on bad hyphenation requests.G. Branden Robinson2018-05-071-3/+14
| | | | | | | | | | | | src/roff/troff/env.cpp: * Warn about hyphenation request values that are completely out out of range; report accepted range (caveat: much of the "legal" range is still rejected due to bad semantics). * Report bad hyphenation request value in diagnostic messages. Thanks to Ralph Corderoy and Werner Lemberg for the code reviews. Signed-off-by: G. Branden Robinson <g.branden.robinson@gmail.com>
* Minor comment fix.Werner Lemberg2018-03-041-1/+1
|
* Hyphenation exceptions in pattern files now obey `.hy' (#53196).Werner Lemberg2018-03-021-24/+65
| | | | | | | | | * src/roff/troff/env.cpp (hyphen_trie::read_patterns_file): Mark `\hyphenation' entries with a trailing space. (hyphen_trie::insert_hyphenation): Updated. (hyphenate): Make `\hyphenation' entries obey `.hy' restrictions. * doc/groff.texi (.hy): Updated.
* Fix some problems related to hyphenation.Werner Lemberg2018-03-011-9/+31
|
* * src/roff/troff/env.cpp: s/HYPHEN_/HYPHEN_NOT/ for clarification.Werner Lemberg2018-02-281-9/+13
|
* src: Fix `quote style' in comments and plaintext.G. Branden Robinson2017-11-091-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/include/include.am: * src/libs/libbib/libbib.am: * src/libs/libdriver/libdriver.am: * src/libs/libgroff/libgroff.am: * src/libs/libxutil/libxutil.am: * src/roff/groff/groff.am: * src/roff/grog/grog.am: * src/roff/troff/troff.am: * src/utils/addftinfo/addftinfo.am: * src/utils/afmtodit/afmtodit.am: * src/utils/hpftodit/hpftodit.am: + Update and parallelize editor aid comments. * src/include/font.h: * src/libs/libdriver/input.cpp: * src/libs/libgroff/glyphuni.cpp * src/libs/libgroff/quotearg.c: * src/libs/libgroff/spawnvp.c: * src/preproc/grn/main.cpp: * src/preproc/pic/object.cpp: * src/roff/troff/dictionary.cpp: * src/roff/troff/div.cpp: * src/roff/troff/token.h: * src/roff/troff/troff.am: + Remove trailing whitespace from lines near other changes. Signed-off-by: G. Branden Robinson <g.branden.robinson@gmail.com>
* src: Migrate diagnostics away from `these quotes'.G. Branden Robinson2017-11-091-14/+14
| | | | | | Fix bug https://savannah.gnu.org/bugs/?52374. Signed-off-by: G. Branden Robinson <g.branden.robinson@gmail.com>
* Put two spaces between sentences in GPL notice.G. Branden Robinson2017-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | Fixes half of Savannah #51609 but applies it much more generally. This is a wide-ranging change, but it makes these notices consistent with modern copies of the GPLv3 text. (Some of these files are not GPLv3, but that's where the boilerplate comes from; GPLv2 and LGPLv2.x used semicolons to separate these clauses instead.) If the next resync with Autotools regresses some of these, well, that's a bug in Autotools. I checked with wc -L, and no file grew its longest line to 81 characters due to this change. contrib/hdtbl/hdmisc.tmac-u only: Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is> Blame me for the rest. Signed-off-by: G. Branden Robinson <g.branden.robinson@gmail.com>