flock: add NLS support, remove tailing white-spaces

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2009-03-11 13:34:55 +01:00
parent 56d23414c1
commit db1749cf6c
1 changed files with 24 additions and 18 deletions

View File

@ -40,6 +40,8 @@
#include <sys/time.h>
#include <sys/wait.h>
#include "nls.h"
static const struct option long_options[] = {
{ "shared", 0, NULL, 's' },
{ "exclusive", 0, NULL, 'x' },
@ -60,7 +62,7 @@ static void usage(int ex)
{
fputs("flock (" PACKAGE_STRING ")\n", stderr);
fprintf(stderr,
"Usage: %1$s [-sxun][-w #] fd#\n"
_("Usage: %1$s [-sxun][-w #] fd#\n"
" %1$s [-sxon][-w #] file [-c] command...\n"
" %1$s [-sxon][-w #] directory [-c] command...\n"
" -s --shared Get a shared lock\n"
@ -71,7 +73,7 @@ static void usage(int ex)
" -o --close Close file descriptor before running command\n"
" -c --command Run a single command string through the shell\n"
" -h --help Display this text\n"
" -V --version Display version\n",
" -V --version Display version\n"),
program);
exit(ex);
}
@ -134,6 +136,10 @@ int main(int argc, char *argv[])
const char *filename = NULL;
struct sigaction sa, old_sa;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
program = argv[0];
if ( argc < 2 )
@ -183,7 +189,7 @@ int main(int argc, char *argv[])
!strcmp(argv[optind+1], "--command") ) {
if ( argc != optind+3 ) {
fprintf(stderr, "%s: %s requires exactly one command argument\n",
fprintf(stderr, _("%s: %s requires exactly one command argument\n"),
program, argv[optind+1]);
exit(EX_USAGE);
}
@ -210,7 +216,7 @@ int main(int argc, char *argv[])
if ( fd < 0 ) {
err = errno;
fprintf(stderr, "%s: cannot open lock file %s: %s\n",
fprintf(stderr, _("%s: cannot open lock file %s: %s\n"),
program, argv[optind], strerror(err));
exit((err == ENOMEM||err == EMFILE||err == ENFILE) ? EX_OSERR :
(err == EROFS||err == ENOSPC) ? EX_CANTCREAT :
@ -222,14 +228,14 @@ int main(int argc, char *argv[])
fd = (int)strtol(argv[optind], &eon, 10);
if ( *eon || !argv[optind] ) {
fprintf(stderr, "%s: bad number: %s\n", program, argv[optind]);
fprintf(stderr, _("%s: bad number: %s\n"), program, argv[optind]);
exit(EX_USAGE);
}
} else {
/* Bad options */
fprintf(stderr, "%s: requires file descriptor, file or directory\n",
fprintf(stderr, _("%s: requires file descriptor, file or directory\n"),
program);
exit(EX_USAGE);
}
@ -285,7 +291,7 @@ int main(int argc, char *argv[])
if ( f < 0 ) {
err = errno;
fprintf(stderr, "%s: fork: %s\n", program, strerror(err));
fprintf(stderr, _("%s: fork failed: %s\n"), program, strerror(err));
exit(EX_OSERR);
} else if ( f == 0 ) {
if ( do_close )