]> git.pld-linux.org Git - packages/busybox.git/blobdiff - busybox-printf-gettext.patch
- up to 1.5.0
[packages/busybox.git] / busybox-printf-gettext.patch
index 56584a699130e6bf55f5ded0cc7a14568db004c9..35642459833fbc093c8bddd2bd3a8b134ecd14ee 100644 (file)
@@ -1,23 +1,18 @@
-diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/printf.c
---- busybox-1.00.orig/coreutils/printf.c       2004-09-15 02:05:23.000000000 +0000
-+++ busybox-1.00/coreutils/printf.c    2004-11-11 18:16:33.724386928 +0000
-@@ -47,8 +47,13 @@
+--- busybox-1.3.1/coreutils/printf.c.orig      2006-12-27 05:54:50.000000000 +0100
++++ busybox-1.3.1/coreutils/printf.c   2006-12-30 12:28:27.605589427 +0100
+@@ -38,6 +38,9 @@
  
  //   19990508 Busy Boxed! Dave Cinege
  
 +// on by default
 +#define BB_FEATURE_PRINTF_GETTEXT
 +
- #include <unistd.h>
- #include <stdio.h>
-+#include <sys/mman.h>
-+#include <sys/stat.h>
- #include <sys/types.h>
- #include <string.h>
- #include <errno.h>
-@@ -66,18 +71,137 @@
- static void print_direc __P( (char *start, size_t length,
-                       int field_width, int precision, char *argument));
+ #include "busybox.h"
+ static int print_formatted(char *format, int argc, char **argv);
+@@ -288,19 +288,135 @@
+       return save_argc - argc;
+ }
  
 +/*
 + * Very pure gettext added by Michal Moskal <malekith@pld-linux.org>
@@ -58,10 +53,9 @@ diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/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)
@@ -74,7 +68,7 @@ diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/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;
 +
@@ -83,7 +77,7 @@ diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/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)
@@ -97,19 +91,18 @@ diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/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)
@@ -119,7 +112,7 @@ diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/printf.c
 +              act = -1;
 +      }
 +
-+      oops:
++oops:
 +      if (act != -1)
 +              ret = strdup(((char *) ptr + swap_if(trans_tab[act].offset)));
 +      munmap(ptr, st.st_size);
@@ -129,24 +122,25 @@ diff -ur busybox-1.00.orig/coreutils/printf.c busybox-1.00/coreutils/printf.c
 +# define getmsg(a,b) (b)
 +#endif
 +
+ int printf_main(int argc, char **argv);
  int printf_main(int argc, char **argv)
  {
        char *format;
-       int args_used;
-+      int opt;
+-      int args_used;
++      int args_used, opt;
 +      const char *nls_file = NULL;
  
--      if (argc <= 1 || **(argv + 1) == '-') {
+-      if (argc <= 1 || argv[1][0] == '-') {
 -              bb_show_usage();
 -      }
 +      while ((opt = getopt(argc, argv, "n:")) != -1)
 +              switch (opt) {
-+              case 'n':
-+                      nls_file = optarg;
-+                      break;
-+              default:
-+                      bb_show_usage();
-+                      break;
++                      case 'n':
++                              nls_file = optarg;
++                              break;
++                      default:
++                              bb_show_usage();
++                              break;
 +              }
 +
 +      format = getmsg(nls_file, argv[optind++]);
This page took 0.066571 seconds and 4 git commands to generate.