aboutsummaryrefslogtreecommitdiff
blob: 1cc6b432c3d4555b454db3dee0ffa6db5fb7a811 (plain)
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
41
42
43
44
45
46
47
48
49
50
From 14f407a5d183cdac7029cc54a9d8ae6b0cb5cbcd Mon Sep 17 00:00:00 2001
From: Nicolas Bock <nicolasbock@gmail.com>
Date: Fri, 27 Sep 2013 10:52:18 -0600
Subject: [PATCH 3/4] charmrun.c: parsing of strings now parses "\n" into '\n'

Since gdb lacks anything like ';' to separate several commands in one line,
the commands need to be separated by a newline character. I have added some
parsing logic so that the string "\n" will now be translated into the
character '\n'.
---
 src/arch/net/charmrun/charmrun.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/arch/net/charmrun/charmrun.c b/src/arch/net/charmrun/charmrun.c
index 6837712..8818cf8 100644
--- a/src/arch/net/charmrun/charmrun.c
+++ b/src/arch/net/charmrun/charmrun.c
@@ -454,8 +454,27 @@ static int pparam_setdef(def, value)
       if (*p) return -1;
       return 0;
     case 's' :
-      *def->where.s = strdup(value);
-      return 0;
+      {
+        /* Parse input string and convert a literal "\n" into '\n'. */
+        *def->where.s = (char*) calloc(strlen(value)+1, sizeof(char));
+        char* parsed_value = (char*) *def->where.s;
+        int i;
+        int j = 0;
+        for(i = 0; i < strlen(value); i++)
+        {
+          if(i+1 < strlen(value))
+          {
+            if(value[i] == '\\' && value[i+1] == 'n')
+            {
+              parsed_value[j++] = '\n';
+              i++;
+              continue;
+            }
+          }
+          parsed_value[j++] = value[i];
+        }
+        return 0;
+      }
     case 'f' :
       *def->where.f = strtol(value, &p, 10);
       if (*p) return -1;
-- 
1.8.1.5