summaryrefslogtreecommitdiff
path: root/setfattr
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2005-02-22 02:49:39 +0000
committerNathan Scott <nathans@sgi.com>2005-02-22 02:49:39 +0000
commitc9017cd8e22a9d70f5ba105fc7d03c3ed24d49b4 (patch)
treef6f6199262916dc1aaced5a3641a465da896e2a0 /setfattr
parent3af9ec3b25013fbec25e53693fa9fe37bff739ca (diff)
downloadattr-c9017cd8e22a9d70f5ba105fc7d03c3ed24d49b4.tar.gz
Updated next_line fix from AndreasG
Merge of master-melb:xfs-cmds:21594a by kenmcd.
Diffstat (limited to 'setfattr')
-rw-r--r--setfattr/setfattr.c51
1 files changed, 9 insertions, 42 deletions
diff --git a/setfattr/setfattr.c b/setfattr/setfattr.c
index 6f5deaa..519d423 100644
--- a/setfattr/setfattr.c
+++ b/setfattr/setfattr.c
@@ -61,7 +61,6 @@ const char *progname;
int do_set(const char *path, const char *name, const char *value);
const char *decode(const char *value, size_t *size);
int restore(const char *filename);
-char *next_line(FILE *file);
int hex_digit(char c);
int base64_digit(char c);
@@ -149,8 +148,15 @@ int restore(const char *filename)
*value++ = '\0';
status = do_set(path, unquote(name), value);
}
- if (l != NULL)
- line++;
+ if (l == NULL)
+ break;
+ line++;
+ }
+ if (!feof(file)) {
+ fprintf(stderr, "%s: %s: %s\n", progname, filename,
+ strerror(errno));
+ if (!status)
+ status = 1;
}
cleanup:
@@ -178,45 +184,6 @@ void help(void)
" --help this help text\n"));
}
-char *next_line(FILE *file)
-{
- static char *line;
- static size_t line_size;
- char *c;
- int eol = 0;
-
- if (!line) {
- if (high_water_alloc((void **)&line, &line_size, PATH_MAX)) {
- perror(progname);
- had_errors++;
- return NULL;
- }
- }
- c = line;
- do {
- if (!fgets(c, line_size - (c - line), file))
- return NULL;
- c = strrchr(c, '\0');
- while (c > line && (*(c-1) == '\n' || *(c-1) == '\r')) {
- c--;
- *c = '\0';
- eol = 1;
- }
- if (feof(file))
- break;
- if (!eol) {
- if (high_water_alloc((void **)&line, &line_size,
- 2 * line_size)) {
- perror(progname);
- had_errors++;
- return NULL;
- }
- c = strrchr(line, '\0');
- }
- } while (!eol);
- return line;
-}
-
int main(int argc, char *argv[])
{
int opt;