##// END OF EJS Templates
xdiff: add comments for fields in xdfile_t...
Jun Wu -
r36839:0c735065 default
parent child Browse files
Show More
@@ -1,71 +1,105
1 /*
1 /*
2 * LibXDiff by Davide Libenzi ( File Differential Library )
2 * LibXDiff by Davide Libenzi ( File Differential Library )
3 * Copyright (C) 2003 Davide Libenzi
3 * Copyright (C) 2003 Davide Libenzi
4 *
4 *
5 * This library is free software; you can redistribute it and/or
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
8 * version 2.1 of the License, or (at your option) any later version.
9 *
9 *
10 * This library is distributed in the hope that it will be useful,
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
13 * Lesser General Public License for more details.
14 *
14 *
15 * You should have received a copy of the GNU Lesser General Public
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see
16 * License along with this library; if not, see
17 * <http://www.gnu.org/licenses/>.
17 * <http://www.gnu.org/licenses/>.
18 *
18 *
19 * Davide Libenzi <davidel@xmailserver.org>
19 * Davide Libenzi <davidel@xmailserver.org>
20 *
20 *
21 */
21 */
22
22
23 #if !defined(XTYPES_H)
23 #if !defined(XTYPES_H)
24 #define XTYPES_H
24 #define XTYPES_H
25
25
26
26
27
27
28 typedef struct s_chanode {
28 typedef struct s_chanode {
29 struct s_chanode *next;
29 struct s_chanode *next;
30 long icurr;
30 long icurr;
31 } chanode_t;
31 } chanode_t;
32
32
33 typedef struct s_chastore {
33 typedef struct s_chastore {
34 chanode_t *head, *tail;
34 chanode_t *head, *tail;
35 long isize, nsize;
35 long isize, nsize;
36 chanode_t *ancur;
36 chanode_t *ancur;
37 chanode_t *sncur;
37 chanode_t *sncur;
38 long scurr;
38 long scurr;
39 } chastore_t;
39 } chastore_t;
40
40
41 typedef struct s_xrecord {
41 typedef struct s_xrecord {
42 struct s_xrecord *next;
42 struct s_xrecord *next;
43 char const *ptr;
43 char const *ptr;
44 long size;
44 long size;
45 unsigned long ha;
45 unsigned long ha;
46 } xrecord_t;
46 } xrecord_t;
47
47
48 typedef struct s_xdfile {
48 typedef struct s_xdfile {
49 /* manual memory management */
49 chastore_t rcha;
50 chastore_t rcha;
51
52 /* number of records (lines) */
50 long nrec;
53 long nrec;
54
55 /* hash table size
56 * the maximum hash value in the table is (1 << hbits) */
51 unsigned int hbits;
57 unsigned int hbits;
58
59 /* hash table, hash value => xrecord_t
60 * note: xrecord_t is a linked list. */
52 xrecord_t **rhash;
61 xrecord_t **rhash;
62
63 /* range excluding common prefix and suffix
64 * [recs[i] for i in range(0, dstart)] are common prefix.
65 * [recs[i] for i in range(dstart, dend + 1 - dstart)] are interesting
66 * lines */
53 long dstart, dend;
67 long dstart, dend;
68
69 /* pointer to records (lines) */
54 xrecord_t **recs;
70 xrecord_t **recs;
71
72 /* record changed, use original "recs" index
73 * rchag[i] can be either 0 or 1. 1 means recs[i] (line i) is marked
74 * "changed". */
55 char *rchg;
75 char *rchg;
76
77 /* cleaned-up record index => original "recs" index
78 * clean-up means:
79 * rule 1. remove common prefix and suffix
80 * rule 2. remove records that are only on one side, since they can
81 * not match the other side
82 * rindex[0] is likely dstart, if not removed up by rule 2.
83 * rindex[nreff - 1] is likely dend, if not removed by rule 2.
84 */
56 long *rindex;
85 long *rindex;
86
87 /* rindex size */
57 long nreff;
88 long nreff;
89
90 /* cleaned-up record index => hash value
91 * ha[i] = recs[rindex[i]]->ha */
58 unsigned long *ha;
92 unsigned long *ha;
59 } xdfile_t;
93 } xdfile_t;
60
94
61 typedef struct s_xdfenv {
95 typedef struct s_xdfenv {
62 xdfile_t xdf1, xdf2;
96 xdfile_t xdf1, xdf2;
63
97
64 /* number of lines for common prefix and suffix that are removed
98 /* number of lines for common prefix and suffix that are removed
65 * from xdf1 and xdf2 as a preprocessing step */
99 * from xdf1 and xdf2 as a preprocessing step */
66 long nprefix, nsuffix;
100 long nprefix, nsuffix;
67 } xdfenv_t;
101 } xdfenv_t;
68
102
69
103
70
104
71 #endif /* #if !defined(XTYPES_H) */
105 #endif /* #if !defined(XTYPES_H) */
General Comments 0
You need to be logged in to leave comments. Login now