0002-localedef-fix-ups-hardlink-to-make-it-compile.patch 8.8 KB

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