From e485e80b512f17aba0b6b1dd5acc3f738f4189c1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 04:20:54 +0000 Subject: r7743: be consistent in how stdin is supported for ldbadd and ldbmodify (This used to be commit 3d60b3a8eea5ac6c35cf2e579ae12cef3dc1794e) --- source4/lib/ldb/tools/ldbmodify.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'source4/lib/ldb/tools') diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index 8fa0dcf0b6..901a4c9628 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -101,25 +101,17 @@ static int process_file(struct ldb_context *ldb, FILE *f) options = ldb_cmdline_process(ldb, argc, argv, usage); if (options->argc == 0) { - usage(); - exit(1); - } - - for (i=0;iargc;i++) { - const char *fname = options->argv[i]; - FILE *f; - if (strcmp(fname,"-") == 0) { - f = stdin; - } else { + count += process_file(ldb, stdin); + } else { + for (i=0;iargc;i++) { + const char *fname = options->argv[i]; + FILE *f; f = fopen(fname, "r"); - } - if (!f) { - perror(fname); - exit(1); - } - count += process_file(ldb, f); - if (f != stdin) { - fclose(f); + if (!f) { + perror(fname); + exit(1); + } + count += process_file(ldb, f); } } -- cgit