3 Copyright (C) 2020-2021 Free Software Foundation, Inc.
5 This file is part of Bison, the GNU Compiler Compiler.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
25 #include <attribute.h>
29 #include <unicodeio.h>
35 glyph_buffer_t down_arrow
;
44 const char *derivation_separator
= " ";
45 int derivation_separator_width
= 1;
55 on_success (const char *buf
, size_t buflen
, void *callback_arg
)
57 callback_arg_t
*arg
= (callback_arg_t
*) callback_arg
;
58 assert (buflen
+ 1 < sizeof *arg
->pbuf
);
59 *stpncpy (*arg
->pbuf
, buf
, buflen
) = '\0';
64 on_failure (unsigned code MAYBE_UNUSED
, const char *msg MAYBE_UNUSED
,
67 callback_arg_t
*arg
= (callback_arg_t
*) callback_arg
;
68 assert (strlen (arg
->fallback
) + 1 < sizeof *arg
->pbuf
);
69 strcpy (*arg
->pbuf
, arg
->fallback
);
74 glyph_set (glyph_buffer_t
*glyph
, int *width
,
75 unsigned code
, const char *fallback
)
77 callback_arg_t arg
= { glyph
, fallback
};
78 int res
= unicode_to_mb (code
, on_success
, on_failure
, &arg
);
79 *width
= mbswidth (*glyph
, 0);
86 glyph_set (&arrow
, &arrow_width
, 0x2192, "->");
87 glyph_set (&dot
, &dot_width
, 0x2022, ".");
88 glyph_set (&down_arrow
, &down_arrow_width
, 0x21b3, "`->");
89 glyph_set (&empty
, &empty_width
, 0x03b5, "%empty");
91 strncat (down_arrow
, " ", sizeof down_arrow
- strlen (down_arrow
) - 1);
92 down_arrow_width
+= 1;