[patches] slicing into manageable chunks, corrections, untangling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In the first of the attached patches there is probably a better way
than to use 'if (what == "current")' -- and I don't even know whether
this works.  :)  But the intent should be clear.

In the fifth patch, I would have liked to also slice up the help text
of fdisk into three manageable chunks, but I don't know how to do
that in the current string assignment.

(I am limited to webmail for the moment, so cannot send a patch
as a single mail.)

Regards,

Benno

-- 
http://www.fastmail.fm - The way an email service should be

From 2fa76bab3a6b55367a64fda6c244f9cf80c26f60 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 19:47:08 +0200
Subject: [PATCH 1/6] chrt: change two messages into four translatable sentences

In several languages the translations for "current" and "new" will
have to be slightly different depending on whether they apply to
"policy" or "priority".  (As a general rule, translatable messages
should be full sentences, and not partial ones with optional words
filled in via %s.)

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 schedutils/chrt.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index cc40013..878eaec 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -93,7 +93,11 @@ static void show_rt_info(const char *what, pid_t pid)
 	if (policy == -1)
 		err(EXIT_FAILURE, _("failed to get pid %d's policy"), pid);
 
-	printf(_("pid %d's %s scheduling policy: "), pid, what);
+	if (what == "current")
+		printf(_("pid %d's current scheduling policy: "), pid);
+	else
+		printf(_("pid %d's new scheduling policy: "), pid);
+
 	switch (policy) {
 	case SCHED_OTHER:
 		printf("SCHED_OTHER\n");
@@ -131,8 +135,12 @@ static void show_rt_info(const char *what, pid_t pid)
 	if (sched_getparam(pid, &sp))
 		err(EXIT_FAILURE, _("failed to get pid %d's attributes"), pid);
 
-	printf(_("pid %d's %s scheduling priority: %d\n"),
-		pid, what, sp.sched_priority);
+	if (what == "current")
+		printf(_("pid %d's current scheduling priority: %d\n"),
+		       pid, sp.sched_priority);
+	else
+		printf(_("pid %d's new scheduling priority: %d\n"),
+		       pid, sp.sched_priority);
 }
 
 static void show_min_max(void)
@@ -247,7 +255,7 @@ int main(int argc, char *argv[])
 		show_usage(EXIT_FAILURE);
 
 	if ((pid > -1) && (verbose || argc - optind == 1)) {
-		show_rt_info(_("current"), pid);
+		show_rt_info("current", pid);
 		if (argc - optind == 1)
 			return EXIT_SUCCESS;
 	}
@@ -274,7 +282,7 @@ int main(int argc, char *argv[])
 		err(EXIT_FAILURE, _("failed to set pid %d's policy"), pid);
 
 	if (verbose)
-		show_rt_info(_("new"), pid);
+		show_rt_info("new", pid);
 
 	if (!pid) {
 		argv += optind + 1;
-- 
1.6.3.3

From 1681fe0902ace5ede667a0d0dc7e63973f1e6f65 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 20:03:21 +0200
Subject: [PATCH 2/6] chrt: slice help text into manageable chunks for translators

And BTW, translatable messages cannot contain #ifdef parts.

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 schedutils/chrt.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 878eaec..3901a3e 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -55,25 +55,28 @@
 static void show_usage(int rc)
 {
 	fprintf(stdout, _(
-	"\nchrt - manipulate real-time attributes of a process.\n"
+	"\nchrt - manipulate real-time attributes of a process\n"
 	"\nSet policy:\n"
 	"  chrt [options] <policy> <priority> {<pid> | <command> [<arg> ...]}\n"
 	"\nGet policy:\n"
-	"  chrt [options] {<pid> | <command> [<arg> ...]}\n\n"
+	"  chrt [options] {<pid> | <command> [<arg> ...]}\n\n"));
+	fprintf(stdout, _(
 	"\nScheduling policies:\n"
 	"  -b | --batch         set policy to SCHED_BATCH\n"
 	"  -f | --fifo          set policy to SCHED_FIFO\n"
 	"  -i | --idle          set policy to SCHED_IDLE\n"
 	"  -o | --other         set policy to SCHED_OTHER\n"
-	"  -r | --rr            set policy to SCHED_RR (default)\n"
+	"  -r | --rr            set policy to SCHED_RR (default)\n"));
 #ifdef SCHED_RESET_ON_FORK
+	fprintf(stdout, _(
 	"\nScheduling flags:\n"
-	"  -R | --reset-on-fork set SCHED_RESET_ON_FORK for FIFO or RR\n"
+	"  -R | --reset-on-fork set SCHED_RESET_ON_FORK for FIFO or RR\n"));
 #endif
+	fprintf(stdout, _(
 	"\nOptions:\n"
 	"  -h | --help          display this help\n"
-	"  -p | --pid           operate on existing given pid\n"
 	"  -m | --max           show min and max valid priorities\n"
+	"  -p | --pid           operate on existing given pid\n"
 	"  -v | --verbose       display status information\n"
 	"  -V | --version       output version information\n\n"));
 
-- 
1.6.3.3

From 03af8647b4db42876c4eaed9e032bfb1d14ec8b6 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 20:07:37 +0200
Subject: [PATCH 3/6] chrt: add --verbose to man page, correct -V for --version, alphabetize

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 schedutils/chrt.1 |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/schedutils/chrt.1 b/schedutils/chrt.1
index 9016cfe..d903df2 100644
--- a/schedutils/chrt.1
+++ b/schedutils/chrt.1
@@ -25,7 +25,7 @@
 .\" 2002-05-11 Robert Love <rml@xxxxxxxxx>
 .\" 	Initial version
 .\"
-.TH CHRT "1" "Apr 2003" "schedutils" "Linux User's Manual"
+.TH CHRT "1" "June 2010" "schedutils" "Linux User's Manual"
 .SH NAME
 chrt \- manipulate real-time attributes of a process
 .SH SYNOPSIS
@@ -40,7 +40,7 @@ chrt \- manipulate real-time attributes of a process
 .SH DESCRIPTION
 .PP
 .BR chrt (1)
-sets or retrieves the real-time scheduling attributes of an existing PID or
+sets or retrieves the real-time scheduling attributes of an existing PID, or
 runs COMMAND with the given attributes.  Both policy (one of
 .BR SCHED_OTHER ,
 .BR SCHED_FIFO ,
@@ -74,15 +74,6 @@ set scheduling policy to
 set scheduling policy to
 .BR SCHED_FIFO
 .TP
-.B -R, --reset-on-fork
-add
-.B SCHED_RESET_ON_FORK
-flag to the
-.B SCHED_FIFO
-or
-.B SCHED_RR
-scheduling policy (Linux specific)
-.TP
 .B -i, --idle
 set schedulng policy to
 .BR SCHED_IDLE
@@ -100,11 +91,23 @@ set scheduling policy to
 .BR SCHED_RR
 (the default)
 .TP
+.B -R, --reset-on-fork
+add
+.B SCHED_RESET_ON_FORK
+flag to the
+.B SCHED_FIFO
+or
+.B SCHED_RR
+scheduling policy (Linux specific)
+.TP
+.B -v, --verbose
+show status information
+.TP
 .B -h, --help
 display usage information and exit
 .TP
-.B -v, --version
-output version information and exit
+.B -V, --version
+display version information and exit
 .SH USAGE
 .TP
 The default behavior is to run a new command::
-- 
1.6.3.3

From d5e7dd17f389038505b39cb1ad4975e7fcce219e Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 20:08:50 +0200
Subject: [PATCH 4/6] fdisk: untangle the reporting of deprecated mode and unit

Translatable messages should not be split into parts that are
conditionally concatenated.  Preferably they should each form
a complete message.

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 fdisk/fdisk.c |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 0126e67..3d2b191 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -796,18 +796,11 @@ warn_alignment(void) {
 "the physical sector size. Aligning to a physical sector (or optimal\n"
 "I/O) size boundary is recommended, or performance may be impacted.\n"));
 
-	if (dos_compatible_flag) {
+	if (dos_compatible_flag)
 		fprintf(stderr, _("\n"
 "WARNING: DOS-compatible mode is deprecated. It's strongly recommended to\n"
-"         switch off the mode (command 'c')"));
-
-		if (display_in_cyl_units)
-			fprintf(stderr, _(" and change display units to\n"
-"         sectors (command 'u').\n"));
-		else
-			fprintf(stderr, ".\n");
-
-	 } else if (display_in_cyl_units)
+"         switch off the mode (with command 'c')."));
+	if (display_in_cyl_units)
 		fprintf(stderr, _("\n"
 "WARNING: cylinders as display units are deprecated. Use command 'u' to\n"
 "         change units to sectors.\n"));
-- 
1.6.3.3

From dd34a7ab0099df9209e4fdec4bb789e402175467 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 20:11:27 +0200
Subject: [PATCH 5/6] fdisk: remove erroneous <size> argument from -u option in help text

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 fdisk/fdisk.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 3d2b191..f019635 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -261,9 +261,9 @@ void fatal(enum failure why) {
 "\nOptions:\n"
 " -b <size>                 sector size (512, 1024, 2048 or 4096)\n"
 " -c                        switch off DOS-compatible mode\n"
-" -h                        print help\n"
-" -u <size>                 give sizes in sectors instead of cylinders\n"
-" -v                        print version\n"
+" -h                        print this help text\n"
+" -u                        show sizes in sectors instead of cylinders\n"
+" -v                        print program version\n"
 " -C <number>               specify the number of cylinders\n"
 " -H <number>               specify the number of heads\n"
 " -S <number>               specify the number of sectors per track\n"
-- 
1.6.3.3

From 0e8c36acf85d37691ee20ff55b7cd61f33637e42 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 20:12:56 +0200
Subject: [PATCH 6/6] lscpu: fix typo, "faild" to "failed"

Signed-off-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
---
 sys-utils/lscpu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 72d1054..a2401c7 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -260,7 +260,7 @@ path_cpuset(const char *path, ...)
 		err(EXIT_FAILURE, _("failed to callocate cpu set"));
 
 	if (cpumask_parse(buf, set, setsize))
-		errx(EXIT_FAILURE, _("faild to parse CPU mask %s"), buf);
+		errx(EXIT_FAILURE, _("failed to parse CPU mask %s"), buf);
 
 	return set;
 }
-- 
1.6.3.3


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux