ReactOS  0.4.15-dev-2700-g4b4ffa9
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 167 of file text.h.

◆ HASH_MASK

#define HASH_MASK   0x7FFFFFFF

Definition at line 168 of file text.h.

◆ IS_SPACE

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

Definition at line 9 of file text.h.

◆ NODE

#define NODE   NODE_A

Definition at line 16 of file text.h.

◆ PrintLine

#define PrintLine   PrintLineA

Definition at line 17 of file text.h.

◆ TAB_WIDTH

#define TAB_WIDTH   8

Definition at line 124 of file text.h.

◆ TextCompare

#define TextCompare   TextCompareA

Definition at line 18 of file text.h.

Function Documentation

◆ AllocEOFNode()

static NODE* AllocEOFNode ( DWORD  lineno)
static

Definition at line 182 of file text.h.

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

Referenced by ParseLines().

◆ AllocLine()

static LPTSTR AllocLine ( LPCTSTR  pch,
DWORD  cch 
)
static

Definition at line 21 of file text.h.

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

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

◆ AllocNode()

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

Definition at line 31 of file text.h.

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

Referenced by AllocEOFNode(), and ParseLines().

◆ CompareNode()

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

Definition at line 225 of file text.h.

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

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

◆ CompressSpace()

static LPTSTR CompressSpace ( LPCTSTR  line)
static

Definition at line 106 of file text.h.

107 {
108  LPTSTR pszNew;
109  LPCTSTR pchLast;
110 
111  line = SkipSpace(line);
112  pchLast = FindLastNonSpace(line);
113  if (pchLast == NULL)
114  return AllocLine(NULL, 0);
115 
116  pszNew = AllocLine(line, (DWORD)(pchLast - line) + 1);
117  if (!pszNew)
118  return NULL;
119 
120  DeleteDuplicateSpaces(pszNew);
121  return pszNew;
122 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
static VOID DeleteDuplicateSpaces(LPTSTR psz)
Definition: text.h:88
CHAR * LPTSTR
Definition: xmlstorage.h:192
static __inline LPCTSTR SkipSpace(LPCTSTR pch)
Definition: text.h:69
Definition: parser.c:48
static __inline LPCTSTR FindLastNonSpace(LPCTSTR pch)
Definition: text.h:76
static LPTSTR AllocLine(LPCTSTR pch, DWORD cch)
Definition: text.h:21
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112

Referenced by ConvertNode().

◆ ConvertNode()

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

Definition at line 203 of file text.h.

204 {
205  if (!(pFC->dwFlags & FLAG_T))
206  {
207  LPTSTR tmp = ExpandTab(node->pszLine);
208  if (!tmp)
209  return FALSE;
210  free(node->pszLine);
211  node->pszLine = tmp;
212  if (!(pFC->dwFlags & FLAG_W))
213  node->hash = GetHash(node->pszLine, !!(pFC->dwFlags & FLAG_C));
214  }
215  if (pFC->dwFlags & FLAG_W)
216  {
217  node->pszComp = CompressSpace(node->pszLine);
218  if (!node->pszComp)
219  return FALSE;
220  node->hash = GetHash(node->pszComp, !!(pFC->dwFlags & FLAG_C));
221  }
222  return TRUE;
223 }
#define TRUE
Definition: types.h:120
#define free
Definition: debug_ros.c:5
#define FLAG_T
Definition: fc.h:56
CHAR * LPTSTR
Definition: xmlstorage.h:192
DWORD dwFlags
Definition: fc.h:64
#define FALSE
Definition: types.h:117
static DWORD GetHash(LPCTSTR psz, BOOL bIgnoreCase)
Definition: text.h:170
static LPTSTR ExpandTab(LPCTSTR line)
Definition: text.h:140
#define FLAG_C
Definition: fc.h:51
Definition: dlist.c:348
static LPTSTR CompressSpace(LPCTSTR line)
Definition: text.h:106

Referenced by ParseLines().

◆ DeleteDuplicateSpaces()

static VOID DeleteDuplicateSpaces ( LPTSTR  psz)
static

Definition at line 88 of file text.h.

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

Referenced by CompressSpace().

◆ DeleteList()

static VOID DeleteList ( struct list list)
static

Definition at line 57 of file text.h.

58 {
59  struct list *ptr;
60  NODE *node;
61  while ((ptr = list_head(list)) != NULL)
62  {
66  }
67 }
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
struct node node
static PVOID ptr
Definition: dispmode.c:27
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
static __inline VOID DeleteNode(NODE *node)
Definition: text.h:47
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define NODE
Definition: text.h:16
#define NULL
Definition: types.h:112
#define LIST_ENTRY(type)
Definition: queue.h:175
Definition: dlist.c:348

Referenced by TextCompare().

◆ DeleteNode()

static __inline VOID DeleteNode ( NODE node)
static

Definition at line 47 of file text.h.

48 {
49  if (node)
50  {
51  free(node->pszLine);
52  free(node->pszComp);
53  free(node);
54  }
55 }
#define free
Definition: debug_ros.c:5
Definition: dlist.c:348

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

◆ ExpandTab()

static LPTSTR ExpandTab ( LPCTSTR  line)
static

Definition at line 140 of file text.h.

141 {
142  INT spaces, cch = ExpandTabLength(line), ich;
143  LPTSTR pszNew = malloc((cch + 1) * sizeof(TCHAR));
144  LPCTSTR pch;
145  if (!pszNew)
146  return NULL;
147  ich = 0;
148  for (pch = line; *pch; ++pch)
149  {
150  if (*pch == TEXT('\t'))
151  {
152  spaces = TAB_WIDTH - (ich % TAB_WIDTH);
153  while (spaces-- > 0)
154  {
155  pszNew[ich++] = TEXT(' ');
156  }
157  }
158  else
159  {
160  pszNew[ich++] = *pch;
161  }
162  }
163  pszNew[ich] = 0;
164  return pszNew;
165 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
int32_t INT
Definition: typedefs.h:58
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define pch(ap)
Definition: match.c:418
Definition: parser.c:48
char TCHAR
Definition: xmlstorage.h:189
static INT ExpandTabLength(LPCTSTR line)
Definition: text.h:126
#define TEXT(s)
Definition: k32.h:26
#define TAB_WIDTH
Definition: text.h:124
#define NULL
Definition: types.h:112
#define malloc
Definition: debug_ros.c:4
IN PCTCH IN DWORD cch
Definition: pager.h:34

Referenced by ConPagerWorker(), and ConvertNode().

◆ ExpandTabLength()

static INT ExpandTabLength ( LPCTSTR  line)
static

Definition at line 126 of file text.h.

127 {
128  LPCTSTR pch;
129  INT cch = 0;
130  for (pch = line; *pch; ++pch)
131  {
132  if (*pch == TEXT('\t'))
133  cch += TAB_WIDTH - (cch % TAB_WIDTH);
134  else
135  ++cch;
136  }
137  return cch;
138 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
int32_t INT
Definition: typedefs.h:58
#define pch(ap)
Definition: match.c:418
Definition: parser.c:48
#define TEXT(s)
Definition: k32.h:26
#define TAB_WIDTH
Definition: text.h:124
IN PCTCH IN DWORD cch
Definition: pager.h:34

Referenced by ExpandTab().

◆ Finalize()

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

Definition at line 514 of file text.h.

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

Referenced by CheckLogOrSourceExistence(), and TextCompare().

◆ FindLastNonSpace()

static __inline LPCTSTR FindLastNonSpace ( LPCTSTR  pch)
static

Definition at line 76 of file text.h.

77 {
78  LPCTSTR pchLast = NULL;
79  while (*pch)
80  {
81  if (!IS_SPACE(*pch))
82  pchLast = pch;
83  ++pch;
84  }
85  return pchLast;
86 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define pch(ap)
Definition: match.c:418
#define IS_SPACE(ch)
Definition: text.h:9
#define NULL
Definition: types.h:112

Referenced by CompressSpace().

◆ FindNextLine()

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

Definition at line 240 of file text.h.

241 {
242  while (ich < cch)
243  {
244  if (pch[ich] == TEXT('\n') || pch[ich] == TEXT('\0'))
245  {
246  *pich = ich;
247  return TRUE;
248  }
249  ++ich;
250  }
251  *pich = cch;
252  return FALSE;
253 }
#define TRUE
Definition: types.h:120
#define pch(ap)
Definition: match.c:418
#define FALSE
Definition: types.h:117
#define TEXT(s)
Definition: k32.h:26
IN PCTCH IN DWORD cch
Definition: pager.h:34

Referenced by ParseLines().

◆ GetHash()

static DWORD GetHash ( LPCTSTR  psz,
BOOL  bIgnoreCase 
)
static

Definition at line 170 of file text.h.

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

Referenced by ConvertNode().

◆ IsEOFNode()

static __inline BOOL IsEOFNode ( NODE node)
static

Definition at line 198 of file text.h.

199 {
200  return !node || node->hash == HASH_EOF;
201 }
#define HASH_EOF
Definition: text.h:167
Definition: dlist.c:348

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 256 of file text.h.

258 {
259  DWORD lineno = 1, ich, cch, ichNext, cbView, cchNode;
260  LPTSTR psz, pszLine;
261  BOOL fLast, bCR;
262  NODE *node;
263 
264  if (*phMapping == NULL)
265  return FCRET_NO_MORE_DATA;
266 
267  if (pib->QuadPart >= pcb->QuadPart)
268  {
269  CloseHandle(*phMapping);
270  *phMapping = NULL;
271  return FCRET_NO_MORE_DATA;
272  }
273 
274  cbView = (DWORD)min(pcb->QuadPart - pib->QuadPart, MAX_VIEW_SIZE);
275  psz = MapViewOfFile(*phMapping, FILE_MAP_READ, pib->HighPart, pib->LowPart, cbView);
276  if (!psz)
277  {
278  return OutOfMemory();
279  }
280 
281  ich = 0;
282  cch = cbView / sizeof(TCHAR);
283  fLast = (pib->QuadPart + cbView >= pcb->QuadPart);
284  while (ich < cch &&
285  (FindNextLine(psz, ich, cch, &ichNext) ||
286  (ichNext == cch && (fLast || ich == 0))))
287  {
288  bCR = (ichNext > 0) && (psz[ichNext - 1] == TEXT('\r'));
289  cchNode = ichNext - ich - bCR;
290  pszLine = AllocLine(&psz[ich], cchNode);
291  node = AllocNode(pszLine, lineno++);
292  if (!node || !ConvertNode(pFC, node))
293  {
294  DeleteNode(node);
295  UnmapViewOfFile(psz);
296  return OutOfMemory();
297  }
298  list_add_tail(list, &node->entry);
299  ich = ichNext + 1;
300  }
301 
302  UnmapViewOfFile(psz);
303 
304  pib->QuadPart += ichNext * sizeof(WCHAR);
305 
306  if (pib->QuadPart < pcb->QuadPart)
307  return FCRET_IDENTICAL;
308 
309  // append EOF node
310  node = AllocEOFNode(lineno);
311  if (!node)
312  return OutOfMemory();
313  list_add_tail(list, &node->entry);
314 
315  return FCRET_NO_MORE_DATA;
316 }
static BOOL ConvertNode(const FILECOMPARE *pFC, NODE *node)
Definition: text.h:203
#define CloseHandle
Definition: compat.h:598
#define MapViewOfFile
Definition: compat.h:604
static BOOL FindNextLine(LPCTSTR pch, DWORD ich, DWORD cch, LPDWORD pich)
Definition: text.h:240
#define DWORD
Definition: nt_native.h:44
CHAR * LPTSTR
Definition: xmlstorage.h:192
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
struct node node
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FILE_MAP_READ
Definition: compat.h:635
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
static LPTSTR AllocLine(LPCTSTR pch, DWORD cch)
Definition: text.h:21
unsigned long DWORD
Definition: ntddk_ex.h:95
static NODE * AllocEOFNode(DWORD lineno)
Definition: text.h:182
static __inline VOID DeleteNode(NODE *node)
Definition: text.h:47
ULONG LowPart
Definition: typedefs.h:106
Definition: _list.h:228
static NODE * AllocNode(LPTSTR psz, DWORD lineno)
Definition: text.h:31
#define TEXT(s)
Definition: k32.h:26
#define NODE
Definition: text.h:16
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
IN PCTCH IN DWORD cch
Definition: pager.h:34
#define UnmapViewOfFile
Definition: compat.h:605
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: dlist.c:348
#define MAX_VIEW_SIZE
Definition: fc.h:96

Referenced by TextCompare().

◆ Resync()

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

Definition at line 442 of file text.h.

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

Referenced by TextCompare().

◆ ScanDiff()

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

Definition at line 406 of file text.h.

408 {
409  struct list *ptr0 = *pptr0, *ptr1 = *pptr1, *tmp0, *tmp1;
410  NODE *node0, *node1;
411  INT count;
412  while (ptr0 && ptr1)
413  {
414  node0 = LIST_ENTRY(ptr0, NODE, entry);
415  node1 = LIST_ENTRY(ptr1, NODE, entry);
416  if (node0->lineno >= lineno0)
417  return FCRET_DIFFERENT;
418  if (node1->lineno >= lineno1)
419  return FCRET_DIFFERENT;
420  tmp0 = ptr0;
421  tmp1 = ptr1;
422  count = SkipIdenticalN(pFC, &tmp0, &tmp1, pFC->nnnn, lineno0, lineno1);
423  if (count >= pFC->nnnn)
424  break;
425  if (count > 0)
426  {
427  ptr0 = tmp0;
428  ptr1 = tmp1;
429  }
430  else
431  {
432  ptr0 = list_next(&pFC->list[0], ptr0);
433  ptr1 = list_next(&pFC->list[1], ptr1);
434  }
435  }
436  *pptr0 = ptr0;
437  *pptr1 = ptr1;
438  return FCRET_IDENTICAL;
439 }
INT nnnn
Definition: fc.h:66
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:58
static DWORD SkipIdenticalN(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1, DWORD nnnn, DWORD lineno0, DWORD lineno1)
Definition: text.h:379
struct list list[2]
Definition: fc.h:68
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
#define NODE
Definition: text.h:16
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by Resync().

◆ ShowDiff()

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

Definition at line 319 of file text.h.

320 {
321  NODE* node;
322  struct list *list = &pFC->list[i];
323  struct list *first = NULL, *last = NULL;
324  PrintCaption(pFC->file[i]);
325  if (begin && end && list_prev(list, begin))
327  while (begin != end)
328  {
330  if (IsEOFNode(node))
331  break;
332  if (!first)
333  first = begin;
334  last = begin;
335  if (!(pFC->dwFlags & FLAG_A))
336  PrintLine(pFC, node->lineno, node->pszLine);
338  }
339  if ((pFC->dwFlags & FLAG_A) && first)
340  {
342  PrintLine(pFC, node->lineno, node->pszLine);
344  if (first != last)
345  {
346  if (list_next(list, first) == last)
347  {
349  PrintLine(pFC, node->lineno, node->pszLine);
350  }
351  else
352  {
353  PrintDots();
354  }
355  }
357  PrintLine(pFC, node->lineno, node->pszLine);
358  }
359 }
POINT last
Definition: font.c:46
__WINE_SERVER_LIST_INLINE struct list * list_prev(const struct list *list, const struct list *elem)
Definition: list.h:123
const GLint * first
Definition: glext.h:5794
VOID PrintDots(VOID)
Definition: fc.c:98
LPCWSTR file[2]
Definition: fc.h:67
VOID PrintCaption(LPCWSTR file)
Definition: fc.c:88
struct node node
DWORD dwFlags
Definition: fc.h:64
#define FLAG_A
Definition: fc.h:49
static __inline BOOL IsEOFNode(NODE *node)
Definition: text.h:198
static clock_t begin
Definition: xmllint.c:466
struct list list[2]
Definition: fc.h:68
GLuint GLuint end
Definition: gl.h:1545
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
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
#define NODE
Definition: text.h:16
#define NULL
Definition: types.h:112
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define LIST_ENTRY(type)
Definition: queue.h:175
#define PrintLine
Definition: text.h:17
Definition: dlist.c:348

Referenced by Finalize(), and TextCompare().

◆ SkipIdentical()

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

Definition at line 362 of file text.h.

363 {
364  struct list *ptr0 = *pptr0, *ptr1 = *pptr1;
365  while (ptr0 && ptr1)
366  {
367  NODE *node0 = LIST_ENTRY(ptr0, NODE, entry);
368  NODE *node1 = LIST_ENTRY(ptr1, NODE, entry);
369  if (CompareNode(pFC, node0, node1) != FCRET_IDENTICAL)
370  break;
371  ptr0 = list_next(&pFC->list[0], ptr0);
372  ptr1 = list_next(&pFC->list[1], ptr1);
373  }
374  *pptr0 = ptr0;
375  *pptr1 = ptr1;
376 }
struct list list[2]
Definition: fc.h:68
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static FCRET CompareNode(const FILECOMPARE *pFC, const NODE *node0, const NODE *node1)
Definition: text.h:225
#define NODE
Definition: text.h:16
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define LIST_ENTRY(type)
Definition: queue.h:175

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 379 of file text.h.

381 {
382  struct list *ptr0 = *pptr0, *ptr1 = *pptr1;
383  DWORD count = 0;
384  while (ptr0 && ptr1)
385  {
386  NODE *node0 = LIST_ENTRY(ptr0, NODE, entry);
387  NODE *node1 = LIST_ENTRY(ptr1, NODE, entry);
388  if (node0->lineno >= lineno0)
389  break;
390  if (node1->lineno >= lineno1)
391  break;
392  if (CompareNode(pFC, node0, node1) != FCRET_IDENTICAL)
393  break;
394  ptr0 = list_next(&pFC->list[0], ptr0);
395  ptr1 = list_next(&pFC->list[1], ptr1);
396  ++count;
397  if (count >= nnnn)
398  break;
399  }
400  *pptr0 = ptr0;
401  *pptr1 = ptr1;
402  return count;
403 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
struct list list[2]
Definition: fc.h:68
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static FCRET CompareNode(const FILECOMPARE *pFC, const NODE *node0, const NODE *node1)
Definition: text.h:225
#define NODE
Definition: text.h:16
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by ScanDiff().

◆ SkipSpace()

static __inline LPCTSTR SkipSpace ( LPCTSTR  pch)
static

Definition at line 69 of file text.h.

70 {
71  while (IS_SPACE(*pch))
72  ++pch;
73  return pch;
74 }
#define pch(ap)
Definition: match.c:418
#define IS_SPACE(ch)
Definition: text.h:9

Referenced by CompressSpace().

◆ TextCompare()

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

Definition at line 532 of file text.h.

534 {
535  FCRET ret, ret0, ret1;
536  struct list *ptr0, *ptr1, *save0, *save1, *next0, *next1;
537  NODE* node0, * node1;
538  BOOL fDifferent = FALSE;
539  LARGE_INTEGER ib0 = { .QuadPart = 0 }, ib1 = { .QuadPart = 0 };
540  struct list *list0 = &pFC->list[0], *list1 = &pFC->list[1];
541  list_init(list0);
542  list_init(list1);
543 
544  do
545  {
546  ret0 = ParseLines(pFC, phMapping0, &ib0, pcb0, list0);
547  if (ret0 == FCRET_INVALID)
548  {
549  ret = ret0;
550  goto cleanup;
551  }
552  ret1 = ParseLines(pFC, phMapping1, &ib1, pcb1, list1);
553  if (ret1 == FCRET_INVALID)
554  {
555  ret = ret1;
556  goto cleanup;
557  }
558 
559  ptr0 = list_head(list0);
560  ptr1 = list_head(list1);
561  for (;;)
562  {
563  if (!ptr0 || !ptr1)
564  goto quit;
565 
566  // skip identical (sync'ed)
567  SkipIdentical(pFC, &ptr0, &ptr1);
568  if (ptr0 || ptr1)
569  fDifferent = TRUE;
570  node0 = LIST_ENTRY(ptr0, NODE, entry);
571  node1 = LIST_ENTRY(ptr1, NODE, entry);
572  if (IsEOFNode(node0) || IsEOFNode(node1))
573  goto quit;
574 
575  // try to resync
576  save0 = ptr0;
577  save1 = ptr1;
578  ret = Resync(pFC, &ptr0, &ptr1);
579  if (ret == FCRET_INVALID)
580  goto cleanup;
581  if (ret == FCRET_DIFFERENT)
582  {
583  // resync failed
584  ret = ResyncFailed();
585  // show the difference
586  ShowDiff(pFC, 0, save0, ptr0);
587  ShowDiff(pFC, 1, save1, ptr1);
588  PrintEndOfDiff();
589  goto cleanup;
590  }
591 
592  // show the difference
593  fDifferent = TRUE;
594  next0 = ptr0 ? list_next(list0, ptr0) : ptr0;
595  next1 = ptr1 ? list_next(list1, ptr1) : ptr1;
596  ShowDiff(pFC, 0, save0, (next0 ? next0 : ptr0));
597  ShowDiff(pFC, 1, save1, (next1 ? next1 : ptr1));
598  PrintEndOfDiff();
599 
600  // now resync'ed
601  }
602  } while (ret0 != FCRET_NO_MORE_DATA || ret1 != FCRET_NO_MORE_DATA);
603 
604 quit:
605  ret = Finalize(pFC, ptr0, ptr1, fDifferent);
606 cleanup:
607  DeleteList(list0);
608  DeleteList(list1);
609  return ret;
610 }
#define TRUE
Definition: types.h:120
void quit(int argc, const char *argv[])
Definition: cmds.c:1606
static VOID DeleteList(struct list *list)
Definition: text.h:57
FCRET
Definition: fc.h:23
VOID PrintEndOfDiff(VOID)
Definition: fc.c:93
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static __inline BOOL IsEOFNode(NODE *node)
Definition: text.h:198
static FCRET Finalize(FILECOMPARE *pFC, struct list *ptr0, struct list *ptr1, BOOL fDifferent)
Definition: text.h:514
static FCRET ParseLines(const FILECOMPARE *pFC, HANDLE *phMapping, LARGE_INTEGER *pib, const LARGE_INTEGER *pcb, struct list *list)
Definition: text.h:256
struct list list[2]
Definition: fc.h:68
FCRET ResyncFailed(VOID)
Definition: fc.c:82
int ret
static VOID ShowDiff(FILECOMPARE *pFC, INT i, struct list *begin, struct list *end)
Definition: text.h:319
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static FCRET Resync(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1)
Definition: text.h:442
#define NODE
Definition: text.h:16
__WINE_SERVER_LIST_INLINE struct list * list_next(const struct list *list, const struct list *elem)
Definition: list.h:115
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
char * cleanup(char *str)
Definition: wpickclick.c:99
#define LIST_ENTRY(type)
Definition: queue.h:175
static VOID SkipIdentical(FILECOMPARE *pFC, struct list **pptr0, struct list **pptr1)
Definition: text.h:362
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by get_str_hash(), and test_hash_value().