ReactOS 0.4.15-dev-7934-g1dc8d80
text.h File Reference
#include "fc.h"
Include dependency graph for text.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IS_SPACE(ch)   ((ch) == TEXT(' ') || (ch) == TEXT('\t'))
 
#define NODE   NODE_A
 
#define PrintLine   PrintLineA
 
#define TextCompare   TextCompareA
 
#define TAB_WIDTH   8
 
#define HASH_EOF   0xFFFFFFFF
 
#define HASH_MASK   0x7FFFFFFF
 

Functions

static LPTSTR AllocLine (LPCTSTR pch, DWORD cch)
 
static NODEAllocNode (LPTSTR psz, DWORD lineno)
 
static __inline VOID DeleteNode (NODE *node)
 
static VOID DeleteList (struct list *list)
 
static __inline LPCTSTR SkipSpace (LPCTSTR pch)
 
static __inline LPCTSTR FindLastNonSpace (LPCTSTR pch)
 
static VOID DeleteDuplicateSpaces (LPTSTR psz)
 
static LPTSTR CompressSpace (LPCTSTR line)
 
static INT ExpandTabLength (LPCTSTR line)
 
static LPTSTR ExpandTab (LPCTSTR line)
 
static DWORD GetHash (LPCTSTR psz, BOOL bIgnoreCase)
 
static NODEAllocEOFNode (DWORD lineno)
 
static __inline BOOL IsEOFNode (NODE *node)
 
static BOOL ConvertNode (const FILECOMPARE *pFC, NODE *node)
 
static FCRET CompareNode (const FILECOMPARE *pFC, const NODE *node0, const NODE *node1)
 
static BOOL FindNextLine (LPCTSTR pch, DWORD ich, DWORD cch, LPDWORD pich)
 
static FCRET ParseLines (const FILECOMPARE *pFC, HANDLE *phMapping, LARGE_INTEGER *pib, const LARGE_INTEGER *pcb, struct list *list)
 
static VOID ShowDiff (FILECOMPARE *pFC, INT i, struct list *begin, struct list *end)
 
static VOID SkipIdentical (FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1)
 
static DWORD SkipIdenticalN (FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1, DWORD nnnn, DWORD lineno0, DWORD lineno1)
 
static FCRET ScanDiff (FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1, DWORD lineno0, DWORD lineno1)
 
static FCRET Resync (FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1)
 
static FCRET Finalize (FILECOMPARE *pFC, struct list *ptr0, struct list *ptr1, BOOL fDifferent)
 
FCRET TextCompare (FILECOMPARE *pFC, HANDLE *phMapping0, const LARGE_INTEGER *pcb0, HANDLE *phMapping1, const LARGE_INTEGER *pcb1)
 

Macro Definition Documentation

◆ HASH_EOF

#define HASH_EOF   0xFFFFFFFF

Definition at line 168 of file text.h.

◆ HASH_MASK

#define HASH_MASK   0x7FFFFFFF

Definition at line 169 of file text.h.

◆ IS_SPACE

#define IS_SPACE (   ch)    ((ch) == TEXT(' ') || (ch) == TEXT('\t'))

Definition at line 10 of file text.h.

◆ NODE

#define NODE   NODE_A

Definition at line 17 of file text.h.

◆ PrintLine

#define PrintLine   PrintLineA

Definition at line 18 of file text.h.

◆ TAB_WIDTH

#define TAB_WIDTH   8

Definition at line 125 of file text.h.

◆ TextCompare

#define TextCompare   TextCompareA

Definition at line 19 of file text.h.

Function Documentation

◆ AllocEOFNode()

static NODE * AllocEOFNode ( DWORD  lineno)
static

Definition at line 183 of file text.h.

184{
185 NODE *node = AllocNode(AllocLine(NULL, 0), 0);
186 if (node == NULL)
187 return NULL;
188 node->pszComp = AllocLine(NULL, 0);
189 if (node->pszComp == NULL)
190 {
192 return NULL;
193 }
194 node->lineno = lineno;
195 node->hash = HASH_EOF;
196 return node;
197}
static NODE * AllocNode(LPTSTR psz, DWORD lineno)
Definition: text.h:32
static LPTSTR AllocLine(LPCTSTR pch, DWORD cch)
Definition: text.h:22
#define NODE
Definition: text.h:17
#define HASH_EOF
Definition: text.h:168
static __inline VOID DeleteNode(NODE *node)
Definition: text.h:48
#define NULL
Definition: types.h:112
Definition: dlist.c:348

Referenced by ParseLines().

◆ AllocLine()

static LPTSTR AllocLine ( LPCTSTR  pch,
DWORD  cch 
)
static

Definition at line 22 of file text.h.

23{
24 LPTSTR pszNew = malloc((cch + 1) * sizeof(TCHAR));
25 if (!pszNew)
26 return NULL;
27 memcpy(pszNew, pch, cch * sizeof(TCHAR));
28 pszNew[cch] = 0;
29 return pszNew;
30}
#define malloc
Definition: debug_ros.c:4
#define pch(ap)
Definition: match.c:418
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by AllocEOFNode(), CompressSpace(), and ParseLines().

◆ AllocNode()

static NODE * AllocNode ( LPTSTR  psz,
DWORD  lineno 
)
static

Definition at line 32 of file text.h.

33{
34 NODE *node;
35 if (!psz)
36 return NULL;
37 node = calloc(1, sizeof(NODE));
38 if (!node)
39 {
40 free(psz);
41 return NULL;
42 }
43 node->pszLine = psz;
44 node->lineno = lineno;
45 return node;
46}
#define free
Definition: debug_ros.c:5
#define calloc
Definition: rosglue.h:14

Referenced by AllocEOFNode(), and ParseLines().

◆ CompareNode()

static FCRET CompareNode ( const FILECOMPARE pFC,
const NODE node0,
const NODE node1 
)
static

Definition at line 226 of file text.h.

227{
228 DWORD dwCmpFlags;
229 LPTSTR psz0, psz1;
230 INT ret;
231 if (node0->hash != node1->hash)
232 return FCRET_DIFFERENT;
233
234 psz0 = (pFC->dwFlags & FLAG_W) ? node0->pszComp : node0->pszLine;
235 psz1 = (pFC->dwFlags & FLAG_W) ? node1->pszComp : node1->pszLine;
236 dwCmpFlags = ((pFC->dwFlags & FLAG_C) ? NORM_IGNORECASE : 0);
237 ret = CompareString(LOCALE_USER_DEFAULT, dwCmpFlags, psz0, -1, psz1, -1);
239}
@ FCRET_IDENTICAL
Definition: fc.h:26
@ FCRET_DIFFERENT
Definition: fc.h:27
#define FLAG_W
Definition: fc.h:58
#define FLAG_C
Definition: fc.h:51
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LOCALE_USER_DEFAULT
DWORD dwFlags
Definition: fc.h:64
int32_t INT
Definition: typedefs.h:58
int ret
#define NORM_IGNORECASE
Definition: winnls.h:176
#define CSTR_EQUAL
Definition: winnls.h:456
#define CompareString
Definition: winnls.h:1174

Referenced by Resync(), SkipIdentical(), and SkipIdenticalN().

◆ CompressSpace()

static LPTSTR CompressSpace ( LPCTSTR  line)
static

Definition at line 107 of file text.h.

108{
109 LPTSTR pszNew;
110 LPCTSTR pchLast;
111
113 pchLast = FindLastNonSpace(line);
114 if (pchLast == NULL)
115 return AllocLine(NULL, 0);
116
117 pszNew = AllocLine(line, (DWORD)(pchLast - line) + 1);
118 if (!pszNew)
119 return NULL;
120
121 DeleteDuplicateSpaces(pszNew);
122 return pszNew;
123}
static VOID DeleteDuplicateSpaces(LPTSTR psz)
Definition: text.h:89
static __inline LPCTSTR SkipSpace(LPCTSTR pch)
Definition: text.h:70
static __inline LPCTSTR FindLastNonSpace(LPCTSTR pch)
Definition: text.h:77
Definition: parser.c:49
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by ConvertNode().

◆ ConvertNode()

static BOOL ConvertNode ( const FILECOMPARE pFC,
NODE node 
)
static

Definition at line 204 of file text.h.

205{
206 if (!(pFC->dwFlags & FLAG_T))
207 {
208 LPTSTR tmp = ExpandTab(node->pszLine);
209 if (!tmp)
210 return FALSE;
211 free(node->pszLine);
212 node->pszLine = tmp;
213 if (!(pFC->dwFlags & FLAG_W))
214 node->hash = GetHash(node->pszLine, !!(pFC->dwFlags & FLAG_C));
215 }
216 if (pFC->dwFlags & FLAG_W)
217 {
218 node->pszComp = CompressSpace(node->pszLine);
219 if (!node->pszComp)
220 return FALSE;
221 node->hash = GetHash(node->pszComp, !!(pFC->dwFlags & FLAG_C));
222 }
223 return TRUE;
224}
static LPTSTR ExpandTab(LPCTSTR line)
Definition: text.h:141
static DWORD GetHash(LPCTSTR psz, BOOL bIgnoreCase)
Definition: text.h:171
static LPTSTR CompressSpace(LPCTSTR line)
Definition: text.h:107
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FLAG_T
Definition: fc.h:56

Referenced by ParseLines().

◆ DeleteDuplicateSpaces()

static VOID DeleteDuplicateSpaces ( LPTSTR  psz)
static

Definition at line 89 of file text.h.

90{
91 LPTSTR pch0, pch1;
92 for (pch0 = pch1 = psz; *pch0; ++pch0)
93 {
94 *pch1++ = *pch0;
95 if (IS_SPACE(*pch0))
96 {
97 do
98 {
99 ++pch0;
100 } while (IS_SPACE(*pch0));
101 --pch0;
102 }
103 }
104 *pch1 = 0;
105}
#define IS_SPACE(ch)
Definition: text.h:10

Referenced by CompressSpace().

◆ DeleteList()

static VOID DeleteList ( struct list list)
static

Definition at line 58 of file text.h.

59{
60 struct list *ptr;
61 NODE *node;
62 while ((ptr = list_head(list)) != NULL)
63 {
67 }
68}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
Definition: list.h:37
uint32_t entry
Definition: isohybrid.c:63
static PVOID ptr
Definition: dispmode.c:27
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by TextCompare().

◆ DeleteNode()

static __inline VOID DeleteNode ( NODE node)
static

Definition at line 48 of file text.h.

49{
50 if (node)
51 {
52 free(node->pszLine);
53 free(node->pszComp);
54 free(node);
55 }
56}

Referenced by _CmdWndProc(), AllocEOFNode(), DeleteList(), ParseLines(), and RtlpDeleteAvlTreeNode().

◆ ExpandTab()

static LPTSTR ExpandTab ( LPCTSTR  line)
static

Definition at line 141 of file text.h.

142{
143 INT spaces, cch = ExpandTabLength(line), ich;
144 LPTSTR pszNew = malloc((cch + 1) * sizeof(TCHAR));
145 LPCTSTR pch;
146 if (!pszNew)
147 return NULL;
148 ich = 0;
149 for (pch = line; *pch; ++pch)
150 {
151 if (*pch == TEXT('\t'))
152 {
153 spaces = TAB_WIDTH - (ich % TAB_WIDTH);
154 while (spaces-- > 0)
155 {
156 pszNew[ich++] = TEXT(' ');
157 }
158 }
159 else
160 {
161 pszNew[ich++] = *pch;
162 }
163 }
164 pszNew[ich] = 0;
165 return pszNew;
166}
#define TAB_WIDTH
Definition: text.h:125
static INT ExpandTabLength(LPCTSTR line)
Definition: text.h:127
#define TEXT(s)
Definition: k32.h:26

Referenced by ConPagerWorker(), and ConvertNode().

◆ ExpandTabLength()

static INT ExpandTabLength ( LPCTSTR  line)
static

Definition at line 127 of file text.h.

128{
129 LPCTSTR pch;
130 INT cch = 0;
131 for (pch = line; *pch; ++pch)
132 {
133 if (*pch == TEXT('\t'))
134 cch += TAB_WIDTH - (cch % TAB_WIDTH);
135 else
136 ++cch;
137 }
138 return cch;
139}

Referenced by ExpandTab().

◆ Finalize()

static FCRET Finalize ( FILECOMPARE pFC,
struct list ptr0,
struct list ptr1,
BOOL  fDifferent 
)
static

Definition at line 515 of file text.h.

516{
517 if (!ptr0 && !ptr1)
518 {
519 if (fDifferent)
520 return Different(pFC->file[0], pFC->file[1]);
521 return NoDifference();
522 }
523 else
524 {
525 ShowDiff(pFC, 0, ptr0, NULL);
526 ShowDiff(pFC, 1, ptr1, NULL);
528 return FCRET_DIFFERENT;
529 }
530}
FCRET NoDifference(VOID)
Definition: fc.c:46
VOID PrintEndOfDiff(VOID)
Definition: fc.c:93
FCRET Different(LPCWSTR file0, LPCWSTR file1)
Definition: fc.c:52
static VOID ShowDiff(FILECOMPARE *pFC, INT i, struct list *begin, struct list *end)
Definition: text.h:320
LPCWSTR file[2]
Definition: fc.h:67

Referenced by CheckLogOrSourceExistence(), and TextCompare().

◆ FindLastNonSpace()

static __inline LPCTSTR FindLastNonSpace ( LPCTSTR  pch)
static

Definition at line 77 of file text.h.

78{
79 LPCTSTR pchLast = NULL;
80 while (*pch)
81 {
82 if (!IS_SPACE(*pch))
83 pchLast = pch;
84 ++pch;
85 }
86 return pchLast;
87}

Referenced by CompressSpace().

◆ FindNextLine()

static BOOL FindNextLine ( LPCTSTR  pch,
DWORD  ich,
DWORD  cch,
LPDWORD  pich 
)
static

Definition at line 241 of file text.h.

242{
243 while (ich < cch)
244 {
245 if (pch[ich] == TEXT('\n') || pch[ich] == TEXT('\0'))
246 {
247 *pich = ich;
248 return TRUE;
249 }
250 ++ich;
251 }
252 *pich = cch;
253 return FALSE;
254}

Referenced by ParseLines().

◆ GetHash()

static DWORD GetHash ( LPCTSTR  psz,
BOOL  bIgnoreCase 
)
static

Definition at line 171 of file text.h.

172{
173 DWORD ret = 0xDEADFACE;
174 while (*psz)
175 {
176 ret += (bIgnoreCase ? towupper(*psz) : *psz);
177 ret <<= 2;
178 ++psz;
179 }
180 return (ret & HASH_MASK);
181}
#define HASH_MASK
Definition: text.h:169
static BOOL bIgnoreCase
Definition: find.c:28
#define towupper(c)
Definition: wctype.h:99

Referenced by ConvertNode().

◆ IsEOFNode()

static __inline BOOL IsEOFNode ( NODE node)
static

Definition at line 199 of file text.h.

200{
201 return !node || node->hash == HASH_EOF;
202}

Referenced by ShowDiff(), and TextCompare().

◆ ParseLines()

static FCRET ParseLines ( const FILECOMPARE pFC,
HANDLE phMapping,
LARGE_INTEGER pib,
const LARGE_INTEGER pcb,
struct list list 
)
static

Definition at line 257 of file text.h.

259{
260 DWORD lineno = 1, ich, cch, ichNext, cbView, cchNode;
261 LPTSTR psz, pszLine;
262 BOOL fLast, bCR;
263 NODE *node;
264
265 if (*phMapping == NULL)
266 return FCRET_NO_MORE_DATA;
267
268 if (pib->QuadPart >= pcb->QuadPart)
269 {
270 CloseHandle(*phMapping);
271 *phMapping = NULL;
272 return FCRET_NO_MORE_DATA;
273 }
274
275 cbView = (DWORD)min(pcb->QuadPart - pib->QuadPart, MAX_VIEW_SIZE);
276 psz = MapViewOfFile(*phMapping, FILE_MAP_READ, pib->HighPart, pib->LowPart, cbView);
277 if (!psz)
278 {
279 return OutOfMemory();
280 }
281
282 ich = 0;
283 cch = cbView / sizeof(TCHAR);
284 fLast = (pib->QuadPart + cbView >= pcb->QuadPart);
285 while (ich < cch &&
286 (FindNextLine(psz, ich, cch, &ichNext) ||
287 (ichNext == cch && (fLast || ich == 0))))
288 {
289 bCR = (ichNext > 0) && (psz[ichNext - 1] == TEXT('\r'));
290 cchNode = ichNext - ich - bCR;
291 pszLine = AllocLine(&psz[ich], cchNode);
292 node = AllocNode(pszLine, lineno++);
293 if (!node || !ConvertNode(pFC, node))
294 {
296 UnmapViewOfFile(psz);
297 return OutOfMemory();
298 }
299 list_add_tail(list, &node->entry);
300 ich = ichNext + 1;
301 }
302
303 UnmapViewOfFile(psz);
304
305 pib->QuadPart += ichNext * sizeof(WCHAR);
306
307 if (pib->QuadPart < pcb->QuadPart)
308 return FCRET_IDENTICAL;
309
310 // append EOF node
311 node = AllocEOFNode(lineno);
312 if (!node)
313 return OutOfMemory();
314 list_add_tail(list, &node->entry);
315
316 return FCRET_NO_MORE_DATA;
317}
static BOOL ConvertNode(const FILECOMPARE *pFC, NODE *node)
Definition: text.h:204
static BOOL FindNextLine(LPCTSTR pch, DWORD ich, DWORD cch, LPDWORD pich)
Definition: text.h:241
static NODE * AllocEOFNode(DWORD lineno)
Definition: text.h:183
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define CloseHandle
Definition: compat.h:739
#define UnmapViewOfFile
Definition: compat.h:746
#define FILE_MAP_READ
Definition: compat.h:776
#define MapViewOfFile
Definition: compat.h:745
@ FCRET_NO_MORE_DATA
Definition: fc.h:29
#define MAX_VIEW_SIZE
Definition: fc.h:96
unsigned int BOOL
Definition: ntddk_ex.h:94
@ OutOfMemory
Definition: gdiplustypes.h:29
#define min(a, b)
Definition: monoChain.cc:55
#define DWORD
Definition: nt_native.h:44
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TextCompare().

◆ Resync()

static FCRET Resync ( FILECOMPARE pFC,
struct list **  pptr0,
struct list **  pptr1 
)
static

Definition at line 443 of file text.h.

444{
445 FCRET ret;
446 struct list *ptr0, *ptr1, *save0 = NULL, *save1 = NULL;
447 NODE *node0, *node1;
448 struct list *list0 = &pFC->list[0], *list1 = &pFC->list[1];
449 DWORD lineno0, lineno1;
450 INT penalty, i0, i1, min_penalty = MAXLONG;
451
452 node0 = LIST_ENTRY(*pptr0, NODE, entry);
453 node1 = LIST_ENTRY(*pptr1, NODE, entry);
454 lineno0 = node0->lineno + pFC->n;
455 lineno1 = node1->lineno + pFC->n;
456
457 // ``If the files that you are comparing have more than pFC->n consecutive
458 // differing lines, FC cancels the comparison,,
459 // ``If the number of matching lines in the files is less than pFC->nnnn,
460 // FC displays the matching lines as differences,,
461 for (ptr1 = list_next(list1, *pptr1), i1 = 0; ptr1; ptr1 = list_next(list1, ptr1), ++i1)
462 {
463 node1 = LIST_ENTRY(ptr1, NODE, entry);
464 if (node1->lineno >= lineno1)
465 break;
466 for (ptr0 = list_next(list0, *pptr0), i0 = 0; ptr0; ptr0 = list_next(list0, ptr0), ++i0)
467 {
468 node0 = LIST_ENTRY(ptr0, NODE, entry);
469 if (node0->lineno >= lineno0)
470 break;
471 if (CompareNode(pFC, node0, node1) == FCRET_IDENTICAL)
472 {
473 penalty = min(i0, i1) + abs(i1 - i0);
474 if (min_penalty > penalty)
475 {
476 min_penalty = penalty;
477 save0 = ptr0;
478 save1 = ptr1;
479 }
480 }
481 }
482 }
483
484 if (save0 && save1)
485 {
486 *pptr0 = save0;
487 *pptr1 = save1;
488 ret = ScanDiff(pFC, &save0, &save1, lineno0, lineno1);
489 if (save0 && save1)
490 {
491 *pptr0 = save0;
492 *pptr1 = save1;
493 }
494 return ret;
495 }
496
497 for (ptr0 = *pptr0; ptr0; ptr0 = list_next(list0, ptr0))
498 {
499 node0 = LIST_ENTRY(ptr0, NODE, entry);
500 if (node0->lineno == lineno0)
501 break;
502 }
503 for (ptr1 = *pptr1; ptr1; ptr1 = list_next(list1, ptr1))
504 {
505 node1 = LIST_ENTRY(ptr1, NODE, entry);
506 if (node1->lineno == lineno1)
507 break;
508 }
509 *pptr0 = ptr0;
510 *pptr1 = ptr1;
511 return FCRET_DIFFERENT;
512}
static FCRET ScanDiff(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1, DWORD lineno0, DWORD lineno1)
Definition: text.h:407
static FCRET CompareNode(const FILECOMPARE *pFC, const NODE *node0, const NODE *node1)
Definition: text.h:226
FCRET
Definition: fc.h:24
#define abs(i)
Definition: fconv.c:206
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
INT n
Definition: fc.h:65
struct list list[2]
Definition: fc.h:68
#define MAXLONG
Definition: umtypes.h:116

Referenced by TextCompare().

◆ ScanDiff()

static FCRET ScanDiff ( FILECOMPARE pFC,
struct list **  pptr0,
struct list **  pptr1,
DWORD  lineno0,
DWORD  lineno1 
)
static

Definition at line 407 of file text.h.

409{
410 struct list *ptr0 = *pptr0, *ptr1 = *pptr1, *tmp0, *tmp1;
411 NODE *node0, *node1;
412 INT count;
413 while (ptr0 && ptr1)
414 {
415 node0 = LIST_ENTRY(ptr0, NODE, entry);
416 node1 = LIST_ENTRY(ptr1, NODE, entry);
417 if (node0->lineno >= lineno0)
418 return FCRET_DIFFERENT;
419 if (node1->lineno >= lineno1)
420 return FCRET_DIFFERENT;
421 tmp0 = ptr0;
422 tmp1 = ptr1;
423 count = SkipIdenticalN(pFC, &tmp0, &tmp1, pFC->nnnn, lineno0, lineno1);
424 if (count >= pFC->nnnn)
425 break;
426 if (count > 0)
427 {
428 ptr0 = tmp0;
429 ptr1 = tmp1;
430 }
431 else
432 {
433 ptr0 = list_next(&pFC->list[0], ptr0);
434 ptr1 = list_next(&pFC->list[1], ptr1);
435 }
436 }
437 *pptr0 = ptr0;
438 *pptr1 = ptr1;
439 return FCRET_IDENTICAL;
440}
static DWORD SkipIdenticalN(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1, DWORD nnnn, DWORD lineno0, DWORD lineno1)
Definition: text.h:380
GLuint GLuint GLsizei count
Definition: gl.h:1545
INT nnnn
Definition: fc.h:66

Referenced by Resync().

◆ ShowDiff()

static VOID ShowDiff ( FILECOMPARE pFC,
INT  i,
struct list begin,
struct list end 
)
static

Definition at line 320 of file text.h.

321{
322 NODE* node;
323 struct list *list = &pFC->list[i];
324 struct list *first = NULL, *last = NULL;
325 PrintCaption(pFC->file[i]);
326 if (begin && end && list_prev(list, begin))
328 while (begin != end)
329 {
331 if (IsEOFNode(node))
332 break;
333 if (!first)
334 first = begin;
335 last = begin;
336 if (!(pFC->dwFlags & FLAG_A))
337 PrintLine(pFC, node->lineno, node->pszLine);
339 }
340 if ((pFC->dwFlags & FLAG_A) && first)
341 {
343 PrintLine(pFC, node->lineno, node->pszLine);
345 if (first != last)
346 {
347 if (list_next(list, first) == last)
348 {
350 PrintLine(pFC, node->lineno, node->pszLine);
351 }
352 else
353 {
354 PrintDots();
355 }
356 }
358 PrintLine(pFC, node->lineno, node->pszLine);
359 }
360}
VOID PrintCaption(LPCWSTR file)
Definition: fc.c:88
VOID PrintDots(VOID)
Definition: fc.c:98
#define PrintLine
Definition: text.h:18
static __inline BOOL IsEOFNode(NODE *node)
Definition: text.h:199
#define FLAG_A
Definition: fc.h:49
GLuint GLuint end
Definition: gl.h:1545
const GLint * first
Definition: glext.h:5794
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static UINT UINT last
Definition: font.c:45
__WINE_SERVER_LIST_INLINE struct list * list_prev(const struct list *list, const struct list *elem)
Definition: list.h:123
static clock_t begin
Definition: xmllint.c:458

Referenced by Finalize(), and TextCompare().

◆ SkipIdentical()

static VOID SkipIdentical ( FILECOMPARE pFC,
struct list **  pptr0,
struct list **  pptr1 
)
static

Definition at line 363 of file text.h.

364{
365 struct list *ptr0 = *pptr0, *ptr1 = *pptr1;
366 while (ptr0 && ptr1)
367 {
368 NODE *node0 = LIST_ENTRY(ptr0, NODE, entry);
369 NODE *node1 = LIST_ENTRY(ptr1, NODE, entry);
370 if (CompareNode(pFC, node0, node1) != FCRET_IDENTICAL)
371 break;
372 ptr0 = list_next(&pFC->list[0], ptr0);
373 ptr1 = list_next(&pFC->list[1], ptr1);
374 }
375 *pptr0 = ptr0;
376 *pptr1 = ptr1;
377}

Referenced by TextCompare().

◆ SkipIdenticalN()

static DWORD SkipIdenticalN ( FILECOMPARE pFC,
struct list **  pptr0,
struct list **  pptr1,
DWORD  nnnn,
DWORD  lineno0,
DWORD  lineno1 
)
static

Definition at line 380 of file text.h.

382{
383 struct list *ptr0 = *pptr0, *ptr1 = *pptr1;
384 DWORD count = 0;
385 while (ptr0 && ptr1)
386 {
387 NODE *node0 = LIST_ENTRY(ptr0, NODE, entry);
388 NODE *node1 = LIST_ENTRY(ptr1, NODE, entry);
389 if (node0->lineno >= lineno0)
390 break;
391 if (node1->lineno >= lineno1)
392 break;
393 if (CompareNode(pFC, node0, node1) != FCRET_IDENTICAL)
394 break;
395 ptr0 = list_next(&pFC->list[0], ptr0);
396 ptr1 = list_next(&pFC->list[1], ptr1);
397 ++count;
398 if (count >= nnnn)
399 break;
400 }
401 *pptr0 = ptr0;
402 *pptr1 = ptr1;
403 return count;
404}

Referenced by ScanDiff().

◆ SkipSpace()

static __inline LPCTSTR SkipSpace ( LPCTSTR  pch)
static

Definition at line 70 of file text.h.

71{
72 while (IS_SPACE(*pch))
73 ++pch;
74 return pch;
75}

Referenced by CompressSpace().

◆ TextCompare()

FCRET TextCompare ( FILECOMPARE pFC,
HANDLE phMapping0,
const LARGE_INTEGER pcb0,
HANDLE phMapping1,
const LARGE_INTEGER pcb1 
)

Definition at line 533 of file text.h.

535{
536 FCRET ret, ret0, ret1;
537 struct list *ptr0, *ptr1, *save0, *save1, *next0, *next1;
538 NODE* node0, * node1;
539 BOOL fDifferent = FALSE;
540 LARGE_INTEGER ib0 = { .QuadPart = 0 }, ib1 = { .QuadPart = 0 };
541 struct list *list0 = &pFC->list[0], *list1 = &pFC->list[1];
542 list_init(list0);
543 list_init(list1);
544
545 do
546 {
547 ret0 = ParseLines(pFC, phMapping0, &ib0, pcb0, list0);
548 if (ret0 == FCRET_INVALID)
549 {
550 ret = ret0;
551 goto cleanup;
552 }
553 ret1 = ParseLines(pFC, phMapping1, &ib1, pcb1, list1);
554 if (ret1 == FCRET_INVALID)
555 {
556 ret = ret1;
557 goto cleanup;
558 }
559
560 ptr0 = list_head(list0);
561 ptr1 = list_head(list1);
562 for (;;)
563 {
564 if (!ptr0 || !ptr1)
565 goto quit;
566
567 // skip identical (sync'ed)
568 SkipIdentical(pFC, &ptr0, &ptr1);
569 if (ptr0 || ptr1)
570 fDifferent = TRUE;
571 node0 = LIST_ENTRY(ptr0, NODE, entry);
572 node1 = LIST_ENTRY(ptr1, NODE, entry);
573 if (IsEOFNode(node0) || IsEOFNode(node1))
574 goto quit;
575
576 // try to resync
577 save0 = ptr0;
578 save1 = ptr1;
579 ret = Resync(pFC, &ptr0, &ptr1);
580 if (ret == FCRET_INVALID)
581 goto cleanup;
582 if (ret == FCRET_DIFFERENT)
583 {
584 // resync failed
585 ret = ResyncFailed();
586 // show the difference
587 ShowDiff(pFC, 0, save0, ptr0);
588 ShowDiff(pFC, 1, save1, ptr1);
590 goto cleanup;
591 }
592
593 // show the difference
594 fDifferent = TRUE;
595 next0 = ptr0 ? list_next(list0, ptr0) : ptr0;
596 next1 = ptr1 ? list_next(list1, ptr1) : ptr1;
597 ShowDiff(pFC, 0, save0, (next0 ? next0 : ptr0));
598 ShowDiff(pFC, 1, save1, (next1 ? next1 : ptr1));
600
601 // now resync'ed
602 }
603 } while (ret0 != FCRET_NO_MORE_DATA || ret1 != FCRET_NO_MORE_DATA);
604
605quit:
606 ret = Finalize(pFC, ptr0, ptr1, fDifferent);
607cleanup:
608 DeleteList(list0);
609 DeleteList(list1);
610 return ret;
611}
FCRET ResyncFailed(VOID)
Definition: fc.c:82
static VOID DeleteList(struct list *list)
Definition: text.h:58
static VOID SkipIdentical(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1)
Definition: text.h:363
static FCRET Finalize(FILECOMPARE *pFC, struct list *ptr0, struct list *ptr1, BOOL fDifferent)
Definition: text.h:515
static FCRET ParseLines(const FILECOMPARE *pFC, HANDLE *phMapping, LARGE_INTEGER *pib, const LARGE_INTEGER *pcb, struct list *list)
Definition: text.h:257
static FCRET Resync(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1)
Definition: text.h:443
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
static void list_init(struct list_entry *head)
Definition: list.h:51
static void cleanup(void)
Definition: main.c:1335
@ FCRET_INVALID
Definition: fc.h:25