[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-diffutils] [PATCH 2/3] portability: declare variables first in bloc
From: |
Peter Rosin |
Subject: |
[bug-diffutils] [PATCH 2/3] portability: declare variables first in blocks |
Date: |
Fri, 10 Feb 2012 17:12:14 +0100 |
* src/dir.c (diff_dirs): Declare 'v1' at the top of the block.
(find_dir_file_pathname): Likewise for 'p'.
* src/io.c (find_and_hash_each_line): Likewise for 'repetitions'.
Copyright-paperwork-exempt: Yes
---
src/dir.c | 10 ++++++----
src/io.c | 3 ++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/dir.c b/src/dir.c
index 57134c7..2633ed0 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -254,6 +254,7 @@ diff_dirs (struct comparison const *cmp,
pretend the "next name" in that dir is very large. */
int nameorder = (!*names[0] ? 1 : !*names[1] ? -1
: compare_names (*names[0], *names[1]));
+ int v1;
/* Prefer a file_name_cmp match if available. This algorithm is
O(N**2), where N is the number of names in a directory
@@ -289,9 +290,9 @@ diff_dirs (struct comparison const *cmp,
}
}
- int v1 = (*handle_file) (cmp,
- 0 < nameorder ? 0 : *names[0]++,
- nameorder < 0 ? 0 : *names[1]++);
+ v1 = (*handle_file) (cmp,
+ 0 < nameorder ? 0 : *names[0]++,
+ nameorder < 0 ? 0 : *names[1]++);
if (val < v1)
val = v1;
}
@@ -342,7 +343,8 @@ find_dir_file_pathname (char const *dir, char const *file)
match = file; /* longjmp may mess up MATCH. */
else
{
- for (char const **p = dirdata.names; *p; p++)
+ char const **p;
+ for (p = dirdata.names; *p; p++)
if (compare_names (*p, file) == 0)
{
if (file_name_cmp (*p, file) == 0)
diff --git a/src/io.c b/src/io.c
index 5a631a5..a522f48 100644
--- a/src/io.c
+++ b/src/io.c
@@ -260,6 +260,7 @@ find_and_hash_each_line (struct file_data *current)
size_t column = 0;
while ((c = *p++) != '\n')
{
+ size_t repetitions;
if (ig_white_space & IGNORE_TRAILING_SPACE
&& isspace (c))
{
@@ -274,7 +275,7 @@ find_and_hash_each_line (struct file_data *current)
while (isspace (c1));
}
- size_t repetitions = 1;
+ repetitions = 1;
if (ig_white_space & IGNORE_TAB_EXPANSION)
switch (c)
--
1.7.5.1