[PATCH] Diff: Make sure we handle empty files properly

Denys Vlasenko vda.linux at googlemail.com
Wed Oct 20 22:40:11 UTC 2010


On Tuesday 19 October 2010 19:20, Gilles Espinasse wrote:
> 
> ----- Original Message ----- 
> From: "Lukas Huba" <Huba.Lukas at centrum.cz>
> To: <busybox at busybox.net>
> Sent: Tuesday, October 19, 2010 6:43 PM
> Subject: [PATCH] Diff: Make sure we handle empty files properly
> 
> Suggested rewording of the comment and help texts

Looks ok. I only propose a bit different code which truncates the file:

                                        // File is empty after the patches have been applied
                                        state = 0;
                                        if (option_mask32 & FLAG_RMEMPTY) {
                                                // If flag -E or --remove-empty-files is set
                                                printf("removing %s\n", name);
                                                xunlink(name);
                                        } else {
                                                printf("patching file %s\n", name);
                                                xclose(xopen(name, O_WRONLY | O_TRUNC));
                                        }


Applied, thanks! Please try current git.

-- 
vda


More information about the busybox mailing list