summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/codicefiscaleitaliano/codicefiscaleitaliano.sty
blob: 6d59f18a97f555a0a9c5522bffc37847e2173f56 (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
%%
%% This is file `codicefiscaleitaliano.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% codicefiscaleitaliano.dtx  (with options: `package')
%%   ______________________________________________________
%%   The codicefiscaleitaliano package for LaTeX and XeLaTeX
%%   Copyright (C) 2012 Claudio Beccari
%%   All rights reserved
%% 
%%   License information appended
%% 
%%
%% File `codicefiscaleitaliano.dtx'.
%% Copyright (C)  2012 Claudio Beccari  all rights reserved.
%%
\NeedsTeXFormat{LaTeX2e}[2011/06/20]
\ProvidesPackage{codicefiscaleitaliano}%
        [2012/05/06 v.1.2 Controlla il codice fiscale italiano]
\newif\ifcontrollo \controllotrue
\newif\ifstampacodice \stampacodicefalse
\def\getCFletter#1#2!{\ifx#1\space\getCFLetter#2!\else
\Letter=`#1\def\CFisc{#2}\fi}
\def\getOddValore{%
\ifnum\Letter<\A
\valore=\expandafter\ifcase\numexpr\Letter-\zero\relax
1\or0\or5\or7\or9\or13\or15\or17\or19%
\or21\fi
\else
\valore=\expandafter\ifcase\numexpr\Letter-\A\relax
1\or0\or5\or7\or9\or13\or15\or17\or19%
\or21\or2\or4\or18\or20\or11\or3\or6\or8%
\or12\or14\or16\or10\or22\or25\or24\or23\fi
\fi}
\def\getEvenValore{%
\ifnum\Letter<\A
\valore=\numexpr\Letter-\zero\relax
\else
\valore=\numexpr\Letter-\A\relax
\fi}
\newcommand*\codicefiscaleitaliano{%
\@ifstar{\c@dfiscit[\stampacodicetrue]}{\c@dfiscit}}
\newcommand*\c@dfiscit[2][\stampacodicefalse]{#1\edef\CFisc{#2}%
\let\codfisc\CFisc
\begingroup
\countdef\cifra=256 \cifra=\z@
\countdef\A=258\A=`\A
\countdef\zero=260 \zero=`\0
\countdef\Letter=262
\countdef\valore=264
\countdef\somma=266 \somma=\z@
\@whilenum\cifra<16\do{\advance\cifra\@ne
\ifx\CFisc\@empty
\cifra=16\controllofalse
\PackageError{codicefiscaleitaliano}{%
\MessageBreak
**************************************
\MessageBreak
Il codice fiscale #2\MessageBreak
non ha 16 caratteri.
\MessageBreak
L'esecuzione della verifica viene\MessageBreak
interrotta.
\MessageBreak
**************************************
}{Premere <invio> per continuare}%
\else
\expandafter\getCFletter\CFisc!\relax
\ifodd\cifra
\getOddValore%
\else
\getEvenValore%
\fi
\advance\somma\valore
\fi}\unless\ifx\CFisc\@empty\controllofalse
\PackageError{codicefiscaleitaliano}{%
\MessageBreak
**************************************
\MessageBreak
Il codice immesso #2\MessageBreak
contiene piu' di 16 caratteri.
\MessageBreak
L'esecuzione della verifica viene\MessageBreak
interrotta.
\MessageBreak
**************************************
}{%
Premere <invio> per continuare.
}%
\else
\ifcontrollo
\advance\somma-\valore
\Letter\somma
\divide\Letter by 26\relax
\somma=\numexpr\somma - 26*\Letter\relax
\ifnum\valore=\somma
\PackageInfo{codicefiscaleitaliano}{\MessageBreak
Codice fiscale OK}
\else
\controllofalse
\PackageError{codicefiscaleitaliano}{\MessageBreak
***************************************\MessageBreak
Codice fiscale #2 errato\MessageBreak
***************************************}{%
Premi S oppure Q oppure <invio>; il file
verra' elaborato lo stesso ma il codice
fiscale deve venire ricontrollato!}
\fi
\fi
\fi\ifcontrollo\ifstampacodice\codfisc\fi\fi\endgroup}

%% 
%% Copyright 2012 Claudio Beccari
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "author-maintained"
%% 
%% This work consists of this file codicefiscaleitaliano.dtx, a README file
%% and the derived files codicefiscaleitaliano.sty and codicefiscaleitaliano.pdf.
%% 
%%
%% End of file `codicefiscaleitaliano.sty'.