Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
b3af2d80
Commit
b3af2d80
authored
Jul 16, 2014
by
joshaber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just put it all in buffer.
parent
df4cba0f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
46 deletions
+45
-46
include/git2.h
+0
-1
include/git2/buf_text.h
+0
-42
include/git2/buffer.h
+16
-0
src/buf_text.c
+2
-2
src/buf_text.h
+16
-1
src/buffer.c
+11
-0
No files found.
include/git2.h
View file @
b3af2d80
...
...
@@ -13,7 +13,6 @@
#include "git2/blame.h"
#include "git2/branch.h"
#include "git2/buffer.h"
#include "git2/buf_text.h"
#include "git2/checkout.h"
#include "git2/cherrypick.h"
#include "git2/clone.h"
...
...
include/git2/buf_text.h
deleted
100644 → 0
View file @
df4cba0f
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_buf_text_h__
#define INCLUDE_git_buf_text_h__
#include "common.h"
#include "buffer.h"
/**
* @file git2/buf_text.h
* @brief Buffer text export structure
*
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/**
* 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_text_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_text_contains_nul
(
const
git_buf
*
buf
);
GIT_END_DECL
/** @} */
#endif
include/git2/buffer.h
View file @
b3af2d80
...
...
@@ -105,6 +105,22 @@ GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size);
GIT_EXTERN
(
int
)
git_buf_set
(
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
/** @} */
...
...
src/buf_text.c
View file @
b3af2d80
...
...
@@ -176,7 +176,7 @@ int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings)
return
0
;
}
int
git_buf_text_is_binary
(
const
git_buf
*
buf
)
bool
git_buf_text_is_binary
(
const
git_buf
*
buf
)
{
const
char
*
scan
=
buf
->
ptr
,
*
end
=
buf
->
ptr
+
buf
->
size
;
git_bom_t
bom
;
...
...
@@ -201,7 +201,7 @@ int git_buf_text_is_binary(const git_buf *buf)
return
((
printable
>>
7
)
<
nonprintable
);
}
int
git_buf_text_contains_nul
(
const
git_buf
*
buf
)
bool
git_buf_text_contains_nul
(
const
git_buf
*
buf
)
{
return
(
memchr
(
buf
->
ptr
,
'\0'
,
buf
->
size
)
!=
NULL
);
}
...
...
src/buf_text.h
View file @
b3af2d80
...
...
@@ -7,7 +7,6 @@
#ifndef INCLUDE_buf_text_h__
#define INCLUDE_buf_text_h__
#include "git2/buf_text.h"
#include "buffer.h"
typedef
enum
{
...
...
@@ -79,6 +78,22 @@ extern int git_buf_text_lf_to_crlf(git_buf *tgt, const git_buf *src);
extern
int
git_buf_text_common_prefix
(
git_buf
*
buf
,
const
git_strarray
*
strs
);
/**
* Check quickly if buffer looks like it contains binary data
*
* @param buf Buffer to check
* @return true if buffer looks like non-text data
*/
extern
bool
git_buf_text_is_binary
(
const
git_buf
*
buf
);
/**
* Check quickly if buffer contains a NUL byte
*
* @param buf Buffer to check
* @return true if buffer contains a NUL byte
*/
extern
bool
git_buf_text_contains_nul
(
const
git_buf
*
buf
);
/**
* Check if a buffer begins with a UTF BOM
*
* @param bom Set to the type of BOM detected or GIT_BOM_NONE
...
...
src/buffer.c
View file @
b3af2d80
...
...
@@ -7,6 +7,7 @@
#include "buffer.h"
#include "posix.h"
#include "git2/buffer.h"
#include "buf_text.h"
#include <ctype.h>
/* 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
;
}
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
)
{
return
git_buf_set
(
buf
,
string
,
string
?
strlen
(
string
)
:
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment