[PATCH] D16548: Ignore LC_CTYPE in sed invocation on Darwin

Elias Pipping via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 12:03:31 PST 2016


pipping.elias created this revision.
pipping.elias added a reviewer: hans.
pipping.elias added a subscriber: llvm-commits.

Here, `sed` to prepare object files for comparison via `cmp`. On my Darwin 15.4.0 machine, LC_CTYPE is set to UTF-8 (by default, I believe). Under these circumstances, anything `sed` is made to read will be treated as UTF-8, prompting it to signal an error if it is not, like so:

% sed s/a/b/ <(head -n1 /dev/random) >/dev/null; echo $?           
sed: RE error: illegal byte sequence
1
% 

To make sed work as expected, I need to set LC_CTYPE to C:

% env LC_CTYPE=C sed s/a/b/ <(head -n1 /dev/random) >/dev/null; echo $?
0
%

Without this change, sed will exit with an error for every single file that it compares between phase 2 and phase 3, thereby making it look as if the differences were far larger than they are.

http://reviews.llvm.org/D16548

Files:
  test-release.sh

Index: test-release.sh
===================================================================
--- test-release.sh
+++ test-release.sh
@@ -541,7 +541,7 @@
             # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
             # case there are build paths in the debug info. On some systems,
             # sed adds a newline to the output, so pass $p3 through sed too.
-            if ! cmp -s <(sed -e 's,Phase2,Phase3,g' $p2) <(sed -e '' $p3) \
+            if ! cmp -s <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) <(env LC_CTYPE=C sed -e '' $p3) \
                     16 16 ; then
                 echo "file `basename $p2` differs between phase 2 and phase 3"
             fi


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16548.45897.patch
Type: text/x-patch
Size: 701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160125/fbf2cf4c/attachment.bin>


More information about the llvm-commits mailing list