From: Eric S. Raymond Date: Tue, 24 Feb 2004 10:40:19 +0000 (+0000) Subject: Handle printer control codes in multi-line strings. X-Git-Tag: 1.0~49 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=51448a333a8a1c96f2b24511832eee969514888e;p=mad.git Handle printer control codes in multi-line strings. --- diff --git a/mad b/mad index 8b54b14..c577471 100755 --- a/mad +++ b/mad @@ -899,23 +899,19 @@ def deduce_types(str): return types def lptcodes(res): - "Interpret line-printer control character at start of format string." - if res[0] == ' ': # Single space - res = res[1:] - elif res[0] == '0': # Double space - res = r"\n" + res[1:] - elif res[0] == '+': # No space - res = res[1:] - elif res[0] == '1': # Skip to next page - res = r"\f" + res[1:] - elif res[0] == '2': # Skip to next half page - res = r"\v\v" + res[1:] - elif res[0] == '4': # Skip to next quarter page - res = r"\v" + res[1:] - else: # Anything else falls through - nonfatal('unknown print code %s ignored\n' % res[0]) - res = res[1:] - res = res + '\\n' + "Interpret line-printer control characters in (translated) format strings." + # The Jordan-method example in the MAD manual shows that a printer control + # code is required after each /. + res = r"\n" + res + res = res.replace(r'\n ', r'\n') # Single space + res = res.replace(r'\n0', r'\n\n') # Double space + res = res.replace(r'\n+', r'') # No space + res = res.replace(r'\n1', r'\n\f') # Skip to next page + res = res.replace(r'\n2', r'\v\v') # Skip to next half page + res = res.replace(r'\n4', r'\n') # Skip to next quarter page + re = res[:-1] + # This is not, strictly speaking, correct + res = res + r'\n' return res def print_C_statement(statement):