tload: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
44f5745d7e
commit
24762e2ed8
33
tload.c
33
tload.c
@ -11,7 +11,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "proc/version.h"
|
#include "proc/version.h"
|
||||||
#include "proc/sysinfo.h"
|
#include "proc/sysinfo.h"
|
||||||
#include <err.h>
|
#include "c.h"
|
||||||
|
#include "nls.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@ -57,7 +59,7 @@ static void setsize(int i)
|
|||||||
screen = (char *)realloc(screen, scr_size);
|
screen = (char *)realloc(screen, scr_size);
|
||||||
|
|
||||||
if (screen == NULL)
|
if (screen == NULL)
|
||||||
err(EXIT_FAILURE, "cannot allocate %zu bytes", scr_size);
|
err(EXIT_FAILURE, _("cannot allocate %zu bytes"), scr_size);
|
||||||
|
|
||||||
memset(screen, ' ', scr_size - 1);
|
memset(screen, ' ', scr_size - 1);
|
||||||
*(screen + scr_size - 2) = '\0';
|
*(screen + scr_size - 2) = '\0';
|
||||||
@ -65,18 +67,17 @@ static void setsize(int i)
|
|||||||
longjmp(jb, 0);
|
longjmp(jb, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__ ((__noreturn__))
|
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
||||||
usage(FILE * out)
|
|
||||||
{
|
{
|
||||||
fprintf(out,
|
fputs(USAGE_HEADER, out);
|
||||||
"\nUsage: %s [options] [tty]\n"
|
fprintf(out, " %s [options] [tty]\n", program_invocation_short_name);
|
||||||
"\nOptions:\n", program_invocation_short_name);
|
fputs(USAGE_OPTIONS, out);
|
||||||
fprintf(out,
|
fputs(_(" -d, --delay <secs> update delay in seconds\n"), out);
|
||||||
" -d, --delay <secs> update delay in seconds\n"
|
fputs(_(" -s, --scale <num> vertical scale\n"), out);
|
||||||
" -s, --scale <num> vertical scale\n"
|
fputs(USAGE_SEPARATOR, out);
|
||||||
" -h, --help display this help text\n"
|
fputs(USAGE_HELP, out);
|
||||||
" -V, --version display version information and exit\n");
|
fputs(USAGE_VERSION, out);
|
||||||
fprintf(out, "\nFor more information see tload(1).\n");
|
fprintf(out, USAGE_MAN_TAIL("tload(1)"));
|
||||||
|
|
||||||
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
@ -106,8 +107,8 @@ int main(int argc, char **argv)
|
|||||||
dly = atoi(optarg);
|
dly = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
display_version();
|
printf(PROCPS_NG_VERSION);
|
||||||
exit(0);
|
return EXIT_SUCCESS;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(stdout);
|
usage(stdout);
|
||||||
@ -117,7 +118,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc > optind)
|
if (argc > optind)
|
||||||
if ((fd = open(argv[optind], 1)) == -1)
|
if ((fd = open(argv[optind], 1)) == -1)
|
||||||
err(EXIT_FAILURE, "can not open tty");
|
err(EXIT_FAILURE, _("can not open tty"));
|
||||||
|
|
||||||
setsize(0);
|
setsize(0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user