mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-10 16:12:59 +00:00
Merge pull request #2475 from libgit2/expose-buffer-binary-detection
Export git_buf_text_is_binary and git_buf_text_contains_nul.
This commit is contained in:
commit
091165c53b
@ -105,6 +105,22 @@ GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size);
|
|||||||
GIT_EXTERN(int) git_buf_set(
|
GIT_EXTERN(int) git_buf_set(
|
||||||
git_buf *buffer, const void *data, size_t datalen);
|
git_buf *buffer, const void *data, size_t datalen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check quickly if buffer looks like it contains binary data
|
||||||
|
*
|
||||||
|
* @param buf Buffer to check
|
||||||
|
* @return 1 if buffer looks like non-text data
|
||||||
|
*/
|
||||||
|
GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check quickly if buffer contains a NUL byte
|
||||||
|
*
|
||||||
|
* @param buf Buffer to check
|
||||||
|
* @return 1 if buffer contains a NUL byte
|
||||||
|
*/
|
||||||
|
GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf);
|
||||||
|
|
||||||
GIT_END_DECL
|
GIT_END_DECL
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
11
src/buffer.c
11
src/buffer.c
@ -7,6 +7,7 @@
|
|||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "posix.h"
|
#include "posix.h"
|
||||||
#include "git2/buffer.h"
|
#include "git2/buffer.h"
|
||||||
|
#include "buf_text.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/* Used as default value for git_buf->ptr so that people can always
|
/* Used as default value for git_buf->ptr so that people can always
|
||||||
@ -141,6 +142,16 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_buf_is_binary(const git_buf *buf)
|
||||||
|
{
|
||||||
|
return git_buf_text_is_binary(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int git_buf_contains_nul(const git_buf *buf)
|
||||||
|
{
|
||||||
|
return git_buf_text_contains_nul(buf);
|
||||||
|
}
|
||||||
|
|
||||||
int git_buf_sets(git_buf *buf, const char *string)
|
int git_buf_sets(git_buf *buf, const char *string)
|
||||||
{
|
{
|
||||||
return git_buf_set(buf, string, string ? strlen(string) : 0);
|
return git_buf_set(buf, string, string ? strlen(string) : 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user