From: Eric S. Raymond Date: Fri, 29 Sep 2006 10:01:27 +0000 (+0000) Subject: Unbreak the identifier regexp. X-Git-Tag: 1.0~54 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=1a9070c31d57944a20b734fcc46eae09890199c4;p=ctopy.git Unbreak the identifier regexp. --- diff --git a/ctopy b/ctopy index 98db347..9f8f491 100755 --- a/ctopy +++ b/ctopy @@ -27,7 +27,7 @@ Limitations: import sys, re shorthands = { - 'id' : r"[a-zA-Z][a-zA-Z0-9._]+", + 'id' : r"[a-zA-Z][a-zA-Z0-9._]*", 'exp' : r"[a-zA-Z0-9._\-+\*/]+", 'type' : r"void|int|bool|char \*|char|short|double|long|float|time_t|FILE \*", } @@ -55,13 +55,13 @@ unsafe_transformations = ( (r"while *\(", r"while "), (r"while 1:", r"while True"), (r"for \(;;\)\s*{", r"while True"), - (r"for \((%(id)s) *= *0; *\1 *< *(%(id)s); *\1\+\+\)", + (r"for \((%(id)s) *= *0; *\1 *< *([^;]+); *\1\+\+\)", r"for \1 in range(\2))"), - (r"for \((%(id)s) *= *0; *\1 *<= *(%(id)s); *\1\+\+\)", + (r"for \((%(id)s) *= *0; *\1 *<= *([^;]+); *\1\+\+\)", r"for \1 in range(\2+1))"), - (r"for \((%(id)s) *= *(\d+); *\1 *< *(%(id)s); *\1\+\+\)", + (r"for \((%(id)s) *= *(\d+); *\1 *< *([^;]+); *\1\+\+\)", r"for \1 in range(\2, \3))"), - (r"for \((%(id)s) *= *(\d+); *\1 *<= *(%(id)s); *\1\+\+\)", + (r"for \((%(id)s) *= *(\d+); *\1 *<= *([^;]+); *\1\+\+\)", r"for \1 in range(\2, \3+1))"), (r"\)\s*{", r":"), (r"(?