summaryrefslogtreecommitdiff
path: root/devtools/bin/splitdiff3.pl
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /devtools/bin/splitdiff3.pl
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'devtools/bin/splitdiff3.pl')
-rw-r--r--devtools/bin/splitdiff3.pl54
1 files changed, 54 insertions, 0 deletions
diff --git a/devtools/bin/splitdiff3.pl b/devtools/bin/splitdiff3.pl
new file mode 100644
index 0000000..ccba3a9
--- /dev/null
+++ b/devtools/bin/splitdiff3.pl
@@ -0,0 +1,54 @@
+$infilename = shift;
+$outfilename1 = shift;
+$outfilename2 = shift;
+open INPUT, $infilename || die;
+@input = <INPUT>;
+close INPUT;
+
+open MERGEDMINE, ">$outfilename1" || die;
+open MERGEDTHEIRS, ">$outfilename2" || die;
+
+for( $i = 0; $i < scalar( @input ); $i++ )
+{
+ $line = $input[$i];
+
+ if( $line =~ m/^(.*)<<<<<<</ )
+ {
+ $first = 1;
+ $second = 0;
+ print MERGEDMINE $1;
+ print MERGEDTHEIRS $1;
+ next;
+ }
+ # Make sure that we are in a split block so that comments with ======= don't mess us up.
+ if( $line =~ m/^(.*)=======$/ && $first == 1 )
+ {
+ $first = 0;
+ $second = 1;
+ print MERGEDMINE $1;
+ next;
+ }
+ if( $line =~ m/^(.*)>>>>>>>/ )
+ {
+ $first = $second = 0;
+ print MERGEDTHEIRS $1;
+ next;
+ }
+
+ if( $first )
+ {
+ print MERGEDMINE $line;
+ }
+ elsif( $second )
+ {
+ print MERGEDTHEIRS $line;
+ }
+ else
+ {
+ print MERGEDMINE $line;
+ print MERGEDTHEIRS $line;
+ }
+}
+
+close MERGEDMINE;
+close MERGEDTHEIRS;