summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2012-04-14 13:41:18 +0200
committerAndreas Gruenbacher <agruen@linbit.com>2012-09-13 16:34:58 +0200
commitf0388d2dbff7903e514f86947f3b7c7e29e674c8 (patch)
tree606e105953a97970aa1e21169c34d720b22d22b7
parent281537bcd92515ae3b9f154acd579ce97260f99b (diff)
downloadpatch-f0388d2dbff7903e514f86947f3b7c7e29e674c8.tar.gz
Change the type of *_needs_removal from int to bool
-rw-r--r--src/common.h6
-rw-r--r--src/inp.c2
-rw-r--r--src/patch.c24
-rw-r--r--src/pch.c6
-rw-r--r--src/pch.h2
-rw-r--r--src/util.c4
-rw-r--r--src/util.h2
7 files changed, 23 insertions, 23 deletions
diff --git a/src/common.h b/src/common.h
index b1e6c9e..23a4091 100644
--- a/src/common.h
+++ b/src/common.h
@@ -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;
diff --git a/src/inp.c b/src/inp.c
index 6387587..dbc3f5d 100644
--- a/src/inp.c
+++ b/src/inp.c
@@ -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;
diff --git a/src/patch.c b/src/patch.c
index ce81bbe..0bce8fb 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -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;
}
}
diff --git a/src/pch.c b/src/pch.c
index 9661be2..551099e 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -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 ? "" : "- ",
diff --git a/src/pch.h b/src/pch.h
index e545cb1..0c7ff62 100644
--- a/src/pch.h
+++ b/src/pch.h
@@ -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);
diff --git a/src/util.c b/src/util.c
index e8e2ad4..7fb6b05 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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)
diff --git a/src/util.h b/src/util.h
index d1bf495..f0d20aa 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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 *);