[FFmpeg-devel,1/5] lavu/bprint: reorder cases to match enum order

Submitted by Rodger Combs on April 12, 2017, 7:11 a.m.

Details

Message ID 20170412071127.60511-1-rodger.combs@gmail.com
State New
Headers show

Commit Message

Rodger Combs April 12, 2017, 7:11 a.m.
---
 libavutil/bprint.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

Comments

Nicolas George April 12, 2017, 1:16 p.m.
Le tridi 23 germinal, an CCXXV, Rodger Combs a écrit :
> ---
>  libavutil/bprint.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)

No objection.

(At some point, I would like to have the default case become something
like "av_assert0(!"invalid escape mode")", but that is somewhat
independent.)

Regards,

Patch hide | download patch | download mbox

diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index 2f059c5ba6..652775bef9 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -271,19 +271,8 @@  void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_cha
         mode = AV_ESCAPE_MODE_BACKSLASH; /* TODO: implement a heuristic */
 
     switch (mode) {
-    case AV_ESCAPE_MODE_QUOTE:
-        /* enclose the string between '' */
-        av_bprint_chars(dstbuf, '\'', 1);
-        for (; *src; src++) {
-            if (*src == '\'')
-                av_bprintf(dstbuf, "'\\''");
-            else
-                av_bprint_chars(dstbuf, *src, 1);
-        }
-        av_bprint_chars(dstbuf, '\'', 1);
-        break;
-
     /* case AV_ESCAPE_MODE_BACKSLASH or unknown mode */
+    case AV_ESCAPE_MODE_BACKSLASH:
     default:
         /* \-escape characters */
         for (; *src; src++) {
@@ -301,5 +290,17 @@  void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_cha
             av_bprint_chars(dstbuf, *src, 1);
         }
         break;
+
+    case AV_ESCAPE_MODE_QUOTE:
+        /* enclose the string between '' */
+        av_bprint_chars(dstbuf, '\'', 1);
+        for (; *src; src++) {
+            if (*src == '\'')
+                av_bprintf(dstbuf, "'\\''");
+            else
+                av_bprint_chars(dstbuf, *src, 1);
+        }
+        av_bprint_chars(dstbuf, '\'', 1);
+        break;
     }
 }