Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tcl compress/uncompress error handling and doc #1627

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/sphinx_source/using/tcl-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ uncompressfile <src-file> [target-file]

Description: compresses or un-compresses files. The level option specifies the compression mode to use when compressing. Available modes are from 0 (minimum CPU usage, minimum compression) all the way up to 9 (maximum CPU usage, maximum compression). If you don't specify the target-file, the src-file will be overwritten.

Returns: nothing
Returns: 1 if successful; 0 otherwise

Module: compress

Expand Down
4 changes: 2 additions & 2 deletions src/mod/compress.mod/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static int compress_file(char *filename, int mode_num)
* if the compression routine succeeded.
*/
if (ret == COMPF_SUCCESS)
movefile(temp_fn, filename);
ret = movefile(temp_fn, filename) ? COMPF_ERROR : COMPF_SUCCESS;

nfree(temp_fn);
return ret;
Expand All @@ -340,7 +340,7 @@ static int uncompress_file(char *filename)
* if the uncompression routine succeeded.
*/
if (ret == COMPF_SUCCESS)
movefile(temp_fn, filename);
ret = movefile(temp_fn, filename) ? COMPF_ERROR : COMPF_SUCCESS;

nfree(temp_fn);
return ret;
Expand Down
4 changes: 2 additions & 2 deletions src/mod/compress.mod/tclcompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int tcl_compress_file STDVAR
else
result = compress_file(fn_src, mode_num);

if (result)
if (result == COMPF_SUCCESS)
Tcl_AppendResult(irp, "1", NULL);
else
Tcl_AppendResult(irp, "0", NULL);
Expand All @@ -85,7 +85,7 @@ static int tcl_uncompress_file STDVAR
else
result = uncompress_to_file(argv[1], argv[2]);

if (result)
if (result == COMPF_SUCCESS)
Tcl_AppendResult(irp, "1", NULL);
else
Tcl_AppendResult(irp, "0", NULL);
Expand Down