]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Honor reedit opts printing to a function
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Jun 2012 09:11:27 +0000 (11:11 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 14 Jun 2012 13:04:28 +0000 (15:04 +0200)
When printing reedit options we make stdin raw. However,
this results in stdout being raw as well. Therefore we need
to return carriage when doing new line. Unfortunately,
'\r' cannot be part of internationalized messages hence
we must move them to formatting string which then in turn
become huge and disarranged. To solve this, a new function
is introduced which takes variable string arguments and
prepend each with "\r\n" just before printing.

tools/virsh.c

index 18625009ceb2641331b2fa2c5b7449c54b883b93..6077d84b321dc9a2a31935f27e2be8e1251801c0 100644 (file)
@@ -655,6 +655,19 @@ vshReconnect(vshControl *ctl)
     ctl->useSnapshotOld = false;
 }
 
+static void
+vshPrintRaw(vshControl *ctl, ...)
+{
+    va_list ap;
+    char *key;
+
+    va_start(ap, ctl);
+    while ((key = va_arg(ap, char *)) != NULL) {
+        vshPrint(ctl, "%s\r\n", key);
+    }
+    va_end(ap);
+}
+
 /**
  * vshAskReedit:
  * @msg: Question to ask user
@@ -690,10 +703,13 @@ vshAskReedit(vshControl *ctl, const char *msg)
         c = c_tolower(getchar());
 
         if (c == '?') {
-            vshPrint(ctl, "\r\n%s", _("y - yes, start editor again\n"
-                                      "n - no, throw away my changes\n"
-                                      "f - force, try to redefine again\n"
-                                      "? - print this help\n"));
+            vshPrintRaw(ctl,
+                        "",
+                        _("y - yes, start editor again"),
+                        _("n - no, throw away my changes"),
+                        _("f - force, try to redefine again"),
+                        _("? - print this help"),
+                        NULL);
             continue;
         } else if (c == 'y' || c == 'n' || c == 'f') {
             break;