X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=busybox-printf-gettext.patch;h=a566ff8811952d7a51fa3dfd312e3b3fc10f1bf8;hb=c574afd9c370699db8b5e76d6a37a3ca4ad4b39d;hp=f6ab56e2b5f82c7febfb6a444cfe2d6d71f9a348;hpb=4c6ebd20987865f52d9e771b36c55077132368a1;p=packages%2Fbusybox.git diff --git a/busybox-printf-gettext.patch b/busybox-printf-gettext.patch index f6ab56e..a566ff8 100644 --- a/busybox-printf-gettext.patch +++ b/busybox-printf-gettext.patch @@ -1,35 +1,21 @@ -diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c ---- busybox-0.60.1/printf.c Mon Mar 19 20:25:49 2001 -+++ busybox-0.60.1.new/printf.c Thu May 31 16:41:31 2001 -@@ -47,6 +47,9 @@ +--- busybox-1.12.2/coreutils/printf.c 2008-09-28 20:04:18.000000000 +0200 ++++ busybox-1.12.2.patch/coreutils/printf.c 2008-11-19 13:00:54.187842550 +0100 +@@ -38,6 +38,9 @@ // 19990508 Busy Boxed! Dave Cinege +// on by default +#define BB_FEATURE_PRINTF_GETTEXT + - #include - #include - #include -@@ -55,6 +58,11 @@ - #include - #include - #include -+#include -+#include -+#include -+#include -+#include - #include "busybox.h" + #include "libbb.h" + /* A note on bad input: neither bash 3.2 nor coreutils 6.10 stop on it. +@@ -334,10 +337,131 @@ + return argv; + } -@@ -117,19 +125,140 @@ - /* The value to return to the calling program. */ - static int exit_status; - -+ +/* -+ * Very pure gettext added by Michal Moskal ++ * Very pure gettext added by Michal Moskal + * This possibly could be converted into utility function + * and used in other places as well. + */ @@ -67,12 +53,10 @@ diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c + +static u_int32_t swap(u_int32_t i) +{ -+ return (i << 24) | ((i & 0xff00) << 8) | -+ ((i >> 8) & 0xff00) | (i >> 24); ++ return (i << 24) | ((i & 0xff00) << 8) | ++ ((i >> 8) & 0xff00) | (i >> 24); +} -+ +#define swap_if(a) ((has_to_swap) ? swap(a) : (a)) -+ +static char *getmsg(const char *filename, const char *msgid) +{ + int fd; @@ -83,7 +67,7 @@ diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c + struct string_desc *orig_tab, *trans_tab = NULL; + int act = -1; + char *ret = (char*)msgid; -+ ++ + if (filename == NULL || stat(filename, &st)) + return ret; + @@ -92,7 +76,7 @@ diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c + return ret; + + ptr = (struct mo_file_header *) mmap(NULL, st.st_size, PROT_READ, -+ MAP_PRIVATE, fd, 0); ++ MAP_PRIVATE, fd, 0); + close(fd); + + if (ptr == (void*)-1) @@ -106,19 +90,18 @@ diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c + /* FIXME: use hash table */ + + orig_tab = (struct string_desc *) -+ ((char *) ptr + swap_if(ptr->orig_tab_offset)); ++ ((char *) ptr + swap_if(ptr->orig_tab_offset)); + trans_tab = (struct string_desc *) -+ ((char *) ptr + swap_if(ptr->trans_tab_offset)); ++ ((char *) ptr + swap_if(ptr->trans_tab_offset)); + + bottom = 0; + top = swap_if(ptr->nstrings); + while (bottom < top) { + int cmp_val; -+ + act = (bottom + top) / 2; + cmp_val = -+ strcmp(msgid, -+ ((char *) ptr + swap_if(orig_tab[act].offset))); ++ strcmp(msgid, ++ ((char *) ptr + swap_if(orig_tab[act].offset))); + if (cmp_val < 0) + top = act; + else if (cmp_val > 0) @@ -128,7 +111,7 @@ diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c + act = -1; + } + -+ oops: ++oops: + if (act != -1) + ret = strdup(((char *) ptr + swap_if(trans_tab[act].offset))); + munmap(ptr, st.st_size); @@ -138,35 +121,35 @@ diff -ur busybox-0.60.1/printf.c busybox-0.60.1.new/printf.c +# define getmsg(a,b) (b) +#endif + - int printf_main(int argc, char **argv) + int printf_main(int argc UNUSED_PARAM, char **argv) { char *format; - int args_used; + char **argv2; + int opt; + const char *nls_file = NULL; - - exit_status = 0; -- if (argc <= 1 || **(argv + 1) == '-') { -- show_usage(); -- } - -- format = argv[1]; -- argc -= 2; -- argv += 2; ++ + while ((opt = getopt(argc, argv, "n:")) != -1) + switch (opt) { -+ case 'n': -+ nls_file = optarg; -+ break; -+ default: -+ show_usage(); -+ break; ++ case 'n': ++ nls_file = optarg; ++ break; ++ default: ++ bb_show_usage(); ++ break; + } + + format = getmsg(nls_file, argv[optind++]); -+ -+ argc -= optind; -+ argv += optind; + + /* We must check that stdout is not closed. + * The reason for this is highly non-obvious. +@@ -362,8 +486,8 @@ + if (!argv[1]) + bb_show_usage(); + +- format = argv[1]; +- argv2 = argv + 2; ++ argv += optind; ++ argv2 = argv; do { - args_used = print_formatted(format, argc, argv); + argv = argv2;