Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
017577c1
Commit
017577c1
authored
Jan 09, 2009
by
Tatiana A. Nurnberg
Browse files
Options
Browse Files
Download
Plain Diff
auto-merge
parents
c42892d6
af739b2c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
18 deletions
+63
-18
client/mysqltest.c
client/mysqltest.c
+63
-18
No files found.
client/mysqltest.c
View file @
017577c1
...
...
@@ -1329,6 +1329,35 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...)
DBUG_RETURN
(
ret
);
}
/*
Test if diff is present. This is needed on Windows systems
as the OS returns 1 whether diff is successful or if it is
not present.
We run diff -v and look for output in stdout.
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
not present.
*/
int
diff_check
()
{
char
buf
[
512
]
=
{
0
};
FILE
*
res_file
;
char
*
cmd
=
"diff -v"
;
int
have_diff
=
0
;
if
(
!
(
res_file
=
popen
(
cmd
,
"r"
)))
die
(
"popen(
\"
%s
\"
,
\"
r
\"
) failed"
,
cmd
);
/* if diff is not present, nothing will be in stdout to increment have_diff */
if
(
fgets
(
buf
,
sizeof
(
buf
),
res_file
))
{
have_diff
+=
1
;
}
pclose
(
res_file
);
return
have_diff
;
}
/*
Show the diff of two files using the systems builtin diff
...
...
@@ -1348,10 +1377,19 @@ void show_diff(DYNAMIC_STRING* ds,
{
DYNAMIC_STRING
ds_tmp
;
int
have_diff
=
0
;
if
(
init_dynamic_string
(
&
ds_tmp
,
""
,
256
,
256
))
die
(
"Out of memory"
);
/* determine if we have diff on Windows
needs special processing due to return values
on that OS
*/
have_diff
=
diff_check
();
if
(
have_diff
)
{
/* First try with unified diff */
if
(
run_tool
(
"diff"
,
&
ds_tmp
,
/* Get output from diff in ds_tmp */
...
...
@@ -1371,11 +1409,19 @@ void show_diff(DYNAMIC_STRING* ds,
filename2
,
"2>&1"
,
NULL
)
>
1
)
/* Most "diff" tools return >1 if error */
{
have_diff
=
1
;
}
}
}
if
(
!
(
have_diff
))
{
/*
Fallback to dump both files to result file and inform
about installing "diff"
*/
dynstr_set
(
&
ds_tmp
,
""
);
dynstr_append
(
&
ds_tmp
,
...
...
@@ -1400,7 +1446,6 @@ void show_diff(DYNAMIC_STRING* ds,
cat_file
(
&
ds_tmp
,
filename2
);
dynstr_append
(
&
ds_tmp
,
"<<<<
\n
"
);
}
}
if
(
ds
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment