lanza created this revision.
lanza requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is just a few trivial changes -- change the interpreter and fix a
few byte-vs-string issues.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107944

Files:
  clang/utils/hmaptool/hmaptool


Index: clang/utils/hmaptool/hmaptool
===================================================================
--- clang/utils/hmaptool/hmaptool
+++ clang/utils/hmaptool/hmaptool
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from __future__ import absolute_import, division, print_function
 
 import json
@@ -9,8 +9,8 @@
 
 ###
 
-k_header_magic_LE = 'pamh'
-k_header_magic_BE = 'hmap'
+k_header_magic_LE = b'pamh'
+k_header_magic_BE = b'hmap'
 
 def hmap_hash(str):
     """hash(str) -> int
@@ -83,7 +83,7 @@
             if len(strtable) != strtable_size:
                 raise SystemExit("error: %s: unable to read complete string 
table"%(
                         path,))
-            if strtable[-1] != '\0':
+            if strtable[-1] != 0:
                 raise SystemExit("error: %s: invalid string table in 
headermap" % (
                         path,))
 
@@ -98,7 +98,7 @@
         if idx >= len(self.strtable):
             raise SystemExit("error: %s: invalid string index" % (
                     path,))
-        end_idx = self.strtable.index('\0', idx)
+        end_idx = self.strtable.index(0, idx)
         return self.strtable[idx:end_idx]
 
     @property


Index: clang/utils/hmaptool/hmaptool
===================================================================
--- clang/utils/hmaptool/hmaptool
+++ clang/utils/hmaptool/hmaptool
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from __future__ import absolute_import, division, print_function
 
 import json
@@ -9,8 +9,8 @@
 
 ###
 
-k_header_magic_LE = 'pamh'
-k_header_magic_BE = 'hmap'
+k_header_magic_LE = b'pamh'
+k_header_magic_BE = b'hmap'
 
 def hmap_hash(str):
     """hash(str) -> int
@@ -83,7 +83,7 @@
             if len(strtable) != strtable_size:
                 raise SystemExit("error: %s: unable to read complete string table"%(
                         path,))
-            if strtable[-1] != '\0':
+            if strtable[-1] != 0:
                 raise SystemExit("error: %s: invalid string table in headermap" % (
                         path,))
 
@@ -98,7 +98,7 @@
         if idx >= len(self.strtable):
             raise SystemExit("error: %s: invalid string index" % (
                     path,))
-        end_idx = self.strtable.index('\0', idx)
+        end_idx = self.strtable.index(0, idx)
         return self.strtable[idx:end_idx]
 
     @property
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to