我怎样才能修改文件夹中的所有文件的代码 [英] How can I modify code of all files in folders
问题描述
$ b $ $ $ $ $ $ $ $ $ $ strcpy(out,in)是sprintf(out,%d ,in)
和
strcat(out,in)将是sprintf(out,out%d,in)
我可以使用什么工具来快速进行所有替换,我无法手动完成这些修改。这些修改有9000多个。
感谢您的建议。
我使用的是Windows XP / Linux Ubuntu
我之所以这样做是因为我们计划实现翻译代码的方法。而且因为我们正在使用strcat和所有的东西,所以我们不能使情景翻译工作得很好。因为所有将要被写入的文件都以正确的顺序排列所有的东西。
,更准确地说,预处理器。具体来说,我会找到一个项目范围的标题,并在其中添加几行:
#define strcpy(out,in)sprintf(out,%s,in)
#define strcat out + strlen(out),%s,in)
的源代码。然后,当你感觉到时,很容易变回明智,并使用 strcpy
/ strcat
他们应该在哪里。
I need to make some recurrent modification in a lot of files (C++). I need to replace all strcpy() and strcat() by sprintf(). I figured out that the conversion would be made like this :
strcpy(out,in) would be sprintf(out,%d,in)
and
strcat(out,in) would be sprintf(out,out%d,in)
What tool could I use to rapidly make all replacement, I can't do it manually there is over 9000 of these to modify.
Thanks for your suggestions.
I'm using windows xp/linux Ubuntu
The reason why I do this is that we plan to implement a method that translate code. And because we are using strcat and all, we can't make a situational translating working well. Because the file where all will be written won have all the stuff in the right order
I would use the compiler -- or, more accurately, the preprocessor.
Specifically, I'd find a project-wide header, and in it add a couple lines like:
#define strcpy(out, in) sprintf(out, "%s", in)
#define strcat(out, in) sprintf(out+strlen(out), "%s", in)
...and leave the rest of the source code alone. Then when you come to your senses, it'll be easy to change back to being sensible and using strcpy
/strcat
where they should be.
这篇关于我怎样才能修改文件夹中的所有文件的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!