linux fopen("temp.sh","w");出错,【已解决】patch打补丁时出错:patch: **** malformed patch at line...

【问题】

折腾:

期间,

手动去把:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\m4\m4-1.4.16-no-gets.patch

先改名为:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\m4\m4-1.4.16-no-gets-and-missing-binary-operator.patch

并且内容从:Since the 2.16 release of the glibc, 'gets' is not any more defined in the gnulib.

No m4 version synchronized with gnulib since [1] has been released yet.

This patch avoids the following error occurs when building m4 <=1.4.16 on host using

a glibc >=2.16:

make[4]: Entering directory `/opt/buildroot/output/build/host-m4-1.4.16/lib'

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT gl_avltree_oset.o -MD -MP -MF .deps/gl_avltree_oset.Tpo -c -o gl_avltree_oset.o gl_avltree_oset.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT c-ctype.o -MD -MP -MF .deps/c-ctype.Tpo -c -o c-ctype.o c-ctype.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT c-stack.o -MD -MP -MF .deps/c-stack.Tpo -c -o c-stack.o c-stack.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c

mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c

In file included from clean-temp.h:22:0,

from clean-temp.c:23:

./stdio.h:477:20: error 'gets' undeclared here (not in a function)

make[4]: *** [clean-temp.o] Error 1

References:

[1] http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=66712c23388e93e5c518ebc8515140fa0c807348

[2] http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-devel/m4/files/m4-1.4.16-no-gets.patch?diff_format=h&revision=1.1&view=markup

Signed-off-by: Samuel Martin

---

diff -purN host-m4-1.4.16.orig/lib/stdio.in.h host-m4-1.4.16/lib/stdio.in.h

--- host-m4-1.4.16.orig/lib/stdio.in.h2012-07-21 19:11:40.196541826 +0200

+++ host-m4-1.4.16/lib/stdio.in.h2012-07-21 20:46:05.405850751 +0200

@@ -162,7 +162,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not

so any use of gets warrants an unconditional warning. Assume it is

always declared, since it is required by C89. */

#undef gets

+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)

_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

+#endif

#if @GNULIB_FOPEN@

# if @REPLACE_FOPEN@

改为:Since the 2.16 release of the glibc, 'gets' is not any more defined in the gnulib.

No m4 version synchronized with gnulib since [1] has been released yet.

This patch avoids the following error occurs when building m4 <=1.4.16 on host using

a glibc >=2.16:

make[4]: Entering directory `/opt/buildroot/output/build/host-m4-1.4.16/lib'

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT gl_avltree_oset.o -MD -MP -MF .deps/gl_avltree_oset.Tpo -c -o gl_avltree_oset.o gl_avltree_oset.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT c-ctype.o -MD -MP -MF .deps/c-ctype.Tpo -c -o c-ctype.o c-ctype.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT c-stack.o -MD -MP -MF .deps/c-stack.Tpo -c -o c-stack.o c-stack.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c

mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c

In file included from clean-temp.h:22:0,

from clean-temp.c:23:

./stdio.h:477:20: error 'gets' undeclared here (not in a function)

make[4]: *** [clean-temp.o] Error 1

References:

[1] http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=66712c23388e93e5c518ebc8515140fa0c807348

[2] http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-devel/m4/files/m4-1.4.16-no-gets.patch?diff_format=h&revision=1.1&view=markup

Signed-off-by: Samuel Martin

---

diff -purN host-m4-1.4.16.orig/lib/stdio.in.h host-m4-1.4.16/lib/stdio.in.h

--- host-m4-1.4.16.orig/lib/stdio.in.h2012-07-21 19:11:40.196541826 +0200

+++ host-m4-1.4.16/lib/stdio.in.h2012-07-21 20:46:05.405850751 +0200

@@ -162,7 +162,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not

so any use of gets warrants an unconditional warning. Assume it is

always declared, since it is required by C89. */

#undef gets

+#if defined(__GLIBC__) && !defined(__UCLIBC__)

+#if !((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))

_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

+#endif

#if @GNULIB_FOPEN@

# if @REPLACE_FOPEN@

然后去执行make,然后打补丁期间出错:Applying m4-1.4.16-no-gets-and-missing-binary-operator.patch using patch:

patching file lib/stdio.in.h

patch: **** malformed patch at line 39: # if @REPLACE_FOPEN@

Patch failed! Please fix m4-1.4.16-no-gets-and-missing-binary-operator.patch!

make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/.stamp_patched] Error 1

如图:

cdd05dbb6929e7026d712e86bb90661f.png

即:patch: **** malformed patch at line 39: # if @REPLACE_FOPEN@

【解决过程】

1.此处,实际上,只是修改了一行,从:+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)

改为:+#if defined(__GLIBC__) && !defined(__UCLIBC__)

+#if !((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))

而已,没有其他任何改动。结果竟然也能出错。

很是奇怪。

难道是patch文件的生成,也还有什么特殊的讲究?

2.此处选择,再改回之前的原先的patch内容:Since the 2.16 release of the glibc, 'gets' is not any more defined in the gnulib.

No m4 version synchronized with gnulib since [1] has been released yet.

This patch avoids the following error occurs when building m4 <=1.4.16 on host using

a glibc >=2.16:

make[4]: Entering directory `/opt/buildroot/output/build/host-m4-1.4.16/lib'

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT gl_avltree_oset.o -MD -MP -MF .deps/gl_avltree_oset.Tpo -c -o gl_avltree_oset.o gl_avltree_oset.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT c-ctype.o -MD -MP -MF .deps/c-ctype.Tpo -c -o c-ctype.o c-ctype.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT c-stack.o -MD -MP -MF .deps/c-stack.Tpo -c -o c-stack.o c-stack.c

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c

mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po

/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99 -I. -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c

In file included from clean-temp.h:22:0,

from clean-temp.c:23:

./stdio.h:477:20: error 'gets' undeclared here (not in a function)

make[4]: *** [clean-temp.o] Error 1

References:

[1] http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=66712c23388e93e5c518ebc8515140fa0c807348

[2] http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-devel/m4/files/m4-1.4.16-no-gets.patch?diff_format=h&revision=1.1&view=markup

Signed-off-by: Samuel Martin

---

diff -purN host-m4-1.4.16.orig/lib/stdio.in.h host-m4-1.4.16/lib/stdio.in.h

--- host-m4-1.4.16.orig/lib/stdio.in.h2012-07-21 19:11:40.196541826 +0200

+++ host-m4-1.4.16/lib/stdio.in.h2012-07-21 20:46:05.405850751 +0200

@@ -162,7 +162,9 @@ _GL_WARN_ON_USE (fflush, "fflush is not

so any use of gets warrants an unconditional warning. Assume it is

always declared, since it is required by C89. */

#undef gets

+#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)

_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

+#endif

#if @GNULIB_FOPEN@

# if @REPLACE_FOPEN@

然后make看看, 结果又出现“Reversed (or previously applied) patch detected!  Assume -R? [n]”的问题:

3.结果虽然可以继续执行了, 但是又出现“Patch failed!  Please fix m4-1.4.16-no-fpending-redefinition.patch!”的错误:

4.此处,最终,还是要把此处自己的改动,加上去的,所以,之前恢复到原先内容的做法,还是不能接受的。

还是要想办法,再去搞清楚,为何上面直接改patch文件,为何会出错,

以及,如何自己制作出对应的,可用的patch文件。

5.而通过上面的折腾,注意到一个事情:

diff生成的patch文件中,对应的@@和@@中间的数字,貌似指的是,所应用到的,所修改到的文件的行数。

比如:diff -purN host-m4-1.4.16.orig/ChangeLog host-m4-1.4.16/ChangeLog

--- host-m4-1.4.16.orig/ChangeLog2011-03-02 02:39:40.000000000 +0800

+++ host-m4-1.4.16/ChangeLog2013-08-28 13:25:09.128914000 +0800

@@ -1,3 +1,8 @@

+2013-08-28 Crifan Li

+

+maint: merge Paul Eggert's bugfix for v1.7.11.7 to current version

+* fpending: http://lists.gnu.org/archive/html/bug-gnulib/2013-08/msg00030.html

+

2011-03-01 Eric Blake eblake@redhat.com

如图:

0cf3d57fd67fe30d5967fdf9a6902543.png

感觉-1,3 +1,8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值