File: 03_allow-or-quoting-of-strings-in-.valgrindrc.patch

package info (click to toggle)
valgrind 1%3A3.12.0~svn20160714-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 120,428 kB
  • ctags: 70,855
  • sloc: ansic: 674,645; exp: 26,134; xml: 21,574; asm: 7,570; cpp: 7,567; makefile: 7,380; sh: 6,188; perl: 5,855; haskell: 195
file content (40 lines) | stat: -rw-r--r-- 1,297 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Description: Allow ' or " quoting of strings in ~/.valgrindrc
 Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Origin: vendor
Bug-Debian: http://bugs.debian.org/507236
Author: Pierre Habouzit <madcoder@debian.org>
Reviewed-by: Alessandro Ghedini <ghedo@debian.org>
Last-Update: 2012-05-10

--- a/coregrind/m_commandline.c
+++ b/coregrind/m_commandline.c
@@ -98,14 +98,27 @@
 {
    HChar* tmp;
    HChar* cp = s;
+   int quoted = '\0';
    vg_assert(cp);
    while (True) {
+      HChar* out;
       // We have alternating sequences: blanks, non-blanks, blanks...
       // copy the non-blanks sequences, and add terminating '\0'
+      // deal with " or '-quoted strings properly.
       while (VG_(isspace)(*cp)) cp++;
       if (*cp == 0) break;
-      tmp = cp;
-      while ( !VG_(isspace)(*cp) && *cp != 0 ) cp++;
+      tmp = out = cp;
+      while ( (quoted || !VG_(isspace)(*cp)) && *cp) {
+          if (*cp == quoted) {
+              quoted = '\0';
+          } else if (*cp == '\'' || *cp == '"') {
+              quoted = *cp;
+          } else {
+              *out++ = *cp;
+          }
+          cp++;
+      }
+      if (out < cp) *out++ = '\0';
       if ( *cp != 0 ) *cp++ = '\0';       // terminate if not the last
       add_string( VG_(args_for_valgrind), tmp );
    }