Merge "Escape single quotes in arguments." into lmp-dev
diff --git a/adb/commandline.c b/adb/commandline.c
index e1ff856..af21e38 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -675,7 +675,12 @@
     }
 }
 
-/** Duplicate and escape given argument. */
+static bool should_escape(const char c)
+{
+    return (c == ' ' || c == '\'' || c == '"' || c == '\\' || c == '(' || c == ')');
+}
+
+/* Duplicate and escape given argument. */
 static char *escape_arg(const char *s)
 {
     const char *ts;
@@ -686,7 +691,7 @@
     alloc_len = 0;
     for (ts = s; *ts != '\0'; ts++) {
         alloc_len++;
-        if (*ts == ' ' || *ts == '"' || *ts == '\\' || *ts == '(' || *ts == ')') {
+        if (should_escape(*ts)) {
             alloc_len++;
         }
     }
@@ -704,7 +709,7 @@
     dest = ret;
 
     for (ts = s; *ts != '\0'; ts++) {
-        if (*ts == ' ' || *ts == '"' || *ts == '\\' || *ts == '(' || *ts == ')') {
+        if (should_escape(*ts)) {
             *dest++ = '\\';
         }
         *dest++ = *ts;