diff options
author | Russell Belfer <rb@github.com> | 2013-03-25 14:20:07 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-03-25 14:20:07 -0700 |
commit | 3658e81e3499f874dc9f323d4d9127df7e219e12 (patch) | |
tree | 468b0ba5739118b56d1961063655ffbbf95d8a12 /src/buf_text.h | |
parent | 050ab9950d089c55e874b63e5ab9c8d0b948cf46 (diff) | |
download | libgit2-autocrlf-fixes.tar.gz |
Move crlf conversion into buf_textautocrlf-fixes
This adds crlf/lf conversion functions into buf_text with more
efficient implementations that bypass the high level buffer
functions. They attempt to minimize the number of reallocations
done and they directly write the buffer data as needed if they
know that there is enough memory allocated to memcpy data.
Tests are added for these new functions. The crlf.c code is
updated to use the new functions.
Removed the include of buf_text.h from filter.h and just include
it more narrowly in the places that need it.
Diffstat (limited to 'src/buf_text.h')
-rw-r--r-- | src/buf_text.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/buf_text.h b/src/buf_text.h index 458ee33c9..58e4e26a7 100644 --- a/src/buf_text.h +++ b/src/buf_text.h @@ -56,6 +56,20 @@ GIT_INLINE(int) git_buf_text_puts_escape_regex(git_buf *buf, const char *string) extern void git_buf_text_unescape(git_buf *buf); /** + * Replace all \r\n with \n (or do nothing if no \r\n are found) + * + * @return 0 on success, GIT_ENOTFOUND if no \r\n, -1 on memory error + */ +extern int git_buf_text_crlf_to_lf(git_buf *tgt, const git_buf *src); + +/** + * Replace all \n with \r\n (or do nothing if no \n are found) + * + * @return 0 on success, GIT_ENOTFOUND if no \n, -1 on memory error + */ +extern int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src); + +/** * Fill buffer with the common prefix of a array of strings * * Buffer will be set to empty if there is no common prefix |