View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Be the first to rate this file! 6 Downloads (last 30 days) File Size: 3.02 KB File ID: #41622 Version: 1.0




Function to patch files a la the UNIX patch utility from unified diff files using pure Matlab.

| Watch this File

File Information

 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
      mypatcher( file_to_be_patched, patch )
      patched_text = mypatcher( ... )
      [patched_text, info] = mypatcher( ... )
      mypatcher(..., output_file)
      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.
      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
      output_file - Name of the file to output to. Will be erased if it
         already exists.
      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.
      Given the files 'file.old' and '' we can find the updates
           %>diff -u file.old > file.patch
      We can now run mypatcher to get a patched version of 'file.old'
      like so:
      Wikipedia Diff Article

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Other requirements Will probably work on lower versions of Matlab as well.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us