Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
net-tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
net-tools
Commits
115f1af2
Commit
115f1af2
authored
Jul 10, 2016
by
Eugen Feller
Committed by
Bernd Eckenfels
Jul 10, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed trailing whitespace issue with a and i flags (#7)
Thanks to Eugen Feller.
parent
bd8bceae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
hostname.c
hostname.c
+16
-4
No files found.
hostname.c
View file @
115f1af2
...
...
@@ -31,6 +31,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <stdlib.h>
#include <getopt.h>
...
...
@@ -139,6 +140,7 @@ static void showhname(char *hname, int c)
#endif
socklen_t
len
;
char
**
addrp
;
bool
isfirst
=
true
;
/* We use -1 so we can guarantee the buffer is NUL terminated. */
len
=
sizeof
(
addr
)
-
1
;
...
...
@@ -179,14 +181,24 @@ static void showhname(char *hname, int c)
switch
(
c
)
{
case
'a'
:
while
(
hp
->
h_aliases
[
0
])
printf
(
"%s "
,
*
hp
->
h_aliases
++
);
while
(
hp
->
h_aliases
[
0
])
{
if
(
isfirst
)
{
printf
(
"%s"
,
*
hp
->
h_aliases
++
);
isfirst
=
false
;
}
else
printf
(
" %s"
,
*
hp
->
h_aliases
++
);
}
printf
(
"
\n
"
);
break
;
case
'i'
:
for
(
addrp
=
hp
->
h_addr_list
;
*
addrp
;
++
addrp
)
{
if
(
inet_ntop
(
hp
->
h_addrtype
,
*
addrp
,
addr
,
len
))
printf
(
"%s "
,
addr
);
if
(
inet_ntop
(
hp
->
h_addrtype
,
*
addrp
,
addr
,
len
))
{
if
(
isfirst
)
{
printf
(
"%s"
,
addr
);
isfirst
=
false
;
}
else
printf
(
" %s"
,
addr
);
}
else
if
(
errno
==
EAFNOSUPPORT
)
fprintf
(
stderr
,
_
(
"%s: protocol family not supported
\n
"
),
program_name
);
...
...
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