Change the type of *_needs_removal from int to bool

This commit is contained in:
Andreas Gruenbacher 2012-04-14 13:41:18 +02:00
parent 281537bcd9
commit f0388d2dbf
7 changed files with 23 additions and 23 deletions

View File

@ -91,9 +91,9 @@ XTERN char const * TMPINNAME;
XTERN char const * TMPOUTNAME;
XTERN char const * TMPPATNAME;
XTERN int TMPINNAME_needs_removal;
XTERN int TMPOUTNAME_needs_removal;
XTERN int TMPPATNAME_needs_removal;
XTERN bool TMPINNAME_needs_removal;
XTERN bool TMPOUTNAME_needs_removal;
XTERN bool TMPPATNAME_needs_removal;
#ifdef DEBUGGING
XTERN int debug;

View File

@ -356,7 +356,7 @@ plan_b (char const *filename)
{
tifd = make_tempfile (&TMPINNAME, 'i', NULL, O_RDWR | O_BINARY,
S_IRUSR | S_IWUSR);
TMPINNAME_needs_removal = 1;
TMPINNAME_needs_removal = true;
}
i = 0;
len = 0;

View File

@ -48,14 +48,14 @@ static void init_output (struct outstate *);
static FILE *open_outfile (char const *);
static void init_reject (char const *);
static void reinitialize_almost_everything (void);
static void remove_if_needed (char const *, int *);
static void remove_if_needed (char const *, bool *);
static void usage (FILE *, int) __attribute__((noreturn));
static void abort_hunk (char const *, bool, bool);
static void abort_hunk_context (bool, bool);
static void abort_hunk_unified (bool, bool);
static void output_file (char const *, int *, const struct stat *, char const *,
static void output_file (char const *, bool *, const struct stat *, char const *,
const struct stat *, mode_t, bool);
static void init_files_to_delete (void);
@ -95,7 +95,7 @@ static FILE *rejfp; /* reject file pointer */
static char const *patchname;
static char *rejname;
static char const * TMPREJNAME;
static int TMPREJNAME_needs_removal;
static bool TMPREJNAME_needs_removal;
static lin maxfuzz = 2;
@ -299,7 +299,7 @@ main (int argc, char **argv)
outfd = make_tempfile (&TMPOUTNAME, 'o', outname,
O_WRONLY | binary_transput,
instat.st_mode & S_IRWXUGO);
TMPOUTNAME_needs_removal = 1;
TMPOUTNAME_needs_removal = true;
if (diff_type == ED_DIFF) {
outstate.zero_output = false;
somefailed |= skip_rest_of_patch;
@ -1558,7 +1558,7 @@ init_reject (char const *outname)
int fd;
fd = make_tempfile (&TMPREJNAME, 'r', outname, O_WRONLY | binary_transput,
0666);
TMPREJNAME_needs_removal = 1;
TMPREJNAME_needs_removal = true;
rejfp = fdopen (fd, binary_transput ? "wb" : "w");
if (! rejfp)
pfatal ("Can't open stream for file %s", quotearg (TMPREJNAME));
@ -1759,7 +1759,7 @@ struct file_to_output {
static gl_list_t files_to_output;
static void
output_file_later (char const *from, int *from_needs_removal, const struct stat *from_st,
output_file_later (char const *from, bool *from_needs_removal, const struct stat *from_st,
char const *to, mode_t mode, bool backup)
{
struct file_to_output *file_to_output;
@ -1772,11 +1772,11 @@ output_file_later (char const *from, int *from_needs_removal, const struct stat
file_to_output->backup = backup;
gl_list_add_last (files_to_output, file_to_output);
if (from_needs_removal)
*from_needs_removal = 0;
*from_needs_removal = false;
}
static void
output_file_now (char const *from, int *from_needs_removal,
output_file_now (char const *from, bool *from_needs_removal,
const struct stat *from_st, char const *to,
mode_t mode, bool backup)
{
@ -1793,7 +1793,7 @@ output_file_now (char const *from, int *from_needs_removal,
}
static void
output_file (char const *from, int *from_needs_removal,
output_file (char const *from, bool *from_needs_removal,
const struct stat *from_st, char const *to,
const struct stat *to_st, mode_t mode, bool backup)
{
@ -1860,7 +1860,7 @@ output_files (struct stat const *st)
while (gl_list_iterator_next (&iter, &elt, NULL))
{
const struct file_to_output *file_to_output = elt;
int from_needs_removal = 1;
bool from_needs_removal = true;
struct stat const *from_st = &file_to_output->from_st;
output_file_now (file_to_output->from, &from_needs_removal,
@ -1917,12 +1917,12 @@ fatal_exit (int sig)
}
static void
remove_if_needed (char const *name, int *needs_removal)
remove_if_needed (char const *name, bool *needs_removal)
{
if (*needs_removal)
{
unlink (name);
*needs_removal = 0;
*needs_removal = false;
}
}

View File

@ -138,7 +138,7 @@ open_patch_file (char const *filename)
size_t charsread;
int fd = make_tempfile (&TMPPATNAME, 'p', NULL, O_RDWR | O_BINARY, 0);
FILE *read_pfp = pfp;
TMPPATNAME_needs_removal = 1;
TMPPATNAME_needs_removal = true;
pfp = fdopen (fd, "w+b");
if (! pfp)
pfatal ("Can't open stream for file %s", quotearg (TMPPATNAME));
@ -2350,7 +2350,7 @@ get_ed_command_letter (char const *line)
void
do_ed_script (char const *inname, char const *outname,
int *outname_needs_removal, FILE *ofp)
bool *outname_needs_removal, FILE *ofp)
{
static char const editor_program[] = EDITOR_PROGRAM;
@ -2361,7 +2361,7 @@ do_ed_script (char const *inname, char const *outname,
if (! dry_run && ! skip_rest_of_patch) {
int exclusive = *outname_needs_removal ? 0 : O_EXCL;
assert (! inerrno);
*outname_needs_removal = 1;
*outname_needs_removal = true;
copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
sprintf (buf, "%s %s%s", editor_program,
verbosity == VERBOSE ? "" : "- ",

View File

@ -43,7 +43,7 @@ size_t pch_line_len (lin) _GL_ATTRIBUTE_PURE;
const char *pch_name(enum nametype) _GL_ATTRIBUTE_PURE;
bool pch_copy (void) _GL_ATTRIBUTE_PURE;
bool pch_rename (void) _GL_ATTRIBUTE_PURE;
void do_ed_script (char const *, char const *, int *, FILE *);
void do_ed_script (char const *, char const *, bool *, FILE *);
void open_patch_file (char const *);
void re_patch (void);
void set_hunkmax (void);

View File

@ -430,7 +430,7 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original)
Back up TO if BACKUP is true. */
void
move_file (char const *from, int *from_needs_removal,
move_file (char const *from, bool *from_needs_removal,
struct stat const *fromst,
char const *to, mode_t mode, bool backup)
{
@ -525,7 +525,7 @@ move_file (char const *from, int *from_needs_removal,
if ((0 < to_errno
|| (to_errno == 0 && to_st.st_nlink <= 1))
&& from_needs_removal)
*from_needs_removal = 0;
*from_needs_removal = false;
}
}
else if (! backup)

View File

@ -58,7 +58,7 @@ void init_backup_hash_table (void);
void init_time (void);
void xalloc_die (void) __attribute__ ((noreturn));
void create_backup (char const *, const struct stat *, bool);
void move_file (char const *, int *, struct stat const *, char const *, mode_t, bool);
void move_file (char const *, bool *, struct stat const *, char const *, mode_t, bool);
void read_fatal (void) __attribute__ ((noreturn));
void remove_prefix (char *, size_t);
void removedirs (char const *);