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 );
}
|