#!/usr/bin/env python# Copyright (C) 2012 Christian Heimes (christian@python.org)# Licensed to PSF under a Contributor Agreement.## cleanup Keccak sourcesimport osimport reCPP1 = re.compile("^//(.*)")CPP2 = re.compile(r"\ //(.*)")STATICS = ("void ", "int ", "HashReturn ","const UINT64 ", "UINT16 ", " int prefix##")HERE = os.path.dirname(os.path.abspath(__file__))KECCAK = os.path.join(HERE, "kcp")def getfiles():for name in os.listdir(KECCAK):name = os.path.join(KECCAK, name)if os.path.isfile(name):yield namedef cleanup(f):buf = []for line in f:# mark all functions and global data as static#if line.startswith(STATICS):# buf.append("static " + line)# continue# remove UINT64 typedef, we have our ownif line.startswith("typedef unsigned long long int"):buf.append("/* %s */\n" % line.strip())continue## remove #include "brg_endian.h"if "brg_endian.h" in line:buf.append("/* %s */\n" % line.strip())continue# transform C++ comments into ANSI C commentsline = CPP1.sub(r"/*1円 */\n", line)line = CPP2.sub(r" /*1円 */\n", line)buf.append(line)return "".join(buf)for name in getfiles():with open(name) as f:res = cleanup(f)with open(name, "w") as f:f.write(res)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。