File: programming/cocoa/UKDiffView.zip/UKDiffView/AngelDiff/UKDiffParser.m


//
//  UKDiffParser.m
//  AngelDiff
//
//  Created by Uli Kusterer on 02.08.08.
//  Copyright 2008 The Void Software. All rights reserved.
//
 
#import "UKDiffParser.h"
#import "UKHelperMacros.h"
'\n' || currCh == '\r' )	// Empty line? Skip.
// Get info about operation:
"%C"'\n' || currCh == '\r'','','// If it's a source line, ignore it for now:
'<''\n' && currCh != '\r''-' && currPos < endPos )	// Skip separator line.
'\n' && currCh != '\r''>'' ' )	// There's a greater-than and a space, usually.
"%C"'\n' && currCh != '\r'"NEW ITERATION"'-' || currCh == '+''\n' && currCh != '\r'"\tSkipping file marker line"'\n' || currCh == '\r'  )	// Empty line? Skip.
"\tSkipping empty line"// @@
'@'"NO @@ Marker found"'@'"NO @@ Marker found""\t@@ Markers found"' ' || currCh == '\t'// -nnn,nn
'-'"NO - found""%C""\tleftRange.location = %ld"','"%C""\tleftRange.length = %ld"' ' || currCh == '\t'// +nnn,nn
'+'"\tNO + found""%C""\trightRange.location = %ld"','"%C""\trightRange.length = %ld"' ' || currCh == '\t''@'"NO ending @@"'@'"NO ending @@"'\n' || currCh == '\r'"355"' ' || currCh == '-' || currCh == '+') && currPos < (endPos-1) )
			{
				leftRange.length = rightRange.length = 0;
				
				// Now skip those useless context lines:
' ''\n' && currCh != '\r''\n' || currCh == '\r'"Skipping context line");
				}
				
				// Obtain original lines:
'-''\n' && currCh != '\r'"%C"'\n' || currCh == '\r'"%C""Found - line");
				}
				
				// Obtain new lines:
'+''\n' && currCh != '\r'"%C"'\n' || currCh == '\r'"%C""Found + line""%@"// Skip remaining context lines:
' ' || currCh == '\\''\n' && currCh != '\r''\n' || currCh == '\r'"Skipped trailing context line""parsed""%C"'\n' || currCh == '\r'// Ignore those, we do that ourselves.
// Drop any leftover unchanged entries from a previous run.
// Generate an entry for any unchanged text between this difference and the previous one:
// Now create an entry for the current change:
// Add object is already done, doesn't need an 'oldText'.
// Change or delete:
		{
			// Capture old text and add it to this diff item:
// Append any remaining unchanged text at end of diffs:
// Replace old differences array with new one containing both texts:
// Must have called applyOriginalText: once before using this.
// Must have called applyOriginalText: once before using this.
// Must have called applyOriginalText: once before using this.
"%@ { operation = %c originalRange = { %ld, %ld }, destinationRange = { %ld, %ld }, apply = %s }""YES":"NO"

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.