Mercurial > hg > Members > shinya > pyrect
changeset 77:c50511498bcf
improve filter.
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Nov 2010 05:07:08 +0900 |
parents | dd6d2b9e48ad |
children | 240475723cd8 |
files | pyrect/translator/grep_translator.py |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/translator/grep_translator.py Mon Nov 08 04:47:34 2010 +0900 +++ b/pyrect/translator/grep_translator.py Mon Nov 08 05:07:08 2010 +0900 @@ -93,8 +93,8 @@ if self.filter_only: self.emit("accept(%s);" % self.args) elif self.filter_prefix: - self.emit("buf -= %d;" % l) - self.emit("%s(%s);" % (self.state_name(self.cg.start) ,self.args)) + self.emit("buf++;") + self.emit("%s(%s);" % (self.state_name(self.cg.start), self.args)) else: self.emit("beg = get_line_beg(buf, beg);") self.emit("buf = beg;") @@ -111,7 +111,7 @@ self.emitd("}", 2) return - self.emit('static UCHAR key[] = "%s";' % key) + self.emit('static const UCHAR key[] = "%s";' % key) skip = dict() for i in range(l-1): @@ -120,8 +120,8 @@ self.emit("UCHARP tmp1, *tmp2;", 2) self.emit("buf += %d;" % (l-1)) self.emiti("while (buf < end) {") - self.emiti( "if (*buf == %d /*%c*/) {" % (ord(key[-1]), key[-1])) - self.emit( "tmp1 = buf, tmp2 = key+%d;" % (l-1)) + self.emiti( "if (*buf == %d /* %s */) {" % (ord(key[-1]), Character.ascii(key[-1]))) + self.emit( "tmp1 = buf, tmp2 = (UCHARP)key+%d;" % (l-1)) self.emiti( "while (*(--tmp1) == *(--tmp2)) {") self.emit( "if (tmp2 == key) goto next;") self.emitd( "}") @@ -162,7 +162,7 @@ self.emitd("}", 2) return - self.emit('static UCHAR key[] = "%s";' % key) + self.emit('static const UCHAR key[] = "%s";' % key) skip = dict() for i in range(l): @@ -170,8 +170,8 @@ self.emit("UCHARP tmp1, *tmp2, *end_ = end - %d;" % (l-1), 2) self.emiti("while (buf < end_) {") - self.emiti( "if (*buf == %d) {" % ord(key[0])) - self.emit( "tmp1 = buf, tmp2 = key;") + self.emiti( "if (*buf == %d /* %s */) {" % ord(key[0], Character.ascii(key[0]))) + self.emit( "tmp1 = buf, tmp2 = (UCHARP)key;") self.emiti( "while (*(++tmp1) == *(++tmp2)){") self.emit( "if (tmp2 == key+%d) goto next;" % (l-1)) self.emitd( "}")