From 7ce2589b77d6f78548d6d025ab7d8f5a57199ef8 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Wed, 2 Nov 2016 23:56:53 +0000 Subject: maint: refactor printing of backup suffix --help * src/system.h (emit_backup_suffix_note): A new function to output the backup suffix info. The strings are unchanged, so translations are not impacted. * src/cp.c (usage): Use the new function. * src/ln.c (usage): Likewise. * src/mv.c (usage): Likewise. * src/install.c (usage): Likewise. --- src/cp.c | 14 +------------- src/install.c | 14 +------------- src/ln.c | 14 +------------- src/mv.c | 14 +------------- src/system.h | 18 ++++++++++++++++++ 5 files changed, 22 insertions(+), 52 deletions(-) diff --git a/src/cp.c b/src/cp.c index 79b93bd8e..97a868a53 100644 --- a/src/cp.c +++ b/src/cp.c @@ -250,19 +250,7 @@ When --reflink[=always] is specified, perform a lightweight copy, where the\n\ data blocks are copied only when modified. If this is not possible the copy\n\ fails, or if --reflink=auto is specified, fall back to a standard copy.\n\ "), stdout); - fputs (_("\ -\n\ -The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ -The version control method may be selected via the --backup option or through\n\ -the VERSION_CONTROL environment variable. Here are the values:\n\ -\n\ -"), stdout); - fputs (_("\ - none, off never make backups (even if --backup is given)\n\ - numbered, t make numbered backups\n\ - existing, nil numbered if numbered backups exist, simple otherwise\n\ - simple, never always make simple backups\n\ -"), stdout); + emit_backup_suffix_note (); fputs (_("\ \n\ As a special case, cp makes a backup of SOURCE when the force and backup\n\ diff --git a/src/install.c b/src/install.c index b4b282aae..4fa4bb3d3 100644 --- a/src/install.c +++ b/src/install.c @@ -681,19 +681,7 @@ In the 4th form, create all components of the given DIRECTORY(ies).\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\ -\n\ -The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ -The version control method may be selected via the --backup option or through\n\ -the VERSION_CONTROL environment variable. Here are the values:\n\ -\n\ -"), stdout); - fputs (_("\ - none, off never make backups (even if --backup is given)\n\ - numbered, t make numbered backups\n\ - existing, nil numbered if numbered backups exist, simple otherwise\n\ - simple, never always make simple backups\n\ -"), stdout); + emit_backup_suffix_note (); emit_ancillary_info (PROGRAM_NAME); } exit (status); diff --git a/src/ln.c b/src/ln.c index 0b8eb219b..2a56dc973 100644 --- a/src/ln.c +++ b/src/ln.c @@ -436,19 +436,7 @@ interpreted in relation to its parent directory.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\ -\n\ -The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ -The version control method may be selected via the --backup option or through\n\ -the VERSION_CONTROL environment variable. Here are the values:\n\ -\n\ -"), stdout); - fputs (_("\ - none, off never make backups (even if --backup is given)\n\ - numbered, t make numbered backups\n\ - existing, nil numbered if numbered backups exist, simple otherwise\n\ - simple, never always make simple backups\n\ -"), stdout); + emit_backup_suffix_note (); printf (_("\ \n\ Using -s ignores -L and -P. Otherwise, the last option specified controls\n\ diff --git a/src/mv.c b/src/mv.c index 35b2e929f..6a3d0d277 100644 --- a/src/mv.c +++ b/src/mv.c @@ -323,19 +323,7 @@ If you specify more than one of -i, -f, -n, only the final one takes effect.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\ -\n\ -The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ -The version control method may be selected via the --backup option or through\n\ -the VERSION_CONTROL environment variable. Here are the values:\n\ -\n\ -"), stdout); - fputs (_("\ - none, off never make backups (even if --backup is given)\n\ - numbered, t make numbered backups\n\ - existing, nil numbered if numbered backups exist, simple otherwise\n\ - simple, never always make simple backups\n\ -"), stdout); + emit_backup_suffix_note (); emit_ancillary_info (PROGRAM_NAME); } exit (status); diff --git a/src/system.h b/src/system.h index 1b7a0fbb3..e82dce498 100644 --- a/src/system.h +++ b/src/system.h @@ -608,6 +608,24 @@ Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).\n\ "), program); } +static inline void +emit_backup_suffix_note (void) +{ + fputs (_("\ +\n\ +The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\ +The version control method may be selected via the --backup option or through\n\ +the VERSION_CONTROL environment variable. Here are the values:\n\ +\n\ +"), stdout); + fputs (_("\ + none, off never make backups (even if --backup is given)\n\ + numbered, t make numbered backups\n\ + existing, nil numbered if numbered backups exist, simple otherwise\n\ + simple, never always make simple backups\n\ +"), stdout); +} + static inline void emit_ancillary_info (char const *program) { -- cgit v1.2.3-70-g09d2