projects
/
kopensolaris-gnu
/
glibc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rewrite to allow omitting initialization of global variables.
[kopensolaris-gnu/glibc.git]
/
misc
/
mntent_r.c
diff --git
a/misc/mntent_r.c
b/misc/mntent_r.c
index
4dc0358
..
f6ee1ca
100644
(file)
--- a/
misc/mntent_r.c
+++ b/
misc/mntent_r.c
@@
-1,5
+1,5
@@
/* Utilities for reading/writing fstab, mtab, etc.
/* Utilities for reading/writing fstab, mtab, etc.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997
, 1998
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@
-22,6
+22,11
@@
#include <string.h>
#include <sys/types.h>
#include <string.h>
#include <sys/types.h>
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
/* Prepare to begin reading and/or writing mount table entries from the
beginning of FILE. MODE is as for `fopen'. */
FILE *
/* Prepare to begin reading and/or writing mount table entries from the
beginning of FILE. MODE is as for `fopen'. */
FILE *
@@
-51,12
+56,16
@@
__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
{
char *head;
{
char *head;
+ flockfile (stream);
do
{
char *end_ptr;
do
{
char *end_ptr;
- if (fgets (buffer, bufsiz, stream) == NULL)
- return NULL;
+ if (fgets_unlocked (buffer, bufsiz, stream) == NULL)
+ {
+ funlockfile (stream);
+ return NULL;
+ }
end_ptr = strchr (buffer, '\n');
if (end_ptr != NULL) /* chop newline */
end_ptr = strchr (buffer, '\n');
if (end_ptr != NULL) /* chop newline */
@@
-65,7
+74,7
@@
__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
{
/* Not the whole line was read. Do it now but forget it. */
char tmp[1024];
{
/* Not the whole line was read. Do it now but forget it. */
char tmp[1024];
- while (fgets (tmp, sizeof tmp, stream) != NULL)
+ while (fgets
_unlocked
(tmp, sizeof tmp, stream) != NULL)
if (strchr (tmp, '\n') != NULL)
break;
}
if (strchr (tmp, '\n') != NULL)
break;
}
@@
-92,6
+101,7
@@
__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
mp->mnt_passno = 0;
case 2:
}
mp->mnt_passno = 0;
case 2:
}
+ funlockfile (stream);
return mp;
}
return mp;
}
@@
-127,10
+137,11
@@
__hasmntopt (const struct mntent *mnt, const char *opt)
while ((p = strstr (rest, opt)) != NULL)
{
while ((p = strstr (rest, opt)) != NULL)
{
- if (p == rest || p[-1] == ',' &&
- (p[optlen] == '\0' ||
- p[optlen] == '=' ||
- p[optlen] == ','))
+ if (p == rest
+ || (p[-1] == ','
+ && (p[optlen] == '\0' ||
+ p[optlen] == '=' ||
+ p[optlen] == ',')))
return p;
rest = strchr (rest, ',');
return p;
rest = strchr (rest, ',');