hwclock: Fix --date debug messages
PATCH 4/5 hwclock: Fix --date debug messages
Fix --date debug messages with:
* Empty results for invalid arguments
* Empty lines(superfluous line breaks)
* Uncapitalized and missing words
* Inconsistent language
* Outdated message:
--date is now used for --predict so
'cannot set clock' makes no sense.
--- sys-utils/hwclock.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
sys-utils/hwclock.c +9 -13
@@ -765,15 +765,14 @@ static int interpret_date_string(const char *date_opt, time_t * const time_p) }if (!fgets (date_resp,sizeof (date_resp), date_child_fp)) - date_resp[0 ] ='\0' ;/* in case fgets fails */ +strcpy (date_resp,"NULL\n" );/* in case fgets fails */ if (debug) -printf (_ ("response from date command = %s" ), date_resp); +printf (_ ("The response was: %s" ), date_resp);if (strncmp (date_resp, magic,sizeof (magic) -1 ) !=0 ) {warnx (_ ("The date command issued by %s returned " -"unexpected results\n" -"The command was:\n %s\n" -"The response was:\n %s" ), - program_invocation_short_name, date_command, date_resp); +"unexpected results\nThe response was: %s" +"The command was: %s" ), + program_invocation_short_name, date_resp, date_command); retcode =8 ; }else {long seconds_since_epoch;
@@ -783,16 +782,14 @@ static int interpret_date_string(const char *date_opt, time_t * const time_p)warnx (_ ("The date command issued by %s returned " "something other\nthan an integer where the " "converted time value was expected\n" -"The command was:\n %s\n" -"The response was:\n %s\n" ), - program_invocation_short_name, date_command, - date_resp); +"The response was: %sThe command was: %s" ), + program_invocation_short_name, date_resp, date_command); retcode =6 ; }else { retcode =0 ; *time_p = seconds_since_epoch;if (debug) -printf (_ ("date string %s equates to " +printf (_ ("The date string '%s' equates to:\n" "%ld seconds since 1969\n" ), date_opt, (long )*time_p); }
@@ -1905,8 +1902,7 @@ int main(int argc, char **argv) rc =interpret_date_string (date_opt, &set_time);/* (time-consuming) */ if (rc !=0 ) { -warnx (_ ("No usable set-to time, " -"cannot set clock" )); +warnx (_ ("Invalid --date argument, see date(1)" ));hwclock_exit (EX_USAGE ); } }
sys-utils/hwclock.c static int interpret_date_string(const char *date_opt, time_t * const time_p) · line 775
Quoted 12 lines · JWP
sys-utils/hwclock.c +4
-5if (debug) -printf (_ ("response from date command = %s" ), date_resp); +printf (_ ("The response was: %s" ), date_resp);if (strncmp (date_resp, magic,sizeof (magic) -1 ) !=0 ) {warnx (_ ("The date command issued by %s returned " -"unexpected results\n" -"The command was:\n %s\n" -"The response was:\n %s" ), - program_invocation_short_name, date_command, date_resp); +"unexpected results\nThe response was: %s" +"The command was: %s" ), + program_invocation_short_name, date_resp, date_command);
Oh no. If the user does not use --debug, hwclock will warn that a command gave an unexpected result and will print the command but not the actual result. This is silly.
By the way, the --debug flag is improperly named. It should actually be called --verbose, because in all the rest of util-linux debug messages are never gettextized (using calls to _()). The use of --debug is not meant to debug hwclock itself but to debug the user's use of hwclock. It should therefore be called --verbose.
Benno
Signature · 1 line
http://www.fastmail.fm - A fast, anti-spam email service.
Quoted 12 lines · Benno Schulenberg
sys-utils/hwclock.c static int interpret_date_string(const char *date_opt, time_t * const time_p) · line 775
Quoted 7 lines · JWP
sys-utils/hwclock.c +3
-4-"unexpected results\n" -"The command was:\n %s\n" - "The response was:\n %s"), - program_invocation_short_name, date_command, date_resp); +"unexpected results\nThe response was: %s" + "The command was: %s"), + program_invocation_short_name, date_resp, date_command);Oh no. If the user does not use --debug, hwclock will warn that a command gave an unexpected result and will print the command but not the actual result. This is silly.
Sorry, I misread. That's what you get with a \n in the middle of a line.
Benno
Signature · 1 line
http://www.fastmail.fm - Same, same, but different...