blob: b2c8c75fbd06c9bcae21aee98bed9394a0a3a598 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
%%
%% This is file `l3str-esc-string.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3str-convert.dtx (with options: `string')
%%
%% Copyright (C) 2011-2017 The LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version. The latest
%% version of this license is in the file:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3experimental bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% File: l3str-convert.dtx Copyright (C) 2013-2017 The LaTeX3 Project
\group_begin:
\char_set_lccode:nn {`\*} {`\\}
\char_set_catcode_other:N \^^J
\char_set_catcode_other:N \^^M
\tex_lowercase:D
{
\cs_new_protected:Npn \__str_convert_unescape_string:
{
\group_begin:
\flag_clear:n { str_byte }
\flag_clear:n { str_error }
\int_set:Nn \tex_escapechar:D { 92 }
\tl_gset:Nx \g__str_result_tl
{
\exp_after:wN \__str_unescape_string_newlines:wN
\g__str_result_tl \__prg_break: ^^M ?
\__prg_break_point:
}
\tl_gset:Nx \g__str_result_tl
{
\exp_after:wN \__str_unescape_string_loop:wNNN
\g__str_result_tl * ?? { ? \__prg_break: }
\__prg_break_point:
}
\__str_if_flag_error:nnx { str_byte } { non-byte } { string }
\__str_if_flag_error:nnx { str_error } { unescape-string } { }
\group_end:
}
\cs_new:Npn \__str_unescape_string_loop:wNNN #1 *#2#3#4
}
{
\__str_filter_bytes:n {#1}
\use_none:n #4
\__str_output_byte:w '
\__str_octal_use:NTF #2
{
\__str_octal_use:NTF #3
{
\__str_octal_use:NTF #4
{
\if_int_compare:w #2 > 3 \exp_stop_f:
- 256
\fi:
\__str_unescape_string_repeat:NNNNNN
}
{ \__str_unescape_string_repeat:NNNNNN ? }
}
{ \__str_unescape_string_repeat:NNNNNN ?? }
}
{
\str_case_x:nnF {#2}
{
{ \c_backslash_str } { 134 }
{ ( } { 50 }
{ ) } { 51 }
{ r } { 15 }
{ f } { 14 }
{ n } { 12 }
{ t } { 11 }
{ b } { 10 }
{ ^^J } { 0 - 1 }
}
{
\flag_raise:n { str_error }
0 - 1 \use_i:nn
}
}
\__str_output_end:
\use_i:nn \__str_unescape_string_loop:wNNN #2#3#4
}
\cs_new:Npn \__str_unescape_string_repeat:NNNNNN #1#2#3#4#5#6
{ \__str_output_end: \__str_unescape_string_loop:wNNN }
\cs_new:Npn \__str_unescape_string_newlines:wN #1 ^^M #2
{
#1
\if_charcode:w ^^J #2 \else: ^^J \fi:
\__str_unescape_string_newlines:wN #2
}
\__msg_kernel_new:nnnn { str } { unescape-string }
{ String~invalid~in~escaping~'string'. }
{
LaTeX~came~across~an~escape~character~'\c_backslash_str'~
not~followed~by~any~of:~'n',~'r',~'t',~'b',~'f',~'(',~')',~
'\c_backslash_str',~one~to~three~octal~digits,~or~the~end~
of~a~line.
}
\group_end:
\str_const:Nx \c__str_escape_string_str
{ \c_backslash_str ( ) }
\cs_new_protected:Npn \__str_convert_escape_string:
{ \__str_convert_gmap:N \__str_escape_string_char:N }
\cs_new:Npn \__str_escape_string_char:N #1
{
\__str_if_escape_string:NTF #1
{
\__str_if_contains_char:NNT
\c__str_escape_string_str #1
{ \c_backslash_str }
#1
}
{
\c_backslash_str
\int_div_truncate:nn {`#1} {64}
\int_mod:nn { \int_div_truncate:nn {`#1} { 8 } } { 8 }
\int_mod:nn {`#1} { 8 }
}
}
\prg_new_conditional:Npnn \__str_if_escape_string:N #1 { TF }
{
\if_int_compare:w `#1 < "21 \exp_stop_f:
\prg_return_false:
\else:
\if_int_compare:w `#1 > "7E \exp_stop_f:
\prg_return_false:
\else:
\prg_return_true:
\fi:
\fi:
}
%%
%%
%% End of file `l3str-esc-string.def'.
|