common/bin/difftext.sh

Tue, 18 Sep 2012 11:29:16 -0700

author
ohair
date
Tue, 18 Sep 2012 11:29:16 -0700
changeset 478
2ba6f4da4bf3
parent 425
e1830598f0b7
permissions
-rw-r--r--

7197849: Update new build-infra makefiles
Reviewed-by: ihse, erikj, ohrstrom, tbell

ohair@425 1 #!/bin/bash
ohair@425 2 #
ohair@425 3 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
ohair@425 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ohair@425 5 #
ohair@425 6 # This code is free software; you can redistribute it and/or modify it
ohair@425 7 # under the terms of the GNU General Public License version 2 only, as
ohair@425 8 # published by the Free Software Foundation.
ohair@425 9 #
ohair@425 10 # This code is distributed in the hope that it will be useful, but WITHOUT
ohair@425 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ohair@425 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ohair@425 13 # version 2 for more details (a copy is included in the LICENSE file that
ohair@425 14 # accompanied this code).
ohair@425 15 #
ohair@425 16 # You should have received a copy of the GNU General Public License version
ohair@425 17 # 2 along with this work; if not, write to the Free Software Foundation,
ohair@425 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ohair@425 19 #
ohair@425 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@425 21 # or visit www.oracle.com if you need additional information or have any
ohair@425 22 # questions.
ohair@425 23 #
ohair@425 24
ohair@425 25 # The difftext.sh knows how to compare text files and
ohair@425 26 # ignore some specific differences.
ohair@425 27 # When difftext.sh is called, we already know that the
ohair@425 28 # files differ. But if the tests below trigger, then
ohair@425 29 # we ignore differences caused by:
ohair@425 30 #
ohair@425 31 # Timestamps in Java sources generated by idl2java
ohair@425 32 # Sorting order and cleanup style in .properties files.
ohair@425 33
ohair@425 34 OLD="$1"
ohair@425 35 NEW="$2"
ohair@425 36 SUF="${OLD##*.}"
ohair@425 37 TMP=1
ohair@425 38 if test "x$SUF" == "xjava"; then
ohair@425 39 TMP=$(LANG=C diff $OLD $NEW | \
ohair@425 40 grep '^[<>]' | \
ohair@425 41 sed '/[<>] \* from.*\.idl/d' | \
ohair@425 42 sed '/[<>] \*.*201[12].*/d' | \
ohair@425 43 sed '/\/\/ Generated from input file.*/d' | \
ohair@425 44 sed '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' | \
ohair@425 45 sed '/\/\/ java GenerateCharacter.*/d')
ohair@425 46 fi
ohair@425 47 if test "x$SUF" == "xproperties"; then
ohair@425 48 cat $OLD | sed -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
ohair@425 49 -e 's/\\u0020/\x20/g' \
ohair@425 50 -e 's/\\u003A/\x3A/g' \
ohair@425 51 -e 's/\\u006B/\x6B/g' \
ohair@425 52 -e 's/\\u0075/\x75/g' \
ohair@425 53 -e 's/\\u00A0/\xA0/g' \
ohair@425 54 -e 's/\\u00A3/\xA3/g' \
ohair@425 55 -e 's/\\u00B0/\xB0/g' \
ohair@425 56 -e 's/\\u00B7/\xB7/g' \
ohair@425 57 -e 's/\\u00BA/\xBA/g' \
ohair@425 58 -e 's/\\u00BF/\xBF/g' \
ohair@425 59 -e 's/\\u00C0/\xC0/g' \
ohair@425 60 -e 's/\\u00C1/\xC1/g' \
ohair@425 61 -e 's/\\u00C2/\xC2/g' \
ohair@425 62 -e 's/\\u00C4/\xC4/g' \
ohair@425 63 -e 's/\\u00C5/\xC5/g' \
ohair@425 64 -e 's/\\u00C8/\xC8/g' \
ohair@425 65 -e 's/\\u00C9/\xC9/g' \
ohair@425 66 -e 's/\\u00CA/\xCA/g' \
ohair@425 67 -e 's/\\u00CD/\xCD/g' \
ohair@425 68 -e 's/\\u00CE/\xCE/g' \
ohair@425 69 -e 's/\\u00D3/\xD3/g' \
ohair@425 70 -e 's/\\u00D4/\xD4/g' \
ohair@425 71 -e 's/\\u00D6/\xD6/g' \
ohair@425 72 -e 's/\\u00DA/\xDA/g' \
ohair@425 73 -e 's/\\u00DC/\xDC/g' \
ohair@425 74 -e 's/\\u00DD/\xDD/g' \
ohair@425 75 -e 's/\\u00DF/\xDF/g' \
ohair@425 76 -e 's/\\u00E0/\xE0/g' \
ohair@425 77 -e 's/\\u00E1/\xE1/g' \
ohair@425 78 -e 's/\\u00E2/\xE2/g' \
ohair@425 79 -e 's/\\u00E3/\xE3/g' \
ohair@425 80 -e 's/\\u00E4/\xE4/g' \
ohair@425 81 -e 's/\\u00E5/\xE5/g' \
ohair@425 82 -e 's/\\u00E6/\xE6/g' \
ohair@425 83 -e 's/\\u00E7/\xE7/g' \
ohair@425 84 -e 's/\\u00E8/\xE8/g' \
ohair@425 85 -e 's/\\u00E9/\xE9/g' \
ohair@425 86 -e 's/\\u00EA/\xEA/g' \
ohair@425 87 -e 's/\\u00EB/\xEB/g' \
ohair@425 88 -e 's/\\u00EC/\xEC/g' \
ohair@425 89 -e 's/\\u00ED/\xED/g' \
ohair@425 90 -e 's/\\u00EE/\xEE/g' \
ohair@425 91 -e 's/\\u00EF/\xEF/g' \
ohair@425 92 -e 's/\\u00F1/\xF1/g' \
ohair@425 93 -e 's/\\u00F2/\xF2/g' \
ohair@425 94 -e 's/\\u00F3/\xF3/g' \
ohair@425 95 -e 's/\\u00F4/\xF4/g' \
ohair@425 96 -e 's/\\u00F5/\xF5/g' \
ohair@425 97 -e 's/\\u00F6/\xF6/g' \
ohair@425 98 -e 's/\\u00F9/\xF9/g' \
ohair@425 99 -e 's/\\u00FA/\xFA/g' \
ohair@425 100 -e 's/\\u00FC/\xFC/g' \
ohair@425 101 -e 's/\\u0020/\x20/g' \
ohair@425 102 -e 's/\\u003f/\x3f/g' \
ohair@425 103 -e 's/\\u006f/\x6f/g' \
ohair@425 104 -e 's/\\u0075/\x75/g' \
ohair@425 105 -e 's/\\u00a0/\xa0/g' \
ohair@425 106 -e 's/\\u00a3/\xa3/g' \
ohair@425 107 -e 's/\\u00b0/\xb0/g' \
ohair@425 108 -e 's/\\u00ba/\xba/g' \
ohair@425 109 -e 's/\\u00bf/\xbf/g' \
ohair@425 110 -e 's/\\u00c1/\xc1/g' \
ohair@425 111 -e 's/\\u00c4/\xc4/g' \
ohair@425 112 -e 's/\\u00c5/\xc5/g' \
ohair@425 113 -e 's/\\u00c8/\xc8/g' \
ohair@425 114 -e 's/\\u00c9/\xc9/g' \
ohair@425 115 -e 's/\\u00ca/\xca/g' \
ohair@425 116 -e 's/\\u00cd/\xcd/g' \
ohair@425 117 -e 's/\\u00d6/\xd6/g' \
ohair@425 118 -e 's/\\u00dc/\xdc/g' \
ohair@425 119 -e 's/\\u00dd/\xdd/g' \
ohair@425 120 -e 's/\\u00df/\xdf/g' \
ohair@425 121 -e 's/\\u00e0/\xe0/g' \
ohair@425 122 -e 's/\\u00e1/\xe1/g' \
ohair@425 123 -e 's/\\u00e2/\xe2/g' \
ohair@425 124 -e 's/\\u00e3/\xe3/g' \
ohair@425 125 -e 's/\\u00e4/\xe4/g' \
ohair@425 126 -e 's/\\u00e5/\xe5/g' \
ohair@425 127 -e 's/\\u00e7/\xe7/g' \
ohair@425 128 -e 's/\\u00e8/\xe8/g' \
ohair@425 129 -e 's/\\u00e9/\xe9/g' \
ohair@425 130 -e 's/\\u00ea/\xea/g' \
ohair@425 131 -e 's/\\u00eb/\xeb/g' \
ohair@425 132 -e 's/\\u00ec/\xec/g' \
ohair@425 133 -e 's/\\u00ed/\xed/g' \
ohair@425 134 -e 's/\\u00ee/\xee/g' \
ohair@425 135 -e 's/\\u00ef/\xef/g' \
ohair@425 136 -e 's/\\u00f0/\xf0/g' \
ohair@425 137 -e 's/\\u00f1/\xf1/g' \
ohair@425 138 -e 's/\\u00f2/\xf2/g' \
ohair@425 139 -e 's/\\u00f3/\xf3/g' \
ohair@425 140 -e 's/\\u00f4/\xf4/g' \
ohair@425 141 -e 's/\\u00f5/\xf5/g' \
ohair@425 142 -e 's/\\u00f6/\xf6/g' \
ohair@425 143 -e 's/\\u00f7/\xf7/g' \
ohair@425 144 -e 's/\\u00f8/\xf8/g' \
ohair@425 145 -e 's/\\u00f9/\xf9/g' \
ohair@425 146 -e 's/\\u00fa/\xfa/g' \
ohair@425 147 -e 's/\\u00fc/\xfc/g' \
ohair@425 148 -e 's/\\u00ff/\xff/g' \
ohair@425 149 | sed -e '/^#/d' -e '/^$/d' \
ohair@425 150 -e :a -e '/\\$/N; s/\\\n//; ta' \
ohair@425 151 -e 's/^[ \t]*//;s/[ \t]*$//' \
ohair@425 152 -e 's/\\=/=/' | LANG=C sort > $OLD.cleaned
ohair@425 153 TMP=$(LANG=C diff $OLD.cleaned $NEW)
ohair@425 154 fi
ohair@425 155 if test -n "$TMP"; then
ohair@425 156 echo Files $OLD and $NEW differ
ohair@425 157 fi

mercurial