]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
extract-word: replace an use of `goto` with structured code
authorFilipe Brandenburger <filbranden@google.com>
Fri, 6 Nov 2015 05:17:11 +0000 (21:17 -0800)
committerFilipe Brandenburger <filbranden@google.com>
Fri, 6 Nov 2015 05:19:54 +0000 (21:19 -0800)
Using `goto` might be appropriate for the "finish" cases but it was
really not necessary at this point of the code... Just use if/else
blocks to accomplish the same.

Confirmed that the test cases in test-extract-word keep working as
expected.

src/basic/extract-word.c

index 23e3d557c03be0a052386c5f27bc6600137fb284..1b3123bb7d83e6c7437ccf7b385ea76df358d698 100644 (file)
@@ -106,21 +106,19 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
                                         if (flags & EXTRACT_CUNESCAPE_RELAX) {
                                                 s[sz++] = '\\';
                                                 s[sz++] = c;
-                                                goto end_escape;
-                                        }
-                                        return -EINVAL;
+                                        } else
+                                                return -EINVAL;
+                                } else {
+                                        (*p) += r - 1;
+
+                                        if (c != 0)
+                                                s[sz++] = c; /* normal explicit char */
+                                        else
+                                                sz += utf8_encode_unichar(s + sz, u); /* unicode chars we'll encode as utf8 */
                                 }
-
-                                (*p) += r - 1;
-
-                                if (c != 0)
-                                        s[sz++] = c; /* normal explicit char */
-                                else
-                                        sz += utf8_encode_unichar(s + sz, u); /* unicode chars we'll encode as utf8 */
                         } else
                                 s[sz++] = c;
 
-end_escape:
                         backslash = false;
 
                 } else if (quote) {     /* inside either single or double quotes */