Don't mix declarations and code (not widely portable).

client/mysqltest.c:
  Don't mix declarations and code.
  Tid up function code.
This commit is contained in:
Davi Arnaut 2009-06-06 12:26:39 -03:00
parent 6010bd18ae
commit 07547c7d4a

View File

@ -1329,38 +1329,43 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...)
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
/* /*
Test if diff is present. This is needed on Windows systems Test if diff is present. This is needed on Windows systems
as the OS returns 1 whether diff is successful or if it is as the OS returns 1 whether diff is successful or if it is
not present. not present.
We run diff -v and look for output in stdout. We run diff -v and look for output in stdout.
We don't redirect stderr to stdout to make for a simplified check We don't redirect stderr to stdout to make for a simplified check
Windows will output '"diff"' is not recognized... to stderr if it is Windows will output '"diff"' is not recognized... to stderr if it is
not present. not present.
*/ */
int diff_check(const char *diff_name) #ifdef __WIN__
static int diff_check(const char *diff_name)
{ {
char buf[512]= {0};
FILE *res_file; FILE *res_file;
char cmd[128]; char buf[128];
my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name); int have_diff= 0;
int have_diff = 0;
if (!(res_file= popen(cmd, "r"))) my_snprintf(buf, sizeof(buf), "%s -v", diff_name);
die("popen(\"%s\", \"r\") failed", cmd);
/* if diff is not present, nothing will be in if (!(res_file= popen(buf, "r")))
* stdout to increment have_diff */ die("popen(\"%s\", \"r\") failed", buf);
/* if diff is not present, nothing will be in stdout to increment have_diff */
if (fgets(buf, sizeof(buf), res_file)) if (fgets(buf, sizeof(buf), res_file))
{ have_diff= 1;
have_diff += 1;
}
pclose(res_file); pclose(res_file);
return have_diff; return have_diff;
} }
#endif
/* /*
Show the diff of two files using the systems builtin diff Show the diff of two files using the systems builtin diff
command. If no such diff command exist, just dump the content command. If no such diff command exist, just dump the content