flock: add NLS support, remove tailing white-spaces
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
56d23414c1
commit
db1749cf6c
|
@ -40,6 +40,8 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include "nls.h"
|
||||||
|
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{ "shared", 0, NULL, 's' },
|
{ "shared", 0, NULL, 's' },
|
||||||
{ "exclusive", 0, NULL, 'x' },
|
{ "exclusive", 0, NULL, 'x' },
|
||||||
|
@ -60,7 +62,7 @@ static void usage(int ex)
|
||||||
{
|
{
|
||||||
fputs("flock (" PACKAGE_STRING ")\n", stderr);
|
fputs("flock (" PACKAGE_STRING ")\n", stderr);
|
||||||
fprintf(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 #] file [-c] command...\n"
|
||||||
" %1$s [-sxon][-w #] directory [-c] command...\n"
|
" %1$s [-sxon][-w #] directory [-c] command...\n"
|
||||||
" -s --shared Get a shared lock\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"
|
" -o --close Close file descriptor before running command\n"
|
||||||
" -c --command Run a single command string through the shell\n"
|
" -c --command Run a single command string through the shell\n"
|
||||||
" -h --help Display this text\n"
|
" -h --help Display this text\n"
|
||||||
" -V --version Display version\n",
|
" -V --version Display version\n"),
|
||||||
program);
|
program);
|
||||||
exit(ex);
|
exit(ex);
|
||||||
}
|
}
|
||||||
|
@ -134,6 +136,10 @@ int main(int argc, char *argv[])
|
||||||
const char *filename = NULL;
|
const char *filename = NULL;
|
||||||
struct sigaction sa, old_sa;
|
struct sigaction sa, old_sa;
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
|
textdomain(PACKAGE);
|
||||||
|
|
||||||
program = argv[0];
|
program = argv[0];
|
||||||
|
|
||||||
if ( argc < 2 )
|
if ( argc < 2 )
|
||||||
|
@ -183,7 +189,7 @@ int main(int argc, char *argv[])
|
||||||
!strcmp(argv[optind+1], "--command") ) {
|
!strcmp(argv[optind+1], "--command") ) {
|
||||||
|
|
||||||
if ( argc != optind+3 ) {
|
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]);
|
program, argv[optind+1]);
|
||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +216,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if ( fd < 0 ) {
|
if ( fd < 0 ) {
|
||||||
err = errno;
|
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));
|
program, argv[optind], strerror(err));
|
||||||
exit((err == ENOMEM||err == EMFILE||err == ENFILE) ? EX_OSERR :
|
exit((err == ENOMEM||err == EMFILE||err == ENFILE) ? EX_OSERR :
|
||||||
(err == EROFS||err == ENOSPC) ? EX_CANTCREAT :
|
(err == EROFS||err == ENOSPC) ? EX_CANTCREAT :
|
||||||
|
@ -222,14 +228,14 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
fd = (int)strtol(argv[optind], &eon, 10);
|
fd = (int)strtol(argv[optind], &eon, 10);
|
||||||
if ( *eon || !argv[optind] ) {
|
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);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Bad options */
|
/* Bad options */
|
||||||
|
|
||||||
fprintf(stderr, "%s: requires file descriptor, file or directory\n",
|
fprintf(stderr, _("%s: requires file descriptor, file or directory\n"),
|
||||||
program);
|
program);
|
||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
@ -285,7 +291,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if ( f < 0 ) {
|
if ( f < 0 ) {
|
||||||
err = errno;
|
err = errno;
|
||||||
fprintf(stderr, "%s: fork: %s\n", program, strerror(err));
|
fprintf(stderr, _("%s: fork failed: %s\n"), program, strerror(err));
|
||||||
exit(EX_OSERR);
|
exit(EX_OSERR);
|
||||||
} else if ( f == 0 ) {
|
} else if ( f == 0 ) {
|
||||||
if ( do_close )
|
if ( do_close )
|
||||||
|
|
Loading…
Reference in New Issue