[vlc-devel] [PATCH v2 3/3] zsh: replace printf/puts with std::cout

Sebastian Ramacher sramacher at debian.org
Mon Oct 2 01:11:15 CEST 2017


Signed-off-by: Sebastian Ramacher <sramacher at debian.org>
---
 extras/analyser/zsh.cpp | 80 ++++++++++++++++++++++++-------------------------
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/extras/analyser/zsh.cpp b/extras/analyser/zsh.cpp
index 0c99a7b6e0..7b7b8e00e9 100644
--- a/extras/analyser/zsh.cpp
+++ b/extras/analyser/zsh.cpp
@@ -25,8 +25,8 @@
 # include "config.h"
 #endif
 
-#include <stdio.h>
 #include <algorithm>
+#include <iostream>
 #include <map>
 #include <set>
 #include <string>
@@ -66,33 +66,33 @@ static void PrintOption(const module_config_t *item, const std::string &opt,
     if (!longtext.length() || longtext.find('\n') != std::string::npos || longtext.find('(') != std::string::npos)
         longtext = text;
 
-    printf("  \"");
+    std::cout << "  \"";
 
     const char *args_c = args.empty() ? "" : "=";
     if (i_short) {
-        printf("(-%c", i_short);
+        std::cout << "(-" << i_short;
 
         if (!excl.empty())
-            printf("%s", excl.c_str());
+            std::cout << excl;
 
-        printf(")--%s%s[%s]", opt.c_str(), args_c, text.c_str());
+        std::cout << ")--" << opt << args_c << "[" << text << "]";
 
         if (!args.empty())
-            printf(":%s:%s", longtext.c_str(), args.c_str());
+            std::cout << ":" << longtext << ":" << args;
 
-        printf("\"\\\n  \"(--%s%s)-%c", opt.c_str(), excl.c_str(), i_short);
+        std::cout << "\"\\\n  \"(--" << opt << excl << ")-" << i_short;
     } else {
         if (!excl.empty())
-            printf("(%s)", excl.c_str());
-        printf("--%s", opt.c_str());
+            std::cout << "(" << excl << ")";
+        std::cout << "--" << opt;
         if (!excl.empty())
-            printf("%s", args_c);
+            std::cout << args_c;
     }
 
-    printf("[%s]", text.c_str());
+    std::cout << "[" << text << "]";
     if (!args.empty())
-        printf( ":%s:%s", longtext.c_str(), args.c_str());
-    puts( "\"\\");
+        std::cout << ":" << longtext << ":" << args;
+    std::cout << "\"\\\n";
 }
 
 static void ParseOption(const module_config_t *item)
@@ -215,7 +215,7 @@ static void PrintModule(const module_t *mod)
 
     if (mnames.find(name) == mnames.end())
     {
-        printf("%s ", name);
+        std::cout << name << " ";
         mnames.insert(name);
     }
 }
@@ -253,41 +253,41 @@ int main(int argc, const char **argv)
 
     module_t **max = &mod_list[modules];
 
-    puts("#compdef vlc cvlc rvlc svlc mvlc qvlc nvlc\n"
+    std::cout << "#compdef vlc cvlc rvlc svlc mvlc qvlc nvlc\n"
            "#This file is autogenerated by zsh.cpp\n"
            "typeset -A opt_args\n"
            "local context state line ret=1\n"
-           "local modules\n");
+           "local modules\n\n";
 
-    printf("vlc_modules=\"");
+    std::cout << "vlc_modules=\"";
     for (module_t **mod = mod_list; mod < max; mod++)
         PrintModule(*mod);
-    puts("\"\n");
+    std::cout << "\"\n\n";
 
-    puts("_arguments -S -s \\");
+    std::cout << "_arguments -S -s \\\n";
     for (module_t **mod = mod_list; mod < max; mod++)
         ParseModule(*mod);
-    puts("  \"(--module)-p[print help on module]:print help on module:($vlc_modules)\"\\");
-    puts("  \"(-p)--module[print help on module]:print help on module:($vlc_modules)\"\\");
-    puts("  \"(--help)-h[print help]\"\\");
-    puts("  \"(-h)--help[print help]\"\\");
-    puts("  \"(--longhelp)-H[print detailed help]\"\\");
-    puts("  \"(-H)--longhelp[print detailed help]\"\\");
-    puts("  \"(--list)-l[print a list of available modules]\"\\");
-    puts("  \"(-l)--list[print a list of available modules]\"\\");
-    puts("  \"--reset-config[reset the current config to the default values]\"\\");
-    puts("  \"--config[use alternate config file]\"\\");
-    puts("  \"--reset-plugins-cache[resets the current plugins cache]\"\\");
-    puts("  \"--version[print version information]\"\\");
-    puts("  \"*:Playlist item:->mrl\" && ret=0\n");
-
-    puts("case $state in");
-    puts("  mrl)");
-    puts("    _alternative 'files:file:_files' 'urls:URL:_urls' && ret=0");
-    puts("  ;;");
-    puts("esac\n");
-
-    puts("return ret");
+    std::cout << "  \"(--module)-p[print help on module]:print help on module:($vlc_modules)\"\\\n";
+    std::cout << "  \"(-p)--module[print help on module]:print help on module:($vlc_modules)\"\\\n";
+    std::cout << "  \"(--help)-h[print help]\"\\\n";
+    std::cout << "  \"(-h)--help[print help]\"\\\n";
+    std::cout << "  \"(--longhelp)-H[print detailed help]\"\\\n";
+    std::cout << "  \"(-H)--longhelp[print detailed help]\"\\\n";
+    std::cout << "  \"(--list)-l[print a list of available modules]\"\\\n";
+    std::cout << "  \"(-l)--list[print a list of available modules]\"\\\n";
+    std::cout << "  \"--reset-config[reset the current config to the default values]\"\\\n";
+    std::cout << "  \"--config[use alternate config file]\"\\\n";
+    std::cout << "  \"--reset-plugins-cache[resets the current plugins cache]\"\\\n";
+    std::cout << "  \"--version[print version information]\"\\\n";
+    std::cout << "  \"*:Playlist item:->mrl\" && ret=0\n\n";
+
+    std::cout << "case $state in\n";
+    std::cout << "  mrl)\n";
+    std::cout << "    _alternative 'files:file:_files' 'urls:URL:_urls' && ret=0\n";
+    std::cout << "  ;;\n";
+    std::cout << "esac\n\n";
+
+    std::cout << "return ret\n";
 
     module_list_free(mod_list);
     libvlc_release(libvlc);
-- 
2.14.2



More information about the vlc-devel mailing list