import sys
+# Keep if "k"
+# Otherwise delete.
+global keepcomments
+keepcomments = "k"
+
def isIdStart(c):
if isIndivid(c) == "y":
return "n"
"""
dwclass = "none"
combotok = dwtoken()
+ charnum= -1
+ global keepcomments
for c in rec:
+ charnum = charnum +1
+ if keepcomments == "d" and c == "%" and ( charnum == 0 or rec[charnum - 1] != "\\" ):
+ # Not keeping comments. We drop % and following to end of line
+ # unless preceeded by \
+ break
+
if c == "\n" or c == "\r":
# Just drop these for now. Allowing them
# would not be harmful.
f.dwtransformline(callfunc,f)
+def setkeepordeletecomments(val):
+ """ Pass in "k" or "d" to keep or delete comments, respectively """
+ global keepcomments
+ keepcomments = val
+
def readFilelist(filelist):
dwf = dwfiles()
for f in filelist:
return outtoks,numabsorbed
elif c == "*":
outlist = []
+ curtok = linetoks[curnum]
while isbrace(curtok,"}") == "n":
- curtok = linetoks[curnum]
if dwspace(curtok) == "n":
outlist += [curtok]
curnum = curnum + 1
print "ERROR insufficient tokens on line for pattern ", pattern," line " ,linenum," file ",myfile._name
return outtoks,numabsorbed
numabsorbed = numabsorbed + 1
+ curtok = linetoks[curnum]
# Found a right brace, so done here.
outtoks += [outlist]
else:
def transfunc(linetoks,myfile,linenum):
if len(linetoks) < 1:
return linetoks
+ initialtok = linetoks[0]
+ if ''.join(initialtok._tex) == "\\newcommand":
+ # We ignore newcommand lines, they are not stuff
+ # we want to look at, they are new macros, not macro uses.
+ # We don't want to transform or touch them, nor report on them.
+ return linetoks
tnumin = 0
lasttoknum = len(linetoks)
while tnumin < lasttoknum:
def read_all_args():
filelist = []
+ fileio.setkeepordeletecomments("d")
cur = 1
while len(sys.argv) > cur:
v = sys.argv[cur]