summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3experimental/l3str/l3intarray.sty
blob: 8239e693bbc90115be9afa96f6d47592c255e0e5 (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
%%
%% This is file `l3intarray.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3intarray.dtx  (with options: `package')
%% 
%% 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: l3intarray.dtx Copyright (C) 2017 The LaTeX3 Project
\RequirePackage{expl3}[2017/05/13]
\@ifpackagelater{expl3}{2017/05/13}
  {}
  {%
    \PackageError{l3intarray}{Support package l3kernel too old}
      {%
        Please install an up to date version of l3kernel\MessageBreak
        using your TeX package manager or from CTAN.\MessageBreak
        \MessageBreak
        Loading l3intarray will abort!%
      }%
    \endinput
  }
\ProvidesExplPackage{l3intarray}{2017/05/13}{}
  {L3 Experimental low-level arrays of small integers}
\int_new:N \g__intarray_font_int
\cs_new_protected:Npn \__intarray_new:Nn #1#2
  {
    \__chk_if_free_cs:N #1
    \int_gincr:N \g__intarray_font_int
    \tex_global:D \tex_font:D #1 = cmr10~at~ \g__intarray_font_int sp \scan_stop:
    \tex_hyphenchar:D #1 = \int_eval:n {#2} \scan_stop:
    \int_compare:nNnT { \tex_hyphenchar:D #1 } > 0
      { \tex_fontdimen:D \tex_hyphenchar:D #1 #1 = 0 sp \scan_stop: }
    \int_step_inline:nnnn { 1 } { 1 } { 8 }
      { \tex_fontdimen:D ##1 #1 = 0 sp \scan_stop: }
  }
\cs_new:Npn \__intarray_count:N #1 { \tex_the:D \tex_hyphenchar:D #1 }
\cs_new_protected:Npn \__intarray_gset_fast:Nnn #1#2#3
  { \tex_fontdimen:D \int_eval:n {#2} #1 = \int_eval:n {#3} sp \scan_stop: }
\cs_new_protected:Npn \__intarray_gset:Nnn #1#2#3
  {
    \exp_args:Nff \__intarray_gset_aux:Nnn #1
      { \int_eval:n {#2} } { \int_eval:n {#3} }
  }
\cs_new_protected:Npn \__intarray_gset_aux:Nnn #1#2#3
  {
    \int_compare:nTF { 1 <= #2 <= \__intarray_count:N #1 }
      {
        \int_compare:nTF { - \c_max_dim <= \int_abs:n {#3} <= \c_max_dim }
          { \__intarray_gset_fast:Nnn #1 {#2} {#3} }
          {
            \__msg_kernel_error:nnxxxx { intarray } { overflow }
              { \token_to_str:N #1 } {#2} {#3}
              { \int_compare:nNnT {#3} < 0 { - } \__int_value:w \c_max_dim }
            \__intarray_gset_fast:Nnn #1 {#2}
              { \int_compare:nNnT {#3} < 0 { - } \c_max_dim }
          }
      }
      {
        \__msg_kernel_error:nnxxx { intarray } { out-of-bounds }
          { \token_to_str:N #1 } {#2} { \__intarray_count:N #1 }
      }
  }
\cs_new:Npn \__intarray_item_fast:Nn #1#2
  { \__int_value:w \tex_fontdimen:D \int_eval:n {#2} #1 }
\cs_new:Npn \__intarray_item:Nn #1#2
  { \exp_args:Nf \__intarray_item_aux:Nn #1 { \int_eval:n {#2} } }
\cs_new:Npn \__intarray_item_aux:Nn #1#2
  {
    \int_compare:nTF { 1 <= #2 <= \__intarray_count:N #1 }
      { \__intarray_item_fast:Nn #1 {#2} }
      {
        \__msg_kernel_expandable_error:nnnnn { intarray } { out-of-bounds }
          { \token_to_str:N #1 } {#2} { \__intarray_count:N #1 }
        0
      }
  }
\__msg_kernel_new:nnnn { intarray } { overflow }
  { Integers~larger~than~2^{30}-1~cannot~be~stored~in~arrays. }
  {
    An~attempt~was~made~to~store~#3~at~position~#2~in~the~array~'#1'.~
    The~largest~allowed~value~#4~will~be~used~instead.
  }
\__msg_kernel_new:nnnn { intarray } { out-of-bounds }
  { Access~to~an~entry~beyond~an~array's~bounds. }
  {
    An~attempt~was~made~to~access~or~store~data~at~position~#2~of~the~
    array~'#1',~but~this~array~has~entries~at~positions~from~1~to~#3.
  }
%% 
%%
%% End of file `l3intarray.sty'.