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
5d37128d
Commit
5d37128d
authored
4 years ago
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git__hexdump: better mimic `hexdump -C`
parent
1c7fb212
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
src/util.c
+22
-9
No files found.
src/util.c
View file @
5d37128d
...
@@ -424,35 +424,48 @@ void git__hexdump(const char *buffer, size_t len)
...
@@ -424,35 +424,48 @@ void git__hexdump(const char *buffer, size_t len)
last_line
=
(
len
%
LINE_WIDTH
);
last_line
=
(
len
%
LINE_WIDTH
);
for
(
i
=
0
;
i
<
line_count
;
++
i
)
{
for
(
i
=
0
;
i
<
line_count
;
++
i
)
{
printf
(
"%08"
PRIxZ
" "
,
(
i
*
LINE_WIDTH
));
line
=
buffer
+
(
i
*
LINE_WIDTH
);
line
=
buffer
+
(
i
*
LINE_WIDTH
);
for
(
j
=
0
;
j
<
LINE_WIDTH
;
++
j
,
++
line
)
for
(
j
=
0
;
j
<
LINE_WIDTH
;
++
j
,
++
line
)
{
printf
(
"%02X "
,
(
unsigned
char
)
*
line
&
0xFF
);
printf
(
"%02x "
,
(
unsigned
char
)
*
line
&
0xFF
);
if
(
j
==
(
LINE_WIDTH
/
2
))
printf
(
" "
);
}
printf
(
"
|
"
);
printf
(
"
|
"
);
line
=
buffer
+
(
i
*
LINE_WIDTH
);
line
=
buffer
+
(
i
*
LINE_WIDTH
);
for
(
j
=
0
;
j
<
LINE_WIDTH
;
++
j
,
++
line
)
for
(
j
=
0
;
j
<
LINE_WIDTH
;
++
j
,
++
line
)
printf
(
"%c"
,
(
*
line
>=
32
&&
*
line
<=
126
)
?
*
line
:
'.'
);
printf
(
"%c"
,
(
*
line
>=
32
&&
*
line
<=
126
)
?
*
line
:
'.'
);
printf
(
"
\n
"
);
printf
(
"
|
\n
"
);
}
}
if
(
last_line
>
0
)
{
if
(
last_line
>
0
)
{
printf
(
"%08"
PRIxZ
" "
,
(
line_count
*
LINE_WIDTH
));
line
=
buffer
+
(
line_count
*
LINE_WIDTH
);
line
=
buffer
+
(
line_count
*
LINE_WIDTH
);
for
(
j
=
0
;
j
<
last_line
;
++
j
,
++
line
)
for
(
j
=
0
;
j
<
last_line
;
++
j
,
++
line
)
{
printf
(
"%02X "
,
(
unsigned
char
)
*
line
&
0xFF
);
printf
(
"%02x "
,
(
unsigned
char
)
*
line
&
0xFF
);
if
(
j
==
(
LINE_WIDTH
/
2
))
printf
(
" "
);
}
if
(
j
<
(
LINE_WIDTH
/
2
))
printf
(
" "
);
for
(
j
=
0
;
j
<
(
LINE_WIDTH
-
last_line
);
++
j
)
for
(
j
=
0
;
j
<
(
LINE_WIDTH
-
last_line
);
++
j
)
printf
(
"
"
);
printf
(
"
"
);
printf
(
"
|
"
);
printf
(
"
|
"
);
line
=
buffer
+
(
line_count
*
LINE_WIDTH
);
line
=
buffer
+
(
line_count
*
LINE_WIDTH
);
for
(
j
=
0
;
j
<
last_line
;
++
j
,
++
line
)
for
(
j
=
0
;
j
<
last_line
;
++
j
,
++
line
)
printf
(
"%c"
,
(
*
line
>=
32
&&
*
line
<=
126
)
?
*
line
:
'.'
);
printf
(
"%c"
,
(
*
line
>=
32
&&
*
line
<=
126
)
?
*
line
:
'.'
);
printf
(
"
\n
"
);
printf
(
"
|
\n
"
);
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
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