~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to debian/patches/echo_utf-8_clean.patch

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-02-08 11:39:26 UTC
  • mfrom: (17.6.26 experimental)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 104.
  • Revision ID: james.westby@ubuntu.com-20110208113926-clfs90haboyk9zip
Tags: 1.99~rc1-2
* Merge 1.98+20100804-13 and 1.98+20100804-14, updating translations:
  - Kazakh (Baurzhan Muftakhidinov / Timur Birsh).
* mkconfig_skip_dmcrypt.patch: Refer to GRUB_PRELOAD_MODULES rather than
  suggesting people write a /etc/grub.d/01_modules script (thanks, Jordan
  Uggla).
* Handle empty dir passed to grub_find_root_device_from_mountinfo; fixes
  grub-mkrelpath on btrfs subvolumes (LP: #712029).
* Add rootflags=subvol=<name> if / is on a btrfs subvolume (LP: #712029).
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Make echo UTF-8-clean
2
 
Author: Colin Watson <cjwatson@ubuntu.com>
3
 
Origin: upstream, http://bazaar.launchpad.net/~vcs-imports/grub/grub2-bzr/revision/2989
4
 
Bug-Debian: http://bugs.debian.org/605615
5
 
Forwarded: yes
6
 
Last-Update: 2010-12-21
7
 
 
8
 
Index: b/commands/echo.c
9
 
===================================================================
10
 
--- a/commands/echo.c
11
 
+++ b/commands/echo.c
12
 
@@ -44,8 +44,14 @@
13
 
   for (i = 0; i < argc; i++)
14
 
     {
15
 
       char *arg = *args;
16
 
+      /* Unescaping results in a string no longer than the original.  */
17
 
+      char *unescaped = grub_malloc (grub_strlen (arg) + 1);
18
 
+      char *p = unescaped;
19
 
       args++;
20
 
 
21
 
+      if (!unescaped)
22
 
+       return grub_errno;
23
 
+
24
 
       while (*arg)
25
 
        {
26
 
          /* In case `-e' is used, parse backslashes.  */
27
 
@@ -58,11 +64,11 @@
28
 
              switch (*arg)
29
 
                {
30
 
                case '\\':
31
 
-                 grub_printf ("\\");
32
 
+                 *p++ = '\\';
33
 
                  break;
34
 
 
35
 
                case 'a':
36
 
-                 grub_printf ("\a");
37
 
+                 *p++ = '\a';
38
 
                  break;
39
 
 
40
 
                case 'c':
41
 
@@ -70,23 +76,23 @@
42
 
                  break;
43
 
 
44
 
                case 'f':
45
 
-                 grub_printf ("\f");
46
 
+                 *p++ = '\f';
47
 
                  break;
48
 
 
49
 
                case 'n':
50
 
-                 grub_printf ("\n");
51
 
+                 *p++ = '\n';
52
 
                  break;
53
 
 
54
 
                case 'r':
55
 
-                 grub_printf ("\r");
56
 
+                 *p++ = '\r';
57
 
                  break;
58
 
 
59
 
                case 't':
60
 
-                 grub_printf ("\t");
61
 
+                 *p++ = '\t';
62
 
                  break;
63
 
 
64
 
                case 'v':
65
 
-                 grub_printf ("\v");
66
 
+                 *p++ = '\v';
67
 
                  break;
68
 
                }
69
 
              arg++;
70
 
@@ -95,10 +101,14 @@
71
 
 
72
 
          /* This was not an escaped character, or escaping is not
73
 
             enabled.  */
74
 
-         grub_printf ("%c", *arg);
75
 
+         *p++ = *arg;
76
 
          arg++;
77
 
        }
78
 
 
79
 
+      *p = '\0';
80
 
+      grub_xputs (unescaped);
81
 
+      grub_free (unescaped);
82
 
+
83
 
       /* If another argument follows, insert a space.  */
84
 
       if (i != argc - 1)
85
 
        grub_printf (" " );