Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
ab3beede
Commit
ab3beede
authored
16 years ago
by
patacongo
Browse files
Options
Downloads
Patches
Plain Diff
cosmetic
git-svn-id:
svn://svn.code.sf.net/p/nuttx/code/trunk@897
42af7a65-404d-4744-a932-0658087f49c3
parent
d57cb4fc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/lib_fgets.c
+19
-19
19 additions, 19 deletions
lib/lib_fgets.c
with
19 additions
and
19 deletions
lib/lib_fgets.c
+
19
−
19
View file @
ab3beede
/****************************************************************************
* lib_fgets.c
*
lib/
lib_fgets.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
...
...
@@ -121,9 +121,9 @@ static inline void _lib_consoleputc(int ch)
****************************************************************************/
#ifdef CONFIG_FGETS_ECHO
static
inline
void
_lib_consoleputs
(
const
char
*
s
)
static
inline
void
_lib_consoleputs
(
const
char
*
s
tr
)
{
(
void
)
write
(
1
,
s
,
strlen
(
s
));
(
void
)
write
(
1
,
s
tr
,
strlen
(
s
tr
));
}
#endif
...
...
@@ -135,9 +135,9 @@ static inline void _lib_consoleputs(const char *s)
* Name: fgets
*
* Description:
* fgets() reads in at most one less than 'n' characters
* fgets() reads in at most one less than '
bufle
n' characters
* from stream and stores them into the buffer pointed to
* by '
s
'. Reading stops after an EOF or a newline. If a
* by '
buf
'. Reading stops after an EOF or a newline. If a
* newline is read, it is stored into the buffer. A null
* terminator is stored after the last character in the
* buffer.
...
...
@@ -151,7 +151,7 @@ static inline void _lib_consoleputs(const char *s)
*
**************************************************************************/
char
*
fgets
(
FAR
char
*
s
,
int
n
,
FILE
*
stream
)
char
*
fgets
(
FAR
char
*
buf
,
int
bufle
n
,
FILE
*
stream
)
{
#ifdef CONFIG_FGETS_ECHO
boolean
console
;
...
...
@@ -161,15 +161,15 @@ char *fgets(FAR char *s, int n, FILE *stream)
/* Sanity checks */
if
(
!
stream
||
!
s
||
n
<
1
||
stream
->
fs_filedes
<
0
)
if
(
!
stream
||
!
buf
||
bufle
n
<
1
||
stream
->
fs_filedes
<
0
)
{
return
NULL
;
}
if
(
n
<
2
)
if
(
bufle
n
<
2
)
{
*
s
=
'\0'
;
return
s
;
*
buf
=
'\0'
;
return
buf
;
}
/* Check if the stream is stdin */
...
...
@@ -270,8 +270,8 @@ char *fgets(FAR char *s, int n, FILE *stream)
* with the null terminator.
*/
s
[
nch
++
]
=
'\n'
;
s
[
nch
]
=
'\0'
;
buf
[
nch
++
]
=
'\n'
;
buf
[
nch
]
=
'\0'
;
#ifdef CONFIG_FGETS_ECHO
if
(
console
)
...
...
@@ -281,7 +281,7 @@ char *fgets(FAR char *s, int n, FILE *stream)
_lib_consoleputc
(
'\n'
);
}
#endif
return
s
;
return
buf
;
}
/* Check for end-of-file */
...
...
@@ -300,8 +300,8 @@ char *fgets(FAR char *s, int n, FILE *stream)
{
/* Terminate the line */
s
[
nch
]
=
'\0'
;
return
s
;
\
buf
[
nch
]
=
'\0'
;
return
buf
;
}
}
...
...
@@ -311,7 +311,7 @@ char *fgets(FAR char *s, int n, FILE *stream)
else
if
(
isprint
(
ch
))
{
s
[
nch
++
]
=
ch
;
buf
[
nch
++
]
=
ch
;
#ifdef CONFIG_FGETS_ECHO
if
(
console
)
...
...
@@ -326,10 +326,10 @@ char *fgets(FAR char *s, int n, FILE *stream)
* we have to end the line now.
*/
if
(
nch
+
1
>=
n
)
if
(
nch
+
1
>=
bufle
n
)
{
s
[
nch
]
=
'\0'
;
return
s
;
buf
[
nch
]
=
'\0'
;
return
buf
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment