Skip to content

Commit

Permalink
Format error messages as for LaTeX2e
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Oct 17, 2018
1 parent f57e8f8 commit c181678
Show file tree
Hide file tree
Showing 107 changed files with 4,841 additions and 11,590 deletions.
21 changes: 6 additions & 15 deletions l3experimental/l3str/testfiles/m3str-convert002.luatex.tlg
Expand Up @@ -171,22 +171,13 @@ TRUE
TEST 8: iso encoding
============================================================
(l3str-enc-iso88592.def)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "str/encode-8-bit"
!
! Unicode string cannot be converted to encoding 'iso88592'.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................
! LaTeX3 Error: Unicode string cannot be converted to encoding 'iso88592'.
For immediate help type H <return>.
...
l. ... }
|'''''''''''''''''''''''''''''''''''''''''''''''
| The encoding 'iso88592' only contains a subset of all Unicode characters.
| LaTeX was asked to convert a string to that encoding, but that string
| contains a character that 'iso88592' does not support.
|...............................................
The encoding 'iso88592' only contains a subset of all Unicode characters.
LaTeX was asked to convert a string to that encoding, but that string contains
a character that 'iso88592' does not support.
TRUE
FALSE
============================================================
Expand Down
40 changes: 11 additions & 29 deletions l3experimental/l3str/testfiles/m3str-convert002.tlg
Expand Up @@ -154,21 +154,12 @@ TEST 5: From utf8 to native
============================================================
(l3str-enc-utf8.def)
TRUE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "str/native-overflow"
!
! Character code too large for this engine.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................
! LaTeX3 Error: Character code too large for this engine.
For immediate help type H <return>.
...
l. ... }
|'''''''''''''''''''''''''''''''''''''''''''''''
| This engine only support 8-bit characters: valid character codes are in the
| range [0,255]. To manipulate arbitrary Unicode, use LuaTeX or XeTeX.
|...............................................
This engine only support 8-bit characters: valid character codes are in the
range [0,255]. To manipulate arbitrary Unicode, use LuaTeX or XeTeX.
TRUE
============================================================
============================================================
Expand All @@ -186,22 +177,13 @@ TRUE
TEST 8: iso encoding
============================================================
(l3str-enc-iso88592.def)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "str/encode-8-bit"
!
! Unicode string cannot be converted to encoding 'iso88592'.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................
! LaTeX3 Error: Unicode string cannot be converted to encoding 'iso88592'.
For immediate help type H <return>.
...
l. ... }
|'''''''''''''''''''''''''''''''''''''''''''''''
| The encoding 'iso88592' only contains a subset of all Unicode characters.
| LaTeX was asked to convert a string to that encoding, but that string
| contains a character that 'iso88592' does not support.
|...............................................
The encoding 'iso88592' only contains a subset of all Unicode characters.
LaTeX was asked to convert a string to that encoding, but that string contains
a character that 'iso88592' does not support.
TRUE
FALSE
============================================================
Expand Down
21 changes: 6 additions & 15 deletions l3experimental/l3str/testfiles/m3str-convert002.xetex.tlg
Expand Up @@ -171,22 +171,13 @@ TRUE
TEST 8: iso encoding
============================================================
(l3str-enc-iso88592.def)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "str/encode-8-bit"
!
! Unicode string cannot be converted to encoding 'iso88592'.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................
! LaTeX3 Error: Unicode string cannot be converted to encoding 'iso88592'.
For immediate help type H <return>.
...
l. ... }
|'''''''''''''''''''''''''''''''''''''''''''''''
| The encoding 'iso88592' only contains a subset of all Unicode characters.
| LaTeX was asked to convert a string to that encoding, but that string
| contains a character that 'iso88592' does not support.
|...............................................
The encoding 'iso88592' only contains a subset of all Unicode characters.
LaTeX was asked to convert a string to that encoding, but that string contains
a character that 'iso88592' does not support.
TRUE
FALSE
============================================================
Expand Down
4 changes: 4 additions & 0 deletions l3kernel/CHANGELOG.md
Expand Up @@ -12,6 +12,10 @@ this project uses date-based 'snapshot' version identifiers.
- `\g_msg_module_documentation_prop` (see #471)
- `\peek_remove_spaces:n`

### Changed

- Formatting of messages: now follows LaTeX2e closely

### Deprecated

- `\mg_interrupt:nn`, `\msg_log:n` and `\msg_term:n`
Expand Down
129 changes: 68 additions & 61 deletions l3kernel/l3msg.dtx
Expand Up @@ -148,7 +148,7 @@
% Produces the standard text
% \begin{quote}
% \ttfamily
% Fatal \meta{module} error
% Fatal Package \meta{module} Error
% \end{quote}
% This function can be redefined to alter the language in which the
% message is given, using |#1| as the name of the \meta{module} to
Expand All @@ -162,7 +162,7 @@
% Produces the standard text
% \begin{quote}
% \ttfamily
% Critical \meta{module} error
% Critical Package \meta{module} Error
% \end{quote}
% This function can be redefined to alter the language in which the
% message is given, using |#1| as the name of the \meta{module} to
Expand All @@ -176,7 +176,7 @@
% Produces the standard text
% \begin{quote}
% \ttfamily
% \meta{module} error
% Package \meta{module} Error
% \end{quote}
% This function can be redefined to alter the language in which the
% message is given, using |#1| as the name of the \meta{module} to
Expand Down Expand Up @@ -671,65 +671,86 @@
%
% \subsection{Showing messages: low level mechanism}
%
% \begin{macro}{\@@_interrupt:nnn}
% \begin{macro}{\@@_interrupt:Nnnn}
% The low-level interruption macro is rather opaque, unfortunately.
% Depending on the availability of more information there is a choice
% of how to set up the further help. We feed the extra help text and
% the message itself to a wrapping auxiliary, in this order because we
% must first setup \TeX{}'s \tn{errhelp} register before issuing an
% \tn{errmessage}.
% \begin{macrocode}
\cs_new_protected:Npn \@@_interrupt:nnn #1#2#3
\cs_new_protected:Npn \@@_interrupt:Nnnn #1#2#3#4
{
\tl_if_empty:nTF {#3}
\str_set:Nx \l_@@_text_str { #1 {#2} }
\str_set:Nx \l_@@_name_str { \msg_module_name:n {#2} }
\tl_if_empty:nTF {#4}
{
\@@_interrupt_wrap:nn { \\ \c_@@_no_info_text_tl }
{#1 \\\\ #2 \\\\ \c_@@_continue_text_tl }
\@@_interrupt_wrap:nnn {#3}
{ \c_@@_continue_text_tl }
{ \c_@@_no_info_text_tl }
}
{
\@@_interrupt_wrap:nn { \\ #3 }
{#1 \\\\ #2 \\\\ \c_@@_help_text_tl }
\@@_interrupt_wrap:nnn {#3}
{ \c_@@_help_text_tl }
{#4}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_interrupt_wrap:nn}
% \begin{macro}{\@@_interrupt_more_text:n}
% \begin{macro}{\@@_interrupt_wrap:nnn}
% \begin{macro}{\@@_interrupt_text:n, \@@_interrupt_more_text:n}
% First setup \TeX{}'s \tn{errhelp} register with the extra help |#1|,
% then build a nice-looking error message with |#2|. Everything is
% done using \texttt{x}-type expansion as the new line markers are
% different for the two type of text and need to be correctly set up.
% The auxiliary \cs{@@_interrupt_more_text:n} receives its argument
% as a line-wrapped string, which is thus unaffected by expansion.
% We ave to split the main text into two parts as only the \enquote{message}
% itself is wrapped with a leader: the generic help is wrapped at full
% width. We also have to allow for the two characters used by \tn{errmessage}
% itself.
% \begin{macrocode}
\cs_new_protected:Npn \@@_interrupt_wrap:nn #1#2
\cs_new_protected:Npn \@@_interrupt_wrap:nnn #1#2#3
{
\iow_wrap:nnnN {#1} { | ~ } { } \@@_interrupt_more_text:n
\iow_wrap:nnnN {#2} { ! ~ } { } \@@_interrupt_text:n
\iow_wrap:nnnN { \\ #3 } { } { } \@@_interrupt_more_text:n
\group_begin:
\int_sub:Nn \l_iow_line_count_int { 2 }
\iow_wrap:nxnN { \l_@@_text_str : ~ #1 }
{
( \l_@@_name_str )
\prg_replicate:nn
{
\str_count:N \l_@@_text_str
- \str_count:N \l_@@_name_str
+ 2
}
{ ~ }
}
{ } \@@_interrupt_text:n
\iow_wrap:nnnN { \l_@@_tmp_tl \\ \\ #2 } { } { }
\@@_interrupt:n
}
\cs_new_protected:Npn \@@_interrupt_more_text:n #1
\cs_new_protected:Npn \@@_interrupt_text:n #1
{
\exp_args:Nx \tex_errhelp:D
{
|'''''''''''''''''''''''''''''''''''''''''''''''
#1 \iow_newline:
|...............................................
}
\group_end:
\tl_set:Nn \l_@@_tmp_tl {#1}
}
\cs_new_protected:Npn \@@_interrupt_more_text:n #1
{ \exp_args:Nx \tex_errhelp:D { #1 \iow_newline: } }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@_interrupt_text:n}
% \begin{macro}{\@@_interrupt:n}
% The business end of the process starts by producing some visual
% separation of the message from the main part of the log. The error
% message needs to be printed with everything made
% \enquote{invisible}: \TeX{}'s own information involves the macro in
% which \tn{errmessage} is called, and the end of the argument of the
% \tn{errmessage}, including the closing brace. We use an active |!|
% to call the \tn{errmessage} primitive, and end its argument with
% \cs{use_none:n} \Arg{dots} which fills the output with dots. Two
% \cs{use_none:n} \Arg{spaces} which fills the output with spaces. Two
% trailing closing braces are turned into spaces to hide them as well.
% The group in which we alter the definition of the active |!| is
% closed before producing the message: this ensures that tokens
Expand All @@ -749,22 +770,17 @@
% inserted by the user. This is unavoidable.
% \begin{macrocode}
\group_begin:
\char_set_lccode:nn {`\{} {`\ }
\char_set_lccode:nn {`\}} {`\ }
\char_set_lccode:nn {`\&} {`\!}
\char_set_lccode:nn { 38 } { 32 } % &
\char_set_lccode:nn { 46 } { 32 } % .
\char_set_lccode:nn { 123 } { 32 } % {
\char_set_lccode:nn { 125 } { 32 } % }
\char_set_catcode_active:N \&
\tex_lowercase:D
{
\group_end:
\cs_new_protected:Npn \@@_interrupt_text:n #1
\cs_new_protected:Npn \@@_interrupt:n #1
{
\iow_term:x
{
\iow_newline:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\iow_newline:
!
}
\iow_term:n { }
\__kernel_iow_with:Nnn \tex_newlinechar:D { `\^^J }
{
\__kernel_iow_with:Nnn \tex_errorcontextlines:D { -1 }
Expand Down Expand Up @@ -816,16 +832,16 @@
% \begin{macrocode}
\cs_new:Npn \msg_fatal_text:n #1
{
Fatal~#1~error
Fatal ~
\msg_error_text:n {#1}
}
\cs_new:Npn \msg_critical_text:n #1
{
Critical~#1~error
Critical ~
\msg_error_text:n {#1}
}
\cs_new:Npn \msg_error_text:n #1
{
#1~error
}
{ \@@_text:nn {#1} { Error } }
\cs_new:Npn \msg_warning_text:n #1
{ \@@_text:nn {#1} { Warning } }
\cs_new:Npn \msg_info_text:n #1
Expand Down Expand Up @@ -953,13 +969,10 @@
% \begin{macrocode}
\@@_class_new:nn { fatal }
{
\@@_interrupt:nnn
{ \msg_fatal_text:n {#1} : ~ "#2" }
{
\use:c { \c_@@_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6}
\\ \\
\msg_see_documentation_text:n {#1}
}
\@@_interrupt:Nnnn
\msg_fatal_text:n
{#1}
{ \use:c { \c_@@_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6} }
{ \c_@@_fatal_text_tl }
\tex_end:D
}
Expand All @@ -982,13 +995,10 @@
% \begin{macrocode}
\@@_class_new:nn { critical }
{
\@@_interrupt:nnn
{ \msg_critical_text:n {#1} : ~ "#2" }
{
\use:c { \c_@@_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6}
\\ \\
\msg_see_documentation_text:n {#1}
}
\@@_interrupt:Nnnn
\msg_critical_text:n
{#1}
{ \use:c { \c_@@_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6} }
{ \c_@@_critical_text_tl }
\tex_endinput:D
}
Expand Down Expand Up @@ -1018,13 +1028,10 @@
{ \c_@@_more_text_prefix_tl #1 / #2 }
{#3} {#4} {#5} {#6}
{
\@@_interrupt:nnn
{ \msg_error_text:n {#1} : ~ "#2" }
{
\use:c { \c_@@_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6}
\\ \\
\msg_see_documentation_text:n {#1}
}
\@@_interrupt:Nnnn
\msg_error_text:n
{#1}
{ \use:c { \c_@@_text_prefix_tl #1 / #2 } {#3} {#4} {#5} {#6} }
}
}
\cs_new_protected:Npn \@@_error:cnnnnn #1#2#3#4#5#6
Expand Down

0 comments on commit c181678

Please sign in to comment.