MyPatcher

版本 1.0.0.0 (3.0 KB) 作者: Michael Ryan
Function to patch files a la the UNIX patch utility from unified diff files using pure Matlab.
233.0 次下载
更新时间 2013/5/3

查看许可证

This is a Matlab implementation of the unix patch utility, though
not fully featured. It currently only works on unified diff text
files, ie, the files created by "diff -u old new" and is not POSIX
compliant.

SYNTAX:
mypatcher( file_to_be_patched, patch )
patched_text = mypatcher( ... )
[patched_text, info] = mypatcher( ... )
mypatcher(..., output_file)

DESCRIPTION:
MYPATCHER( file_to_be_patched, patch ) takes a unified diff file
specified by patch and applies it to file_to_be_patched.
The resulting file is output to file_to_be_patched.patched
as well as output to the screen. file_to_be_patched must be
a text file, not binary. mypatcher does not check whether the
surrounding text matches.
patched_text = mypatcher( ... ) puts the changed text in
patched_text instead of displaying and outputting to file
[patched_text, info] = mypatcher( ... ) also includes some info
about the patch file hunks and file_to_be_patched.
mypatcher(..., output_file) uses output_file instead of
file_to_be_patched.patched as the output destination.

INPUTS:
file_to_be_patched - Name of the file to be patched. Cannot be a
binary file
patch - Name of the patch file to apply. Must be a unified diff
file.
output_file - Name of the file to output to. Will be erased if it
already exists.
OUTPUTS:
patched_text - A string containing the result of applying the
patch file to the input file.
info - A struct containing the input file as a whole string and
line-by-line in a struct and the hunks of the patch file in a
different struct along with the hunk header information.
EXAMPLES:
Given the files 'file.old' and 'file.new' we can find the updates
using
%>diff -u file.old file.new > file.patch
We can now run mypatcher to get a patched version of 'file.old'
like so:
mypatcher('file.old','file.patch')
SEE ALSO:
Wikipedia Diff Article

引用格式

Michael Ryan (2024). MyPatcher (https://www.mathworks.com/matlabcentral/fileexchange/41622-mypatcher), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2011b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 File Operations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0