Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame^] | 1 | From 85d14ae38fb9e7b46bb4b8f5f041e39a605ed81e Mon Sep 17 00:00:00 2001 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2 | From: Jason Wessel <jason.wessel@windriver.com> |
| 3 | Date: Sat, 7 Dec 2019 10:01:37 -0800 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 4 | Subject: [PATCH] localedef: fix-ups hardlink to make it compile |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 5 | |
| 6 | Upstream-Status: Pending |
| 7 | Signed-off-by: Jason Wessel <jason.wessel@windriver.com> |
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 9 | --- |
| 10 | locale/programs/c.h | 2 +- |
| 11 | locale/programs/cross-localedef-hardlink.c | 79 +++++++++++----------- |
| 12 | 2 files changed, 39 insertions(+), 42 deletions(-) |
| 13 | |
| 14 | diff --git a/locale/programs/c.h b/locale/programs/c.h |
| 15 | index d0a402e90e..1804d31c73 100644 |
| 16 | --- a/locale/programs/c.h |
| 17 | +++ b/locale/programs/c.h |
| 18 | @@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...) |
| 19 | /* Don't use inline function to avoid '#include "nls.h"' in c.h |
| 20 | */ |
| 21 | #define errtryhelp(eval) __extension__ ({ \ |
| 22 | - fprintf(stderr, _("Try '%s --help' for more information.\n"), \ |
| 23 | + fprintf(stderr, ("Try '%s --help' for more information.\n"), \ |
| 24 | program_invocation_short_name); \ |
| 25 | exit(eval); \ |
| 26 | }) |
| 27 | diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c |
| 28 | index 63615896b0..726e6dd948 100644 |
| 29 | --- a/locale/programs/cross-localedef-hardlink.c |
| 30 | +++ b/locale/programs/cross-localedef-hardlink.c |
| 31 | @@ -20,6 +20,8 @@ |
| 32 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 33 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 34 | */ |
| 35 | + |
| 36 | +#undef HAVE_PCRE |
| 37 | #include <sys/types.h> |
| 38 | #include <stdlib.h> |
| 39 | #include <getopt.h> |
| 40 | @@ -38,8 +40,8 @@ |
| 41 | |
| 42 | #include "c.h" |
| 43 | #include "xalloc.h" |
| 44 | -#include "nls.h" |
| 45 | -#include "closestream.h" |
| 46 | +//#include "nls.h" |
| 47 | +//#include "closestream.h" |
| 48 | |
| 49 | #define NHASH (1<<17) /* Must be a power of 2! */ |
| 50 | #define NBUF 64 |
| 51 | @@ -124,33 +126,33 @@ static void print_summary(void) |
| 52 | if (ctl->verbose > 1 && ctl->nlinks) |
| 53 | fputc('\n', stdout); |
| 54 | |
| 55 | - printf(_("Directories: %9lld\n"), ctl->ndirs); |
| 56 | - printf(_("Objects: %9lld\n"), ctl->nobjects); |
| 57 | - printf(_("Regular files: %9lld\n"), ctl->nregfiles); |
| 58 | - printf(_("Comparisons: %9lld\n"), ctl->ncomp); |
| 59 | + printf(("Directories: %9lld\n"), ctl->ndirs); |
| 60 | + printf(("Objects: %9lld\n"), ctl->nobjects); |
| 61 | + printf(("Regular files: %9lld\n"), ctl->nregfiles); |
| 62 | + printf(("Comparisons: %9lld\n"), ctl->ncomp); |
| 63 | printf( "%s%9lld\n", (ctl->no_link ? |
| 64 | - _("Would link: ") : |
| 65 | - _("Linked: ")), ctl->nlinks); |
| 66 | + ("Would link: ") : |
| 67 | + ("Linked: ")), ctl->nlinks); |
| 68 | printf( "%s %9lld\n", (ctl->no_link ? |
| 69 | - _("Would save: ") : |
| 70 | - _("Saved: ")), ctl->nsaved); |
| 71 | + ("Would save: ") : |
| 72 | + ("Saved: ")), ctl->nsaved); |
| 73 | } |
| 74 | |
| 75 | static void __attribute__((__noreturn__)) usage(void) |
| 76 | { |
| 77 | fputs(USAGE_HEADER, stdout); |
| 78 | - printf(_(" %s [options] directory...\n"), program_invocation_short_name); |
| 79 | + printf((" %s [options] directory...\n"), program_invocation_short_name); |
| 80 | |
| 81 | fputs(USAGE_SEPARATOR, stdout); |
| 82 | - puts(_("Consolidate duplicate files using hardlinks.")); |
| 83 | + puts(("Consolidate duplicate files using hardlinks.")); |
| 84 | |
| 85 | fputs(USAGE_OPTIONS, stdout); |
| 86 | - puts(_(" -c, --content compare only contents, ignore permission, etc.")); |
| 87 | - puts(_(" -n, --dry-run don't actually link anything")); |
| 88 | - puts(_(" -v, --verbose print summary after hardlinking")); |
| 89 | - puts(_(" -vv print every hardlinked file and summary")); |
| 90 | - puts(_(" -f, --force force hardlinking across filesystems")); |
| 91 | - puts(_(" -x, --exclude <regex> exclude files matching pattern")); |
| 92 | + puts((" -c, --content compare only contents, ignore permission, etc.")); |
| 93 | + puts((" -n, --dry-run don't actually link anything")); |
| 94 | + puts((" -v, --verbose print summary after hardlinking")); |
| 95 | + puts((" -vv print every hardlinked file and summary")); |
| 96 | + puts((" -f, --force force hardlinking across filesystems")); |
| 97 | + puts((" -x, --exclude <regex> exclude files matching pattern")); |
| 98 | |
| 99 | fputs(USAGE_SEPARATOR, stdout); |
| 100 | printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ |
| 101 | @@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size_t b) |
| 102 | size_t sum = a + b; |
| 103 | |
| 104 | if (sum < a) |
| 105 | - errx(EXIT_FAILURE, _("integer overflow")); |
| 106 | + errx(EXIT_FAILURE, ("integer overflow")); |
| 107 | return sum; |
| 108 | } |
| 109 | |
| 110 | @@ -193,7 +195,7 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) |
| 111 | if (st.st_dev != ctl->dev && !ctl->force) { |
| 112 | if (ctl->dev) |
| 113 | errx(EXIT_FAILURE, |
| 114 | - _("%s is on different filesystem than the rest " |
| 115 | + ("%s is on different filesystem than the rest " |
| 116 | "(use -f option to override)."), name); |
| 117 | ctl->dev = st.st_dev; |
| 118 | } |
| 119 | @@ -287,9 +289,9 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) |
| 120 | (ssize_t) sizeof(ctl->iobuf1) : fsize; |
| 121 | |
| 122 | if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) |
| 123 | - warn(_("cannot read %s"), name); |
| 124 | + warn(("cannot read %s"), name); |
| 125 | else if ((xsz = read(fd2, ctl->iobuf2, rsize)) != rsize) |
| 126 | - warn(_("cannot read %s"), fp2->name); |
| 127 | + warn(("cannot read %s"), fp2->name); |
| 128 | |
| 129 | if (xsz != rsize) { |
| 130 | close(fd); |
| 131 | @@ -303,13 +305,13 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) |
| 132 | if (fsize > 0) |
| 133 | continue; |
| 134 | if (lstat(name, &st3)) { |
| 135 | - warn(_("cannot stat %s"), name); |
| 136 | + warn(("cannot stat %s"), name); |
| 137 | close(fd); |
| 138 | return; |
| 139 | } |
| 140 | st3.st_atime = st.st_atime; |
| 141 | if (stcmp(&st, &st3, 0)) { |
| 142 | - warnx(_("file %s changed underneath us"), name); |
| 143 | + warnx(("file %s changed underneath us"), name); |
| 144 | close(fd); |
| 145 | return; |
| 146 | } |
| 147 | @@ -329,18 +331,18 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) |
| 148 | suffixlen + 1); |
| 149 | /* First create a temporary link to n1 under a new name */ |
| 150 | if (link(n1, nam2.buf)) { |
| 151 | - warn(_("failed to hardlink %s to %s (create temporary link as %s failed)"), |
| 152 | + warn(("failed to hardlink %s to %s (create temporary link as %s failed)"), |
| 153 | n1, n2, nam2.buf); |
| 154 | free(nam2.buf); |
| 155 | continue; |
| 156 | } |
| 157 | /* Then rename into place over the existing n2 */ |
| 158 | if (rename(nam2.buf, n2)) { |
| 159 | - warn(_("failed to hardlink %s to %s (rename temporary link to %s failed)"), |
| 160 | + warn(("failed to hardlink %s to %s (rename temporary link to %s failed)"), |
| 161 | n1, n2, n2); |
| 162 | /* Something went wrong, try to remove the now redundant temporary link */ |
| 163 | if (unlink(nam2.buf)) |
| 164 | - warn(_("failed to remove temporary link %s"), nam2.buf); |
| 165 | + warn(("failed to remove temporary link %s"), nam2.buf); |
| 166 | free(nam2.buf); |
| 167 | continue; |
| 168 | } |
| 169 | @@ -351,16 +353,16 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) |
| 170 | /* We actually did not save anything this time, since the link second argument |
| 171 | had some other links as well. */ |
| 172 | if (ctl->verbose > 1) |
| 173 | - printf(_(" %s %s to %s\n"), |
| 174 | - (ctl->no_link ? _("Would link") : _("Linked")), |
| 175 | + printf((" %s %s to %s\n"), |
| 176 | + (ctl->no_link ? ("Would link") : ("Linked")), |
| 177 | n1, n2); |
| 178 | } else { |
| 179 | ctl->nsaved += ((st.st_size + 4095) / 4096) * 4096; |
| 180 | if (ctl->verbose > 1) |
| 181 | - printf(_(" %s %s to %s, %s %jd\n"), |
| 182 | - (ctl->no_link ? _("Would link") : _("Linked")), |
| 183 | + printf((" %s %s to %s, %s %jd\n"), |
| 184 | + (ctl->no_link ? ("Would link") : ("Linked")), |
| 185 | n1, n2, |
| 186 | - (ctl->no_link ? _("would save") : _("saved")), |
| 187 | + (ctl->no_link ? ("would save") : ("saved")), |
| 188 | (intmax_t)st.st_size); |
| 189 | } |
| 190 | close(fd); |
| 191 | @@ -410,11 +412,6 @@ int main(int argc, char **argv) |
| 192 | { NULL, 0, NULL, 0 }, |
| 193 | }; |
| 194 | |
| 195 | - setlocale(LC_ALL, ""); |
| 196 | - bindtextdomain(PACKAGE, LOCALEDIR); |
| 197 | - textdomain(PACKAGE); |
| 198 | - close_stdout_atexit(); |
| 199 | - |
| 200 | while ((ch = getopt_long(argc, argv, "cnvfx:Vh", longopts, NULL)) != -1) { |
| 201 | switch (ch) { |
| 202 | case 'n': |
| 203 | @@ -434,7 +431,7 @@ int main(int argc, char **argv) |
| 204 | exclude_pattern = (PCRE2_SPTR) optarg; |
| 205 | #else |
| 206 | errx(EXIT_FAILURE, |
| 207 | - _("option --exclude not supported (built without pcre2)")); |
| 208 | + ("option --exclude not supported (built without pcre2)")); |
| 209 | #endif |
| 210 | break; |
| 211 | case 'V': |
| 212 | @@ -447,7 +444,7 @@ int main(int argc, char **argv) |
| 213 | } |
| 214 | |
| 215 | if (optind == argc) { |
| 216 | - warnx(_("no directory specified")); |
| 217 | + warnx(("no directory specified")); |
| 218 | errtryhelp(EXIT_FAILURE); |
| 219 | } |
| 220 | |
| 221 | @@ -461,7 +458,7 @@ int main(int argc, char **argv) |
| 222 | PCRE2_UCHAR buffer[256]; |
| 223 | pcre2_get_error_message(errornumber, buffer, |
| 224 | sizeof(buffer)); |
| 225 | - errx(EXIT_FAILURE, _("pattern error at offset %d: %s"), |
| 226 | + errx(EXIT_FAILURE, ("pattern error at offset %d: %s"), |
| 227 | (int)erroroffset, buffer); |
| 228 | } |
| 229 | match_data = pcre2_match_data_create_from_pattern(re, NULL); |
| 230 | @@ -506,7 +503,7 @@ int main(int argc, char **argv) |
| 231 | >=0) { |
| 232 | if (ctl->verbose) { |
| 233 | nam1.buf[nam1baselen] = 0; |
| 234 | - printf(_("Skipping %s%s\n"), nam1.buf, di->d_name); |
| 235 | + printf(("Skipping %s%s\n"), nam1.buf, di->d_name); |
| 236 | } |
| 237 | continue; |
| 238 | } |