This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
xstring.tex
1389 lines (1274 loc) · 53.1 KB
/
xstring.tex
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% __________________________________________________
% | |
% | |
% | xstring v1.7c |
% | |
% | 13 octobre 2013 |
% | |
% |__________________________________________________|
%
% This is xtring.tex
%
% "xstring" package consists of the 7 following files:
% xstring.tex (this file)
% xstring.sty
% README
% xstring_doc_fr.tex, xstring_doc_fr.pdf (manual in french)
% xstring_doc_en.tex, xstring_doc_en.pdf (manual in english)
%
% Christian Tellechea 2008-2013
% email : [email protected]
% -------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% -------------------------------------------------------------------
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Christian Tellechea
% -------------------------------------------------------------------
\def\xstringversion {1.7c}
\def\xstringdate {2013/10/13}
\def\xstringfrenchdate {13 octobre 2013}
\def\xstringenglishdate {13 october 2013}
\edef\CurrentAtCatcode {\the\catcode`\@}
\catcode`\@=11
\newwrite\@xs@message% canal pour les messages
\newcount\integerpart
\newcount\decimalpart% compteurs utilis\'es par xstring
\expandafter\ifx\csname @latexerr\endcsname\relax% on n'utilise pas LaTeX ?
\immediate\write\m@ne{Package: xstring \xstringdate\space\space v\xstringversion\space\space String manipulations}%
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
\long\def\@gobble#1{}
\long\def\@ifnextchar#1#2#3{%
\let\reserved@d=#1%
\def\reserved@a{#2}%
\def\reserved@b{#3}%
\futurelet\@let@arg\@ifnch}
\def\@ifnch{%
\ifx\@let@arg\@sptoken
\let\reserved@c\@xifnch
\else
\ifx\@let@arg\reserved@d
\let\reserved@c\reserved@a
\else
\let\reserved@c\reserved@b
\fi
\fi
\reserved@c}
\def\:{\let\@sptoken= } \:
\def\:{\@xifnch} \expandafter\def\: {\futurelet\@let@arg\@ifnch}
\def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}}
\long\def\@testopt#1#2{\@ifnextchar[{#1}{#1[{#2}]}}
\def\@empty{}
\fi% fin des d\'efinitions LaTeX
\long\def\@xs@ifempty#1{%
\expandafter\ifx\expandafter\relax\detokenize{#1}\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% Ouvre un groupe o\`u les catcodes sont \`a 12 et \`a 10 pour les espaces
% ensuite, appelle \@xs@ReadVerb qui lit un argument entre d\'elimiteurs verb
\def\@xs@MakeVerb{% lit 1 argument et le transforme en verb
\begingroup% groupe o\`u les catcodes sont \`a 12 pour la lecture suivante
\def\do##1{\catcode`##112\relax}%
\dospecials% on entre dans le mode verb
\obeyspaces% et on tient compte des espaces
\@xs@ReadVerb% et on va lire l'argument
}
% D\'efinit \@xs@ReadVerb qui lit un argument entre d\'elimiteurs verb
\def\setverbdelim#1{% d\'efinit quel est le d\'elimiteur de verb
\expandafter\@xs@ifempty\expandafter{\@gobble#1}%
\relax
{\begingroup
\newlinechar`\^^J%
\immediate\write\@xs@message
{Package xstring Warning: verb delimiter is not a single token on input line \the\inputlineno^^J}%
\endgroup
}%
\def\@xs@ReadVerb##1#1##2#1{% lit ##2 qui est entre les d\'elimiteurs de verb
\endgroup% on ferme le groupe
\@xs@afterreadverb{##2}}% on appelle l'ex\'ecution de fin
}
% Assigne l'argument entre d\'elimiteur verb dans la sc #1' +
\def\verbtocs#1{%
\def\@xs@afterreadverb##1{\def#1{##1}}%
\@xs@MakeVerb
}
\begingroup
\catcode\z@3 \def\@xs@twochars{^^00}%
\catcode\z@7 \xdef\@xs@twochars{\@xs@twochars^^00}%
\endgroup
\edef\@xs@reserved@A{\long\def\noexpand\@xs@AssignResult##1\@xs@twochars}
\@xs@reserved@A#2{\endgroup\expandafter\def\expandafter#2\expandafter{\@gobble#1}}
\def\tokenize#1#2{%
\begingroup
\@xs@def\@xs@reserved@A{#2}% on d\'eveloppe en accord avec \fullexpandarg ou \noexpandarg
\everyeof\expandafter{\@xs@twochars#1}% met "^^@^^@#1" \`a la fin du fichier virtuel
\endlinechar\m@ne
\expandafter\@xs@AssignResult\scantokens\expandafter{\expandafter\relax\@xs@reserved@A}% on fait l'assignation
}%
% Macro tr\`es simple qui assigne ou affiche le r\'esultat, selon la pr\'esence
% ou non de #2 qui est l'argument optionnel venant en derni\`ere position des macros
\long\def\@xs@ReturnResult#1#2{%
\def\@xs@argument@A{#1}%
\@xs@ifempty{#2}%
\@xs@argument@A
{\let#2\@xs@argument@A}%
}
\def\@xs@ldef{\long\def}
\def\@xs@ledef{\long\edef}
% Pas d'expansion des arguments
\def\normalexpandarg{%
\let\@xs@def\@xs@ldef% on d\'efinit \@xs@call avec \def
\def\@xs@expand##1{\unexpanded\expandafter{##1}}}
\let\noexpandarg\normalexpandarg% synonyme
% 1-d\'eveloppement du premier token des arguments
\def\expandarg{%
\let\@xs@def\@xs@ldef% on d\'efinit \@xs@call avec \def
\def\@xs@expand##1{\unexpanded\expandafter\expandafter\expandafter{##1}}%
}
% D\'eveloppement maximum des arguments
\def\fullexpandarg{%
\let\@xs@def\@xs@ledef% on d\'efinit\@xs@call avec \edef
\def\@xs@expand##1{##1}% et on neutralise \@xs@expand
}
\def\saveexpandmode{\let\@xs@saved@def\@xs@defarg\let\@xs@saved@expand\@xs@expand}
\def\restoreexpandmode{\let\@xs@defarg\@xs@saved@def\let\@xs@expand\@xs@saved@expand}
% Macro interne renvoyant #2 si son argument commence par une accolade ouvrante "{"
% et #3 sinon (Ulrich Diez sur comp.text.tex)
\long\def\@xs@ifbeginwithbrace#1{%
\csname @%
\expandafter\@gobble\string{%
\expandafter\@gobble\expandafter{\expandafter{\string#1}%
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\@firstoftwo
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\@gobble
\expandafter\expandafter\expandafter\@gobble
\expandafter\expandafter\expandafter{\expandafter\string\expandafter}\string}%
\expandafter\@gobble\string}%
\@secondoftwo{first}{second}oftwo%
\endcsname
}
% Cette macro interne prend la 1ere unit\'e syntaxique de #1 et assigne le r\'esultat \`a #2
\long\def\@xs@returnfirstsyntaxunit#1#2{%
\def\@xs@groupfound{\expandafter\def\expandafter#2\expandafter{\expandafter{#2}}\@xs@gobbleall}% on met #2 dans des accolades et on finit
\long\def\@xs@assignfirsttok##1##2\@xs@nil{\let\@xs@toks0\def#2{##1}}%
\def\@xs@testfirsttok{%
\let\@xs@next\@xs@assignfirsttok
\ifx\@xs@toks\bgroup
\expandafter\@xs@ifbeginwithbrace\expandafter{\@xs@argument}{\def\@xs@next{\afterassignment\@xs@groupfound\def#2}}{}%
\fi
\@xs@next}%
\def\@xs@argument{#1}%
\edef\@xs@next{\expandafter\@xs@beforespace\detokenize{#1} \@xs@nil}% #1 commence par un espace ?
\ifx\@xs@next\@empty
\def\@xs@next{\expandafter\ifx\expandafter\@empty\detokenize\expandafter{\@xs@argument}\@empty\let#2\@empty\else\def#2{ }\let\@xs@toks0\fi}%
\else
\def\@xs@next{\expandafter\futurelet\expandafter\@xs@toks\expandafter\@xs@testfirsttok\@xs@argument\@xs@nil}%
\fi
\@xs@next
}
% Cette macro interne enl\`eve la 1ere unit\'e syntaxique de #1 et assigne le r\'esultat \`a #2
\long\def\@xs@testsecondtoken#1\@xs@nil{\@xs@ifbeginwithbrace{#1}}
\long\def\@xs@gobblespacebeforebrace#1#{}% supprime tout ce qui est avant la 1ere accolade ouvrante
\long\def\@xs@removefirstsyntaxunit#1#2{%
\def\@xs@argument{#1}%
\expandafter\expandafter\expandafter\ifx\expandafter\expandafter\expandafter\@empty\expandafter\@xs@beforespace\detokenize\expandafter{\@xs@argument} \@xs@nil\@empty% #1 commence par un espace ?
\expandafter\@xs@ifempty\expandafter{\@xs@argument}%
{\let#2\@empty}
{\afterassignment\@xs@testsecondtoken% après avoir mangé le 1er token, on va tester si la suite commence par «{»
\expandafter\let\expandafter\@xs@secontoken\expandafter=\expandafter\@sptoken\@xs@argument\@xs@@nil\@xs@nil% on mange le 1er token et on rajoute \@xs@@nil à la fin pour éviter de perdre les accolades du groupe
{\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2%
\expandafter\expandafter\expandafter{\expandafter\@xs@gobblespacebeforebrace\@xs@argument}}%
{\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2%
\expandafter\expandafter\expandafter{\expandafter\@xs@behindspace\@xs@argument\@xs@nil}}%
}%
\else
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2%
\expandafter\expandafter\expandafter{\expandafter\@gobble\@xs@argument}%
\fi
}
% Macros \`a arguments d\'elimit\'es pour les macros ci dessus
\long\def\@xs@beforespace#1 #2\@xs@nil{#1}
\long\def\@xs@behindspace#1 #2\@xs@nil{#2}
\long\def\@xs@returnfirstsyntaxunit@ii#1#2\@xs@nil{#1}
\long\def\@xs@gobbleall#1\@xs@nil{}
% Cette macro interne est utilis\'ee dans les macros \'etoil\'ees pour :
% 1) d\'evelopper l'argument selon qu'on a choisit \fullexpandarg
% ou \normalexpandarg, et ceci \`a l'aide de la macro \@xs@def
% 2) Ensuite, on d\'etokenize ce d\'eveloppement de façon n'avoir plus que
% des catcodes de 10 pour les espaces et 12 pour le reste.
\long\def\@xs@expand@and@detokenize#1#2{%
\long\def#1{#2}%
\expandafter\edef\expandafter#1\expandafter{\@xs@expand#1}% on d\'eveloppe #2 selon le mode de d\'eveloppement
\long\edef#1{\detokenize\expandafter{#1}}% puis on d\'etokenize et on assigne \`a #1
}
\long\def\@xs@expand@and@assign#1#2{\@xs@def#1{#2}}% on d\'eveloppe #2 selon \fullexpandarg ou \normalexpandarg
\long\def\@xs@edefaddtomacro#1#2{\edef#1{\unexpanded\expandafter{#1}#2}}
\long\def\@xs@addtomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\@xs@argstring{0########1########2########3########4########5########6########7########8########9}
% \@xs@DefArg{3} met dans la sc \@xs@myarg les tokens "####1####2####3"
\def\@xs@DefArg#1{\def\@xs@defarg0##1#1##2\@xs@nil{\def\@xs@myarg{##1#1}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil}
% \@xs@DefArg@{3} met dans la sc \@xs@myarg les tokens "[####1]####2####3####4"
\def\@xs@DefArg@#1{\expandafter\@xs@defarg@\expandafter{\number\numexpr#1+1}}
\def\@xs@defarg@#1{\def\@xs@defarg0##11##2#1##3\@xs@nil{\def\@xs@myarg{[##11]##2#1}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil}
% \@xs@OneArg{3} met dans la sc \@xs@myarg les tokens "####3"
\def\@xs@OneArg#1{\expandafter\@xs@onearg\expandafter{\number\numexpr#1-1}{#1}}
\def\@xs@onearg#1#2{\def\@xs@defarg##1#1##2#2##3\@xs@nil{\def\@xs@myarg{##2#2}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil}
% #1 : num\'ero du 1er argument; #2 : nombre de lignes; #3 argument optionnel; #4 : dernier num\'ero de l'argument devant être d\'etokenis\'e si \'etoile
\def\@xs@BuildLines#1#2#3#4{%
\let\@xs@newlines\@empty
\let\@xs@newargs\@empty
\def\@xs@buildlines##1{%
\expandafter\@xs@OneArg\expandafter{\number\numexpr##1+#1-1}%
\edef\@xs@reserved@B{\noexpand\@xs@expand\csname @xs@arg@\romannumeral\numexpr##1\endcsname}%
\ifnum##1=\@ne% si c'est le premier argument
\@xs@ifempty{#3}%
{\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}%
\edef\@xs@reserved@B{\ifnum##1>#4 @xs@def\else @xs@assign\fi}%
}% et s'il y a un argument optionnel alors, on met des crochets
{\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter[\@xs@reserved@B]}%
\def\@xs@reserved@B{@xs@def}% ne pas d\'etok\'eniser l'argument optionnel grace au \@xs@def
}
\else
\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}%
\edef\@xs@reserved@B{\ifnum##1>#4 @xs@def\else @xs@assign\fi}%
\fi
\edef\@xs@newlines{\unexpanded\expandafter{\@xs@newlines}\expandafter\noexpand\csname\@xs@reserved@B\endcsname\expandafter\noexpand\csname @xs@arg@\romannumeral\numexpr##1\endcsname{\@xs@myarg}}%
\ifnum##1<#2\relax
\def\@xs@next{\expandafter\@xs@buildlines\expandafter{\number\numexpr##1+1}}%
\expandafter\@xs@next
\fi}%
\@xs@buildlines\@ne
}
\def\@xs@newmacro{%
\@ifstar
{\let\@xs@reserved@D\@empty\@xs@newmacro@}
{\let\@xs@reserved@D\relax\@xs@newmacro@0}%
}
% #1 : dernier num\'ero de l'argument devant être d\'etokenis\'e
% #2 : nom de la macro publique
% #3 : argument optionnel (vide si pas d'arg optionnel)
% #4 : nombre d'arguments obligatoires
% #5 : utilisation de testopt (1 si oui, 0 si non)
% #6 : code de la macro
\def\@xs@newmacro@#1#2#3#4#5{%
\edef\@xs@reserved@A{@xs@\expandafter\@gobble\string#2}%
\edef\@xs@reserved@C{\expandafter\noexpand\csname\@xs@reserved@A @\ifx\@empty#3\@empty @\fi\endcsname}%
\edef\@xs@reserved@B{%
\ifx\@empty\@xs@reserved@D
\def\noexpand#2{\noexpand\@ifstar
{\let\noexpand\@xs@assign\noexpand\@xs@expand@and@detokenize\expandafter\noexpand\@xs@reserved@C}%
{\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}%
}%
\else
\def\noexpand#2{\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}%
\fi
\ifx\@empty#3\@empty
\else
\def\expandafter\noexpand\@xs@reserved@C{%
\noexpand\@testopt{\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname}{\ifx\@xs@def\@xs@ledef#3\else\unexpanded{#3}\fi}}%
\fi
}%
% Que fait \@xs@reserved@B ? Il d\'efinit :
% si #3 est vide : \NOM{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@NOM@@}{\let\@xs@assign\@xs@expand@and@assign\@xs@NOM@@}}
% si #3 existe : \NOM{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@NOM@}{\let\@xs@assign\@xs@expand@and@assign\@xs@NOM@}}
% \@xs@NOM@{\@testopt{\@xs@NOM@@}{#3}}}
\long\@xs@reserved@B
\ifx\@empty#3\@empty
\@xs@BuildLines1{#4}{#3}{#1}%
\@xs@DefArg{#4}%
\else
\expandafter\@xs@BuildLines\expandafter1\expandafter{\number\numexpr#4+1}{#3}{#1}%
\@xs@DefArg@{#4}%
\fi
\edef\@xs@reserved@B{\def\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname\@xs@myarg}%
\edef\@xs@reserved@C{\unexpanded\expandafter{\@xs@newlines}\edef\noexpand\@xs@call}%
\edef\@xs@reserved@D{%
\noexpand\noexpand\expandafter\noexpand\csname\@xs@reserved@A\endcsname\unexpanded\expandafter{\@xs@newargs}%
}%
\ifnum#5=\@ne\edef\@xs@reserved@D{\noexpand\noexpand\noexpand\@testopt{\unexpanded\expandafter{\@xs@reserved@D}}{}}\fi
\@xs@edefaddtomacro\@xs@reserved@C{{\unexpanded\expandafter{\@xs@reserved@D}}\noexpand\@xs@call}%
\@xs@edefaddtomacro\@xs@reserved@B{{\unexpanded\expandafter{\@xs@reserved@C}}}%
% Que fait \@xs@reserved@B ? Il d\'efinit par exemple pour 3 arguments obligatoires et 1 facultatif :
% \def\@xs@NOM@@[##2]##3##4##5{%
% \@xs@def\@xs@arg@i{##2}\@xs@assign\@xs@arg@ii{##3}\@xs@assign\@xs@arg@iii{##4}\@xs@asign\@xs@arg@iv{##5}%
% si #5=0: \edef\@xs@call{\noexpand\@xs@NOM[\@xs@expand\@xs@arg@i]{\@xs@expand\@xs@arg@ii}{\@xs@expand\@xs@arg@iii}{\@xs@expand\@xs@arg@iv}}%
% si #5=1: \edef\@xs@call{\noexpand\@testopt{\noexpand\@xs@NOM[\@xs@expand\@xs@arg@i]{\@xs@expand\@xs@arg@i}{\@xs@expand\@xs@arg@ii}{\@xs@expand\@xs@arg@iii}{\@xs@expand\@xs@arg@iv}}{}}%
% \@xs@call}
\long\@xs@reserved@B
\edef\@xs@reserved@B{%
\def\expandafter\noexpand\csname\@xs@reserved@A\endcsname
\@xs@myarg\ifnum#5=\@ne[\unexpanded{##}\number\numexpr\ifx\@empty#3\@empty#4+1\else#4+2\fi]\fi
}%
% Que fait \@xs@reserved@B ? Il d\'efinit par exemple pour 3 arguments obligatoires et 1 facultatif :
% \def \@xs@NOM[##2]##3##4##5[##6]{#6}
\long\@xs@reserved@B
}
% macro g\'en\'erique qui lit \@xs@reserved@C us par us
% 3 sous-routines sont appel\'ees \`a des moments cl\'e :
% \@xs@atendofgroup (un groupe se finit, appel r\'ecursif)
% \@xs@atbegingroup (un groupe vient d'être ouvert)
% \@xs@atnextsyntaxunit (la future US n'est pas un groupe)
\def\@xs@read@reserved@C{%
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}%
{\ifnum\@xs@nestlevel=\z@
\let\@xs@next\relax
\else
\let\@xs@next\@xs@atendofgroup
\fi
}
{\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C
\let\@xs@next\@xs@read@reserved@C
\@xs@exploregroups
\ifx\bgroup\@xs@toks
\advance\integerpart\@ne
\begingroup
\expandafter\def\expandafter\@xs@reserved@C\@xs@reserved@A
\@xs@manage@groupID
\let\@xs@nestlevel\@ne
\integerpart\z@
\@xs@atbegingroup
\else
\global\advance\decimalpart\@ne
\@xs@atnextsyntaxunit
\fi
}%
\@xs@next
}
% macro g\'en\'erique qui lit \@xs@reserved@D en proc\'edant \`a des tests avec \IfBeginWith
% 2 sous-routines sont appel\'ees \`a des moments cl\'e :
% \@xs@atendofgroup (un groupe se finit, appel r\'ecursif)
% \@xs@atoccurfound (une occurrence a \'et\'e trouv\'ee)
\def\@xs@read@reserved@D{%
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}%
{\ifnum\@xs@nestlevel=\z@
\let\@xs@next\relax
\else
\let\@xs@next\@xs@atendofgroup
\fi
}%
{\expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter
{\expandafter\@xs@reserved@D\expandafter}\expandafter{\@xs@reserved@E}%
{\global\advance\decimalpart\@ne
\let\@xs@reserved@D\@xs@reserved@A
\@xs@atoccurfound
}%
{\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@A
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@D
\let\@xs@next\@xs@read@reserved@D
\@xs@exploregroups
\ifx\bgroup\@xs@toks
\advance\integerpart\@ne
\begingroup
\expandafter\def\expandafter\@xs@reserved@D\@xs@reserved@A
\@xs@manage@groupID
\let\@xs@reserved@C\@empty
\let\@xs@nestlevel\@ne
\integerpart\z@
\else
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}%
\fi
}%
}%
\@xs@next
}
\@xs@newmacro\StrRemoveBraces{}{1}{1}{%
\def\@xs@reserved@C{#1}%
\let\@xs@reserved@B\@empty
\let\@xs@nestlevel\z@
\@xs@StrRemoveBraces@i
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#2}%
}
\def\@xs@StrRemoveBraces@i{%
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}%
{\ifnum\@xs@nestlevel=\z@
\let\@xs@next\relax
\else
\expandafter\endgroup
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@B}%
\let\@xs@next\@xs@StrRemoveBraces@i
\fi
}
{\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C
\let\@xs@next\@xs@StrRemoveBraces@i
\ifx\bgroup\@xs@toks
\ifx\@xs@exploregroups\relax% on explore les groupes ?
\begingroup
\expandafter\def\expandafter\@xs@reserved@C\@xs@reserved@A
\let\@xs@nestlevel\@ne
\integerpart\z@
\let\@xs@reserved@B\@empty
\else
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\@xs@reserved@A
\fi
\else
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@A}%
\fi
}%
\@xs@next
}
% \@xs@cutafteroccur coupe l'argument #1 apr\`es la #3\`eme occurrence de #2
% \@xs@reserved@C : contient ce qui se trouve avant cette occurrence
% \@xs@reserved@D : contient ce qui se trouve avant cette occurrence y compris cette occurrence
% \@xs@reserved@E : contient ce qui se trouve apr\`es l'occurrence
% si l'occurrence n'existe pas ou qu'un des arguments est vide, toutes les chaines renvoy\'ees sont vides
\long\def\@xs@cutafteroccur#1#2#3{%
\ifnum#3<\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{\let\@xs@reserved@C\@empty
\let\@xs@reserved@E\@empty
\global\let\groupID\@empty
}
{\@xs@cutafteroccur@i{#1}{#2}{#3}}%
}
\long\def\@xs@cutafteroccur@i#1#2#3{%
\def\@xs@reserved@D{#1}\let\@xs@reserved@C\@empty\def\@xs@reserved@E{#2}%
\decimalpart\z@
\integerpart\z@
\gdef\groupID{0}%
\let\@xs@nestlevel\z@
\def\@xs@atendofgroup{%
\expandafter\endgroup
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}%
\@xs@read@reserved@D}%
\def\@xs@atoccurfound{%
\ifnum\decimalpart=\numexpr(#3)\relax
\global\let\@xs@reserved@D\@xs@reserved@D
\global\let\@xs@reserved@C\@xs@reserved@C
\@xs@exitallgroups
\let\@xs@next\relax
\else
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@E}%
\let\@xs@next\@xs@read@reserved@D
\fi}%
\@xs@read@reserved@D
\def\@xs@argument@A{#2}%
\ifnum\decimalpart=\numexpr(#3)\relax % occurrence trouv\'ee ?
\let\@xs@reserved@E\@xs@reserved@D
\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\@xs@reserved@D\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\@xs@argument@A}%
\else
\let\@xs@reserved@C\@empty
\let\@xs@reserved@E\@empty
\global\let\groupID\@empty
\fi
}
\@xs@newmacro*3\IfSubStr{1}{2}{0}{%
\def\@xs@argument@A{#2}\def\@xs@argument@B{#3}%
\expandafter\expandafter\expandafter\@xs@cutafteroccur
\expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter{\@xs@argument@B}{#1}%
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}%
\@secondoftwo
\@firstoftwo
}
\@xs@newmacro*2\IfBeginWith{}{2}{0}{%
\def\@xs@argument@A{#1}\def\@xs@argument@B{#2}%
\expandafter\@xs@ifempty\expandafter{\@xs@argument@B}%
{\let\@xs@next\@secondoftwo
}
{\def\@xs@next{%
\expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter
{\expandafter\@xs@argument@A\expandafter}\expandafter
{\@xs@argument@B}}%
}%
\@xs@next
}
\long\def\@xs@IfBeginWith@i#1#2{%
\def\@xs@argument@A{#1}\def\@xs@argument@B{#2}%
\expandafter\@xs@ifempty\expandafter{\@xs@argument@B}%
{\let\@xs@next\@firstoftwo% #2 est vide, tous les tests sont pass\'es avec succ\`es : on renvoie #3
}
{\expandafter\@xs@ifempty\expandafter{\@xs@argument@A}%
{\let\@xs@next\@secondoftwo% #1 est vide, c'est que #2 est + long que #1 : on renvoie #4
}
{\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B
\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A
\ifx\@xs@reserved@A\@xs@reserved@B% il y a \'egalit\'e...
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A% on enl\`eve les 1ere unit\'es syntaxiques
\def\@xs@next{% et on recommence avec ces arguments racourcis d'1 unit\'e syntaxique
\expandafter\expandafter\expandafter\@xs@IfBeginWith@i
\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@A\expandafter}\expandafter{\@xs@reserved@B}}%
\else
\let\@xs@next\@secondoftwo
\fi
}%
}%
\@xs@next
}
\@xs@newmacro*2\IfEndWith{}{2}{0}{%
\def\@xs@argument@A{#1}\def\@xs@argument@B{#2}%
\@xs@ifempty{#2}%
{\let\@xs@reserved@A\@secondoftwo
}
{\expandafter\expandafter\expandafter\@xs@StrCount
\expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter
{\@xs@argument@B}[\@xs@reserved@A]%
\ifnum\@xs@reserved@A=\z@
\let\@xs@reserved@A\@secondoftwo
\else
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}%
{\let\@xs@reserved@A\@firstoftwo}
{\let\@xs@reserved@A\@secondoftwo}%
\fi
}%
\@xs@reserved@A
}
\@xs@newmacro*4\IfSubStrBefore{1,1}{3}{0}{\@xs@IfSubStrBefore@i[#1]{#2}{#3}{#4}}
\def\@xs@IfSubStrBefore@i[#1,#2]#3#4#5{%
\def\@xs@reserved@C{#3}%
\ifx\@xs@exploregroups\relax% si on explore les groupes
\let\@xs@reserved@B\@empty
\let\@xs@nestlevel\z@
\@xs@StrRemoveBraces@i% on retire les accolades
\let\@xs@reserved@C\@xs@reserved@B
\fi
\def\@xs@reserved@A{#5}%
\expandafter\expandafter\expandafter\@xs@cutafteroccur\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@A}{#2}%
\def\@xs@reserved@A{#4}%
\expandafter\expandafter\expandafter\@xs@cutafteroccur\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@A}{#1}%
\global\let\groupID\@empty
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}%
\@secondoftwo
\@firstoftwo
}
\@xs@newmacro*4\IfSubStrBehind{1,1}{3}{0}{\@xs@IfSubStrBehind@i[#1]{#2}{#3}{#4}}
\long\def\@xs@IfSubStrBehind@i[#1,#2]#3#4#5{\@xs@IfSubStrBefore@i[#2,#1]{#3}{#5}{#4}}
\long\def\@xs@formatnumber#1#2{%
\def\@xs@argument@A{#1}%
\@xs@ifempty{#1}%
{\def#2{0X}% si vide, renvoie 0X
}
{\@xs@returnfirstsyntaxunit{#1}\@xs@reserved@A
\def\@xs@reserved@B{+}%
\ifx\@xs@reserved@A\@xs@reserved@B
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@C
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}%
{\def#2{+0X}}
{\expandafter\def\expandafter#2\expandafter{\expandafter+\expandafter0\@xs@reserved@C}}%
\else
\def\@xs@reserved@B{-}%
\ifx\@xs@reserved@A\@xs@reserved@B
\expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@A}%
{\def#2{-0X}}%
{\expandafter\def\expandafter#2\expandafter{\expandafter-\expandafter0\@xs@reserved@A}}%
\else
\expandafter\def\expandafter#2\expandafter{\expandafter0\@xs@argument@A}%
\fi
\fi
}%
}
\@xs@newmacro\IfInteger{}{1}{0}{%
\@xs@formatnumber{#1}\@xs@reserved@A
\decimalpart\z@
\afterassignment\@xs@defafterinteger\integerpart\@xs@reserved@A\relax\@xs@nil
\let\@xs@after@intpart\@xs@afterinteger
\expandafter\@xs@testdot\@xs@afterinteger\@xs@nil
\ifx\@empty\@xs@afterdecimal
\ifnum\decimalpart=\z@
\let\@xs@next\@firstoftwo% partie décimale constituée de 0 --> seul cas où on renvoie vrai
\else
\let\@xs@afterinteger\@xs@after@intpart
\let\@xs@next\@secondoftwo
\fi
\else
\let\@xs@afterinteger\@xs@after@intpart
\let\@xs@next\@secondoftwo
\fi
\@xs@next
}
\@xs@newmacro\IfDecimal{}{1}{0}{%
\@xs@formatnumber{#1}\@xs@reserved@A
\decimalpart\z@
\afterassignment\@xs@defafterinteger\integerpart\@xs@reserved@A\relax\@xs@nil
\expandafter\@xs@testdot\@xs@afterinteger\@xs@nil
\ifx\@empty\@xs@afterdecimal
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\long\def\@xs@defafterinteger#1\relax\@xs@nil{\def\@xs@afterinteger{#1}}
\def\@xs@testdot{%
\let\xs@decsep\@empty
\@ifnextchar.%
{\def\xs@decsep{.}\@xs@readdecimalpart}%
{\@xs@testcomma}%
}
\def\@xs@testcomma{%
\@ifnextchar,%
{\def\xs@dessep{,}\@xs@readdecimalpart}%
{\@xs@endnumber}%
}
\long\def\@xs@readdecimalpart#1#2\@xs@nil{%
\ifx\@empty#2\@empty
\def\@xs@reserved@A{0X}%
\else
\def\@xs@reserved@A{0#2}%
\fi
\afterassignment\@xs@defafterinteger\decimalpart\@xs@reserved@A\relax\@xs@nil
\expandafter\@xs@endnumber\@xs@afterinteger\@xs@nil
}
\long\def\@xs@endnumber#1\@xs@nil{\def\@xs@afterdecimal{#1}}
% test d'\'egalit\'e sur des chaines (et des chaines contenant des nombres)
\long\def\@xs@IfStrEqFalse@i#1#2{\let\@xs@reserved@A\@secondoftwo}
\long\def\@xs@IfStrEqFalse@ii#1#2{% renvoie vrai si les 2 arg sont d\'ecimaux et s'ils sont \'egaux, faux sinon
\@xs@IfDecimal{#1}%
{\@xs@IfDecimal{#2}%
{\ifdim#1pt=#2pt
\let\@xs@reserved@A\@firstoftwo
\else
\let\@xs@reserved@A\@secondoftwo
\fi% les 2 sont d\'ecimaux : on fait le test
}%
{\let\@xs@reserved@A\@secondoftwo}% un seul est d\'ecimal
}%
{\let\@xs@reserved@A\@secondoftwo}% #1 n'est pas d\'ecimal
}
\long\def\@xs@TestEqual#1#2{% teste si les 2 arguments sont \'egaux
\def\@xs@reserved@A{#1}\def\@xs@reserved@B{#2}%
\ifx\@xs@reserved@A\@xs@reserved@B
\let\@xs@reserved@A\@firstoftwo% \'egalit\'e parfaite des 2 chaines
\else
\expandafter\expandafter\expandafter\@xs@reserved@D\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@A\expandafter}\expandafter{\@xs@reserved@B}%
\fi
\@xs@reserved@A
}
\@xs@newmacro*2\IfStrEq{}{2}{0}{% teste si les deux chaines sont \'egales
\let\@xs@reserved@D\@xs@IfStrEqFalse@i
\@xs@TestEqual{#1}{#2}%
}
\@xs@newmacro*2\IfEq{}{2}{0}{% teste si les 2 arguments (chaine ou nombre) sont \'egaux
\let\@xs@reserved@D\@xs@IfStrEqFalse@ii
\@xs@TestEqual{#1}{#2}%
}
\def\IfStrEqCase{%
\@ifstar
{\def\@xs@reserved@E{\IfStrEq*}\@xs@IfStrCase}%
{\def\@xs@reserved@E{\IfStrEq}\@xs@IfStrCase}%
}
\long\def\@xs@IfStrCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}}
\def\IfEqCase{%
\@ifstar
{\def\@xs@reserved@E{\IfEq*}\@xs@IfEqCase}%
{\def\@xs@reserved@E{\IfEq}\@xs@IfEqCase}%
}
\long\def\@xs@IfEqCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}}
\long\def\@xs@IfStringCase#1#2[#3]{%
\long\def\@xs@testcase##1##2##3\@xs@nil{% lit les 2 premieres unit\'es syntaxiques dans ##1 et ##2. Les autres dans ##3
\@xs@reserved@E{#1}{##1}%
{##2}% le test est positif, on ex\'ecute le code correspondant
{\@xs@ifempty{##3}%
{#3}% s'il n'y a plus de cas, on ex\'ecute le code <autres cas>
{\@xs@testcase##3\@xs@nil}% sinon, on recommence avec ce qui reste
}%
}%
\@xs@testcase#2\@xs@nil
}
% Renvoie ce qui est \`a gauche de l'occurence n°#1 de la sous chaine #3 dans la chaine #2
\@xs@newmacro*3\StrBefore{1}{2}{1}{%
\@xs@cutafteroccur{#2}{#3}{#1}%
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}%
}
% Renvoie ce qui est \`a droite de l'occurence n°#1 de la sous chaine #3 dans la chaine #2
\@xs@newmacro*3\StrBehind{1}{2}{1}{%
\@xs@cutafteroccur{#2}{#3}{#1}%
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#4}%
}
% Renvoie ce qui est strictement compris entre les occurrences n°#1 et n°#2
% des chaines #4 et #5 dans la chaine #3
\@xs@newmacro*4\StrBetween{1,1}{3}{1}{\@xs@StrBetween@i[#1]{#2}{#3}{#4}[#5]}
\long\def\@xs@StrBetween@i[#1,#2]#3#4#5[#6]{%
\begingroup
\noexploregroups
\@xs@cutafteroccur{#3}{#5}{#2}%
\expandafter\@xs@cutafteroccur\expandafter{\@xs@reserved@C}{#4}{#1}%
\expandafter
\endgroup
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#6}%
\global\let\groupID\@empty
}
\def\exploregroups{\let\@xs@exploregroups\relax}
\def\noexploregroups{\def\@xs@exploregroups{\let\@xs@toks0\relax}}
\def\saveexploremode{\let\@xs@saveexploremode\@xs@exploregroups}
\def\restoreexploremode{\let\@xs@exploregroups\@xs@saveexploremode}
% Remplace les #1 premi\`eres occurences de la chaine #3
% par la chaine #4 dans la chaine #2
\@xs@newmacro\StrSubstitute{0}{3}{1}{%
\def\@xs@reserved@D{#2}\let\@xs@reserved@C\@empty\def\@xs@reserved@E{#3}%
\def\@xs@argument@C{#3}\def\@xs@argument@D{#4}%
\decimalpart\z@
\integerpart\z@
\gdef\groupID{0}%
\let\@xs@nestlevel\z@
\def\@xs@atendofgroup{%
\expandafter\endgroup
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}%
\@xs@read@reserved@D
}%
\def\@xs@atoccurfound{%
\ifnum#1<\@ne
\let\@xs@reserved@A\@xs@argument@D
\else
\ifnum\decimalpart>#1
\let\@xs@reserved@A\@xs@argument@C
\else
\let\@xs@reserved@A\@xs@argument@D
\fi
\fi
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}%
\@xs@read@reserved@D
}%
\@xs@ifempty{#3}%
{\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@D}{#5}%
}
{\@xs@read@reserved@D
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#5}%
}%
}
% Supprime les #1 premi\`eres occurrences de #3 dans #2
\@xs@newmacro\StrDel{0}{2}{1}{\@xs@StrSubstitute[#1]{#2}{#3}{}[#4]}
\def\@xs@exitallgroups{\ifnum\@xs@nestlevel>\z@\endgroup\expandafter\@xs@exitallgroups\fi}
% Compte combien d'unit\'es syntaxiques contient la chaine #1 ?
\@xs@newmacro\StrLen{}{1}{1}{%
\def\@xs@reserved@C{#1}%
\decimalpart\z@
\let\@xs@nestlevel\z@
\gdef\groupID{0}%
\let\@xs@atbegingroup\relax
\def\@xs@atendofgroup{\endgroup\@xs@read@reserved@C}%
\let\@xs@atnextsyntaxunit\relax
\@xs@read@reserved@C
\expandafter\@xs@ReturnResult\expandafter{\number\decimalpart}{#2}%
}
% Macro interne fermant autant de groupes que n\'ecessaire pour trouver une unit\'e syntaxique derri\`ere
\def\@xs@continuetonext{%
\expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}%
{\ifnum\@xs@nestlevel>\z@
\expandafter\endgroup\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% on concat\`ene
\expandafter\expandafter\expandafter\@xs@continuetonext% on recommence
\fi}
\relax
}%
\def\@xs@manage@groupID{%
\begingroup\def\@xs@reserved@A{0}%
\ifx\@xs@reserved@A\groupID% si on arrive du groupe de niveau 0
\endgroup
\xdef\groupID{\number\integerpart}% on met simplement le niveau
\else
\endgroup
\expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\groupID\expandafter\expandafter\expandafter{\expandafter\groupID\expandafter,\number\integerpart}%
\fi
}
% Cette macro coupe la chaine #1 apr\`es l'unit\'e syntaxique n°#2
\def\StrSplit{%
\@ifstar
{\let\@xs@reserved@E\@xs@continuetonext\StrSpl@t}%
{\let\@xs@reserved@E\relax\StrSpl@t}%
}
\@xs@newmacro\StrSpl@t{}{2}{0}{\@xs@StrSplit@i{#2}{#1}\@xs@StrSplit@ii}
% Cette macro interne coupe la chaine #2 apr\`es l'unit\'e syntaxique n°#1
% Le d\'ebut est assign\'e dans \@xs@reserved@B et la fin dans \@xs@reserved@C
\long\def\@xs@StrSplit@i#1#2{%
\def\@xs@reserved@D{#1}%
\def\@xs@reserved@C{#2}%
\let\@xs@reserved@B\@empty
\global\let\groupID\@empty
\ifnum#1>\z@
\decimalpart\z@
\integerpart\z@
\gdef\groupID{0}%
\let\@xs@nestlevel\z@
\def\@xs@atendofgroup{%
\expandafter\endgroup
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}%
\@xs@read@reserved@C
}%
\def\@xs@atbegingroup{\let\@xs@reserved@B\@empty}%
\def\@xs@atnextsyntaxunit{%
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@A}%
\ifnum\decimalpart=\@xs@reserved@D\relax
\ifx\@xs@reserved@C\@empty\@xs@reserved@E\fi
\global\let\@xs@reserved@B\@xs@reserved@B
\global\let\@xs@reserved@C\@xs@reserved@C
\@xs@exitallgroups
\let\@xs@next\relax
\fi
}%
\@xs@read@reserved@C
\fi
}
\def\@xs@StrSplit@ii#1#2{\let#1\@xs@reserved@B\let#2\@xs@reserved@C}
% StrCut[n]{<texte>}{<motif>}\macroA\macroB
% \macroA reçoit ce qui se trouve avant la n ème occurrence <motif> dans <texte>
% \macroB reçoit ce qui est après cette n ème occurrence
\@xs@newmacro*3\StrCut{1}{2}{0}{%
\@xs@ifempty{#3}%
{\global\let\groupID\@empty
\let\@xs@reserved@C\@empty
\let\@xs@reserved@E\@empty
}
{\ifnum#1<\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{\@xs@StrCut@ii{#2}{#3}1}
{\@xs@StrCut@ii{#2}{#3}{#1}}%
}%
\@xs@StrCut@iii
}
\long\def\@xs@StrCut@ii#1#2#3{%
\def\@xs@reserved@D{#1}%
\let\@xs@reserved@C\@empty
\def\@xs@reserved@E{#2}%
\decimalpart\z@\integerpart\z@
\gdef\groupID{0}%
\let\@xs@nestlevel\z@
\def\@xs@atendofgroup{%
\expandafter\endgroup
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}%
\@xs@read@reserved@D
}%
\def\@xs@atoccurfound{%
\ifnum\decimalpart=\numexpr(#3)\relax
\global\let\@xs@reserved@D\@xs@reserved@D
\global\let\@xs@reserved@C\@xs@reserved@C
\@xs@exitallgroups
\let\@xs@next\relax
\else
\expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@E}%
\let\@xs@next\@xs@read@reserved@D
\fi
}%
\@xs@read@reserved@D
\def\@xs@argument@A{#2}%
\let\@xs@reserved@E\@xs@reserved@D
\expandafter\expandafter\expandafter
\def
\expandafter\expandafter\expandafter
\@xs@reserved@D
\expandafter\expandafter\expandafter
{\expandafter\@xs@reserved@C\@xs@argument@A}%
}
\long\def\@xs@StrCut@iii#1#2{\let#1\@xs@reserved@C\let#2\@xs@reserved@E}
% De la chaine #1, renvoie ce qui se trouve entre les positions
% #2 et #3, unit\'es syntaxiques aux positions compris !
\@xs@newmacro\StrMid{}{3}{1}{%
\begingroup
\noexploregroups
\let\@xs@reserved@E\relax
\@xs@StrSplit@i{#3}{#1}%
\edef\@xs@reserved@C{\number\numexpr#2-1}%
\let\@xs@reserved@E\relax
\expandafter\expandafter\expandafter\@xs@StrSplit@i\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@B}%
\expandafter\endgroup
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}%
\global\let\groupID\@empty
}
% supprime #2 unit\'es syntaxiques \`a gauche dans la chaine #1
\@xs@newmacro\StrGobbleLeft{}{2}{1}{%
\let\@xs@reserved@E\relax
\@xs@StrSplit@i{#2}{#1}%
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}%
}
% extrait de #1 la chaine \`a gauche de longueur #2
\@xs@newmacro\StrLeft{}{2}{1}{%
\let\@xs@reserved@E\relax
\@xs@StrSplit@i{#2}{#1}%
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}%
}
% supprime #2 unit\'es syntaxiques \`a droite dans la chaine #1
\@xs@newmacro\StrGobbleRight{}{2}{1}{%
\@xs@StrLen{#1}[\@xs@reserved@D]%
\let\@xs@reserved@E\relax
\expandafter\@xs@StrSplit@i\expandafter{\number\numexpr\@xs@reserved@D-#2}{#1}%
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}%
}
% renvoie #2 unit\'es syntaxiques \`a la droite de la chaine #1
\@xs@newmacro\StrRight{}{2}{1}{%
\@xs@StrLen{#1}[\@xs@reserved@D]%
\let\@xs@reserved@E\relax
\expandafter\@xs@StrSplit@i\expandafter{\number\numexpr\@xs@reserved@D-#2}{#1}%
\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}%
}
\@xs@newmacro\StrChar{}{2}{1}{%
\let\@xs@reserved@B\@empty
\def\@xs@reserved@C{#1}\def\@xs@reserved@D{#2}%