]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
code style: Avoid gratuitous 'continue;' statements.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Aug 2019 09:38:22 +0000 (11:38 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Aug 2019 09:38:22 +0000 (11:38 +0200)
* gettext-tools/src/file-list.c (read_names_from_file): Use 'if' instead of
'continue'.
* gettext-tools/src/its.c (its_rule_list_add_from_doc): Likewise.
* gettext-tools/src/locating-rule.c (locating_rule_list_add_from_file):
Likewise.
* gettext-tools/src/msgfmt.c (get_languages): Likewise.
* gettext-tools/src/x-javascript.c (phase5_scan_xml_markup): Likewise.
* gettext-tools/src/x-lua.c (phase2_getc): Likewise.
* gettext-tools/src/read-desktop.c (desktop_lex): Use 'if' instead of 'switch'
with few alternatives. Test for EOF first.

gettext-tools/src/file-list.c
gettext-tools/src/its.c
gettext-tools/src/locating-rule.c
gettext-tools/src/msgfmt.c
gettext-tools/src/read-desktop.c
gettext-tools/src/x-javascript.c
gettext-tools/src/x-lua.c

index 58a5277102441dcf485388b366af552129746ef9..3d2fcaf4dcbab41ae8dbcd03ba6140abdef528d9 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading file lists.
-   Copyright (C) 1995-1998, 2000-2002, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2002, 2007, 2019 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -74,10 +74,9 @@ read_names_from_file (const char *file_name)
         line_buf[--len] = '\0';
 
       /* Test if we have to ignore the line.  */
-      if (*line_buf == '\0' || *line_buf == '#')
-        continue;
-
-      string_list_append_unique (result, line_buf);
+      if (!(*line_buf == '\0' || *line_buf == '#'))
+        /* Include the line in the result.  */
+        string_list_append_unique (result, line_buf);
     }
 
   /* Free buffer allocated through getline.  */
index d9306cd23f2b4799cecc19908556fdbe7659913e..8adf045448ba8e767b1a9e33db8c2cba48b8ea22 100644 (file)
@@ -1,5 +1,5 @@
 /* Internationalization Tag Set (ITS) handling
-   Copyright (C) 2015, 2018 Free Software Foundation, Inc.
+   Copyright (C) 2015, 2018-2019 Free Software Foundation, Inc.
 
    This file was written by Daiki Ueno <ueno@gnu.org>, 2015.
 
@@ -1427,17 +1427,17 @@ its_rule_list_add_from_doc (struct its_rule_list_ty *rules,
       struct its_rule_ty *rule;
 
       rule = its_rule_parse (doc, node);
-      if (!rule)
-        continue;
-
-      if (rules->nitems == rules->nitems_max)
+      if (rule != NULL)
         {
-          rules->nitems_max = 2 * rules->nitems_max + 1;
-          rules->items =
-            xrealloc (rules->items,
-                      sizeof (struct its_rule_ty *) * rules->nitems_max);
+          if (rules->nitems == rules->nitems_max)
+            {
+              rules->nitems_max = 2 * rules->nitems_max + 1;
+              rules->items =
+                xrealloc (rules->items,
+                          sizeof (struct its_rule_ty *) * rules->nitems_max);
+            }
+          rules->items[rules->nitems++] = rule;
         }
-      rules->items[rules->nitems++] = rule;
     }
 
   return true;
index f78b437ca28b3702cc4ad48e89b14d2a8ceabfcd..1b470ae81ce541c07dfe3473b357e654023fe68b 100644 (file)
@@ -1,5 +1,5 @@
 /* XML resource locating rules
-   Copyright (C) 2015 Free Software Foundation, Inc.
+   Copyright (C) 2015, 2019 Free Software Foundation, Inc.
 
    This file was written by Daiki Ueno <ueno@gnu.org>, 2015.
 
@@ -331,34 +331,35 @@ locating_rule_list_add_from_file (struct locating_rule_list_ty *rules,
             {
               missing_attribute (node, "pattern");
               xmlFreeDoc (doc);
-              continue;
             }
-
-          memset (&rule, 0, sizeof (struct locating_rule_ty));
-          rule.pattern = get_attribute (node, "pattern");
-          if (xmlHasProp (node, BAD_CAST "name"))
-            rule.name = get_attribute (node, "name");
-          if (xmlHasProp (node, BAD_CAST "target"))
-            rule.target = get_attribute (node, "target");
           else
             {
-              xmlNode *n;
+              memset (&rule, 0, sizeof (struct locating_rule_ty));
+              rule.pattern = get_attribute (node, "pattern");
+              if (xmlHasProp (node, BAD_CAST "name"))
+                rule.name = get_attribute (node, "name");
+              if (xmlHasProp (node, BAD_CAST "target"))
+                rule.target = get_attribute (node, "target");
+              else
+                {
+                  xmlNode *n;
 
-              for (n = node->children; n; n = n->next)
+                  for (n = node->children; n; n = n->next)
+                    {
+                      if (xmlStrEqual (n->name, BAD_CAST "documentRule"))
+                        document_locating_rule_list_add (&rule.doc_rules, n);
+                    }
+                }
+              if (rules->nitems == rules->nitems_max)
                 {
-                  if (xmlStrEqual (n->name, BAD_CAST "documentRule"))
-                    document_locating_rule_list_add (&rule.doc_rules, n);
+                  rules->nitems_max = 2 * rules->nitems_max + 1;
+                  rules->items =
+                    xrealloc (rules->items,
+                              sizeof (struct locating_rule_ty) * rules->nitems_max);
                 }
+              memcpy (&rules->items[rules->nitems++], &rule,
+                      sizeof (struct locating_rule_ty));
             }
-          if (rules->nitems == rules->nitems_max)
-            {
-              rules->nitems_max = 2 * rules->nitems_max + 1;
-              rules->items =
-                xrealloc (rules->items,
-                          sizeof (struct locating_rule_ty) * rules->nitems_max);
-            }
-          memcpy (&rules->items[rules->nitems++], &rule,
-                  sizeof (struct locating_rule_ty));
         }
     }
 
index 9dded2462e6b57b6a06d03181165472b24ef7f1e..d016c47eab935196c03e6d2283600f42dfc64379 100644 (file)
@@ -1488,10 +1488,9 @@ get_languages (string_list_ty *languages, const char *directory)
         line_buf[--len] = '\0';
 
       /* Test if we have to ignore the line.  */
-      if (*line_buf == '\0' || *line_buf == '#')
-        continue;
-
-      add_languages (languages, desired_languages, line_buf, len);
+      if (!(*line_buf == '\0' || *line_buf == '#'))
+        /* Include the line among the languages.  */
+        add_languages (languages, desired_languages, line_buf, len);
     }
 
   free (line_buf);
index 4de134f3cc6dfc77b3e8b46163e9b2748ca87856..31d4c851d9c0020aa11b111d2682445150b37c93 100644 (file)
@@ -252,24 +252,20 @@ desktop_lex (token_ty *tp)
             for (;;)
               {
                 c = phase2_getc ();
-                switch (c)
+                if (c == EOF || c == ']')
+                  break;
+                if (c == '\n')
                   {
-                  default:
-                    /* Group names may contain all ASCII characters
-                       except for '[' and ']' and control characters.  */
-                    if (!(c_isascii (c) && c != '[') && !c_iscntrl (c))
-                      break;
-                    APPEND (c);
-                    continue;
-                  case '\n':
                     po_xerror (PO_SEVERITY_WARNING, NULL,
                                real_file_name, gram_pos.line_number, 0, false,
                                _("unterminated group name"));
                     break;
-                  case EOF: case ']':
-                    break;
                   }
-                break;
+                /* Group names may contain all ASCII characters
+                   except for '[' and ']' and control characters.  */
+                if (!(c_isascii (c) && c != '[') && !c_iscntrl (c))
+                  break;
+                APPEND (c);
               }
             /* Skip until newline.  */
             while (c != '\n' && c != EOF)
@@ -296,15 +292,9 @@ desktop_lex (token_ty *tp)
             for (;;)
               {
                 c = phase2_getc ();
-                switch (c)
-                  {
-                  default:
-                    APPEND (c);
-                    continue;
-                  case EOF: case '\n':
-                    break;
-                  }
-                break;
+                if (c == EOF || c == '\n')
+                  break;
+                APPEND (c);
               }
             APPEND (0);
             tp->type = token_type_comment;
@@ -360,15 +350,9 @@ desktop_lex (token_ty *tp)
                     for (;;)
                       {
                         int c2 = phase2_getc ();
-                        switch (c2)
-                          {
-                          default:
-                            APPEND (c2);
-                            continue;
-                          case EOF: case ']':
-                            break;
-                          }
-                        break;
+                        if (c2 == EOF || c2 == ']')
+                          break;
+                        APPEND (c2);
                       }
                     break;
 
@@ -386,9 +370,9 @@ desktop_lex (token_ty *tp)
                 c = phase2_getc ();
                 switch (c)
                   {
+                  case ' ':
+                    continue;
                   default:
-                    if (c == ' ')
-                      continue;
                     phase2_ungetc (c);
                     break;
                   case EOF: case '\n':
@@ -419,9 +403,9 @@ desktop_lex (token_ty *tp)
                 c = phase2_getc ();
                 switch (c)
                   {
+                  case ' ':
+                    continue;
                   default:
-                    if (c == ' ')
-                      continue;
                     phase2_ungetc (c);
                     break;
                   case EOF:
index 7ac5b24725f479e6d33d18e7cc2db5a189ebe844..0a8cd28568ccc6c42a6946ecdb54346ca1ab2439 100644 (file)
@@ -1000,56 +1000,54 @@ phase5_scan_xml_markup (token_ty *tp)
             }
         }
 
-      if (start[j] != '\0')
-        continue;
-
-      /* Skip until the end marker.  */
-      for (;;)
-        {
-          int c;
-
-          for (j = 0; end[j] != '\0'; j++)
-            {
-              assert (phase2_pushback_length + 1 < SIZEOF (phase2_pushback));
-              c = phase2_getc ();
-              if (c == UEOF)
-                goto eof;
-              if (c != end[j])
-                {
-                  /* Don't push the first character back so the next
-                     iteration start from the second character.  */
-                  if (j > 0)
-                    {
-                      int k = j;
+      if (start[j] == '\0')
+        /* Skip until the end marker.  */
+        for (;;)
+          {
+            int c;
 
-                      phase2_ungetc (c);
-                      k--;
+            for (j = 0; end[j] != '\0'; j++)
+              {
+                assert (phase2_pushback_length + 1 < SIZEOF (phase2_pushback));
+                c = phase2_getc ();
+                if (c == UEOF)
+                  goto eof;
+                if (c != end[j])
+                  {
+                    /* Don't push the first character back so the next
+                       iteration start from the second character.  */
+                    if (j > 0)
+                      {
+                        int k = j;
 
-                      for (; k > 0; k--)
-                        phase2_ungetc (end[k]);
-                    }
-                  break;
-                }
-            }
+                        phase2_ungetc (c);
+                        k--;
 
-          if (end[j] != '\0')
-            continue;
+                        for (; k > 0; k--)
+                          phase2_ungetc (end[k]);
+                      }
+                    break;
+                  }
+              }
 
-          c = phase2_getc ();
-          if (c == UEOF)
-            goto eof;
-          if (c != '>')
-            {
-              error_with_progname = false;
-              error (0, 0,
-                     _("%s:%d: warning: %s is not allowed"),
-                     logical_file_name, line_number,
-                     end);
-              error_with_progname = true;
-              return false;
-            }
-          return true;
-        }
+            if (end[j] == '\0')
+              {
+                c = phase2_getc ();
+                if (c == UEOF)
+                  goto eof;
+                if (c != '>')
+                  {
+                    error_with_progname = false;
+                    error (0, 0,
+                           _("%s:%d: warning: %s is not allowed"),
+                           logical_file_name, line_number,
+                           end);
+                    error_with_progname = true;
+                    return false;
+                  }
+                return true;
+              }
+          }
     }
   return false;
 
index 8db7561ba1b7dd5c42dc88e18b34bd6191c136d6..5aed25745a1d6697f913fc14fb8812feee37823c 100644 (file)
@@ -308,42 +308,42 @@ phase2_getc ()
                         break;
 
                       /* Ignore leading spaces and tabs.  */
-                      if (buflen == 0 && (c == ' ' || c == '\t'))
-                        continue;
-
-                      comment_add (c);
-
-                      switch (c)
+                      if (!(buflen == 0 && (c == ' ' || c == '\t')))
                         {
-                        case ']':
-                          if (!right_bracket)
-                            {
-                              right_bracket = true;
-                              esigns2 = 0;
-                            }
-                          else
+                          comment_add (c);
+
+                          switch (c)
                             {
-                              if (esigns2 == esigns)
+                            case ']':
+                              if (!right_bracket)
                                 {
-                                  comment_line_end (2 + esigns);
-                                  end = true;
+                                  right_bracket = true;
+                                  esigns2 = 0;
                                 }
-                            }
-                          break;
+                              else
+                                {
+                                  if (esigns2 == esigns)
+                                    {
+                                      comment_line_end (2 + esigns);
+                                      end = true;
+                                    }
+                                }
+                              break;
 
-                        case '=':
-                          if (right_bracket)
-                            esigns2++;
-                          break;
+                            case '=':
+                              if (right_bracket)
+                                esigns2++;
+                              break;
 
-                        case '\n':
-                          comment_line_end (1);
-                          comment_start ();
-                          lineno = line_number;
-                          /* Intentionally not breaking.  */
+                            case '\n':
+                              comment_line_end (1);
+                              comment_start ();
+                              lineno = line_number;
+                              /* Intentionally not breaking.  */
 
-                        default:
-                          right_bracket = false;
+                            default:
+                              right_bracket = false;
+                            }
                         }
                     }
                   last_comment_line = lineno;