[llvm] [llvm-lit] Adding -e option to lit's built-in cat command (PR #102061)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 15:46:32 PDT 2024
================
@@ -1,29 +1,45 @@
import getopt
import sys
+from dataclasses import dataclass, fields
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
-def convertToCaretAndMNotation(data):
+ at dataclass
+class Options:
+ show_ends: bool
+ show_nonprinting: bool
+
+
+def convertTextNotation(data, options):
newdata = StringIO()
if isinstance(data, str):
data = bytearray(data.encode())
+
for intval in data:
- if intval == 9 or intval == 10:
- newdata.write(chr(intval))
- continue
- if intval > 127:
- intval = intval - 128
- newdata.write("M-")
- if intval < 32:
- newdata.write("^")
- newdata.write(chr(intval + 64))
- elif intval == 127:
- newdata.write("^?")
+ if options.show_ends:
+ if intval == 10:
----------------
ilovepi wrote:
nit: you can combine these and drop a level of nesting. Could also be `if/else if/else` but that isn't too important since there's a continue.
https://github.com/llvm/llvm-project/pull/102061
More information about the llvm-commits
mailing list