Delete parse_flags/parse_flags_qcs
authorPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:06:54 +0000 (00:06 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:24:17 +0000 (00:24 +0100)
Now that "thread/frame apply" have been converted to the gdb::option
framework, these functions are no longer used.

For a while, I thought about keeping the unit tests, by making a local
version of parse_flags_qcs in the unit tests file.  But all that would
really test that is used by GDB itself, is the validate_flags_qcs
function.  So in the end, I went through all the unit tests, and
converted any that wasn't already covered to gdb.base/options.exp
tests.  And those have all already been added in previous patches.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

* cli/cli-utils.c (parse_flags, parse_flags_qcs): Delete.
* cli/cli-utils.h (parse_flags, parse_flags_qcs): Delete.
* unittests/cli-utils-selftests.c (test_parse_flags)
(test_parse_flags_qcs): Delete.
(test_cli_utils): Don't call deleted functions.

gdb/ChangeLog
gdb/cli/cli-utils.c
gdb/cli/cli-utils.h
gdb/unittests/cli-utils-selftests.c

index 51842ed10d11df48b942ff0551047fa92d1e54be..8fe3f103030ce98b4f0206addf25a2164cdfc119 100644 (file)
@@ -1,3 +1,11 @@
+2019-06-13  Pedro Alves  <palves@redhat.com>
+
+       * cli/cli-utils.c (parse_flags, parse_flags_qcs): Delete.
+       * cli/cli-utils.h (parse_flags, parse_flags_qcs): Delete.
+       * unittests/cli-utils-selftests.c (test_parse_flags)
+       (test_parse_flags_qcs): Delete.
+       (test_cli_utils): Don't call deleted functions.
+
 2019-06-13  Pedro Alves  <palves@redhat.com>
 
        * thread.c: Include "cli/cli-option.h".
index 30d4091a0d1914b2ca999541cd2741dfdcf2c536..f5d47aeffbc0e1eb3ca0095a76c980fb42e567ca 100644 (file)
@@ -524,62 +524,6 @@ check_for_argument (const char **str, const char *arg, int arg_len)
 
 /* See documentation in cli-utils.h.  */
 
-int
-parse_flags (const char **str, const char *flags)
-{
-  const char *p = skip_spaces (*str);
-
-  if (p[0] == '-'
-      && isalpha (p[1])
-      && (p[2] == '\0' || isspace (p[2])))
-    {
-      const char pf = p[1];
-      const char *f = flags;
-
-      while (*f != '\0')
-       {
-         if (*f == pf)
-           {
-             *str = skip_spaces (p + 2);
-             return f - flags + 1;
-           }
-         f++;
-       }
-    }
-
-  return 0;
-}
-
-/* See documentation in cli-utils.h.  */
-
-bool
-parse_flags_qcs (const char *which_command, const char **str,
-                qcs_flags *flags)
-{
-  switch (parse_flags (str, "qcs"))
-    {
-    case 0:
-      return false;
-    case 1:
-      flags->quiet = true;
-      break;
-    case 2:
-      flags->cont = true;
-      break;
-    case 3:
-      flags->silent = true;
-      break;
-    default:
-      gdb_assert_not_reached ("int qcs flag out of bound");
-    }
-
-  validate_flags_qcs (which_command, flags);
-
-  return true;
-}
-
-/* See documentation in cli-utils.h.  */
-
 void
 validate_flags_qcs (const char *which_command, qcs_flags *flags)
 {
index e6b877d5ab7b34efedc4807195f578a67eb5b7c3..c2a0f374a6e0d3d30327298a41c956fc7c2ba8b2 100644 (file)
@@ -220,15 +220,6 @@ check_for_argument (char **str, const char *arg)
   return check_for_argument (str, arg, strlen (arg));
 }
 
-/* A helper function that looks for a set of flags at the start of a
-   string.  The possible flags are given as a null terminated string.
-   A flag in STR must either be at the end of the string,
-   or be followed by whitespace.
-   Returns 0 if no valid flag is found at the start of STR.
-   Otherwise updates *STR, and returns N (which is > 0),
-   such that FLAGS [N - 1] is the valid found flag.  */
-extern int parse_flags (const char **str, const char *flags);
-
 /* qcs_flags struct groups the -q, -c, and -s flags parsed by "thread
    apply" and "frame apply" commands */
 
@@ -239,27 +230,6 @@ struct qcs_flags
   int silent = false;
 };
 
-/* A helper function that uses parse_flags to handle the flags qcs :
-     A flag -q sets FLAGS->QUIET to true.
-     A flag -c sets FLAGS->CONT to true.
-     A flag -s sets FLAGS->SILENT to true.
-
-   The caller is responsible to initialize *FLAGS to false before the (first)
-   call to parse_flags_qcs.
-   parse_flags_qcs can then be called iteratively to search for more
-   valid flags, as part of a 'main parsing loop' searching for -q/-c/-s
-   flags together with other flags and options.
-
-   Returns true and updates *STR and one of FLAGS->QUIET, FLAGS->CONT,
-   FLAGS->SILENT if it finds a valid flag.
-   Returns false if no valid flag is found at the beginning of STR.
-
-   Throws an error if a flag is found such that both FLAGS->CONT and
-   FLAGS->SILENT are true.  */
-
-extern bool parse_flags_qcs (const char *which_command, const char **str,
-                            qcs_flags *flags);
-
 /* Validate FLAGS.  Throws an error if both FLAGS->CONT and
    FLAGS->SILENT are true.  WHICH_COMMAND is included in the error
    message.  */
index 99b98bf8cd1b6007a256bcae1e0e3a050adb3a53..a251a8e58f84a386b5b5cd2e2688cedb15db179f 100644 (file)
@@ -101,143 +101,10 @@ test_number_or_range_parser ()
   }
 }
 
-static void
-test_parse_flags ()
-{
-  const char *flags = "abc";
-  const char *non_flags_args = "non flags args";
-
-  /* Extract twice the same flag, separated by one space.  */
-  {
-    const char *t1 = "-a -a non flags args";
-
-    SELF_CHECK (parse_flags (&t1, flags) == 1);
-    SELF_CHECK (parse_flags (&t1, flags) == 1);
-    SELF_CHECK (strcmp (t1, non_flags_args) == 0);
-  }
-
-  /* Extract some flags, separated by one or more spaces.  */
-  {
-    const char *t2 = "-c     -b -c  -b -c    non flags args";
-
-    SELF_CHECK (parse_flags (&t2, flags) == 3);
-    SELF_CHECK (parse_flags (&t2, flags) == 2);
-    SELF_CHECK (parse_flags (&t2, flags) == 3);
-    SELF_CHECK (parse_flags (&t2, flags) == 2);
-    SELF_CHECK (parse_flags (&t2, flags) == 3);
-    SELF_CHECK (strcmp (t2, non_flags_args) == 0);
-  }
-
-  /* Check behaviour where there is no flag to extract.  */
-  {
-    const char *t3 = non_flags_args;
-
-    SELF_CHECK (parse_flags (&t3, flags) == 0);
-    SELF_CHECK (strcmp (t3, non_flags_args) == 0);
-  }
-
-  /* Extract 2 known flags in front of unknown flags.  */
-  {
-    const char *t4 = "-c -b -x -y -z -c";
-
-    SELF_CHECK (parse_flags (&t4, flags) == 3);
-    SELF_CHECK (parse_flags (&t4, flags) == 2);
-    SELF_CHECK (strcmp (t4, "-x -y -z -c") == 0);
-    SELF_CHECK (parse_flags (&t4, flags) == 0);
-    SELF_CHECK (strcmp (t4, "-x -y -z -c") == 0);
-  }
-
-  /* Check combined flags are not recognised.  */
-  {
-    const char *t5 = "-c -cb -c";
-
-    SELF_CHECK (parse_flags (&t5, flags) == 3);
-    SELF_CHECK (parse_flags (&t5, flags) == 0);
-    SELF_CHECK (strcmp (t5, "-cb -c") == 0);
-  }
-}
-
-static void
-test_parse_flags_qcs ()
-{
-  const char *non_flags_args = "non flags args";
-
-  /* Test parsing of 2 flags out of the known 3.  */
-  {
-    const char *t1 = "-q -s    non flags args";
-    qcs_flags flags;
-
-    SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t1.q",
-                                &t1,
-                                &flags) == 1);
-    SELF_CHECK (flags.quiet && !flags.cont && !flags.silent);
-    SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t1.s",
-                                &t1,
-                                &flags) == 1);
-    SELF_CHECK (flags.quiet && !flags.cont && flags.silent);
-    SELF_CHECK (strcmp (t1, non_flags_args) == 0);
-  }
-
-  /* Test parsing when there is no flag.  */
-  {
-    const char *t2 = "non flags args";
-    qcs_flags flags;
-
-    SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t2",
-                                &t2,
-                                &flags) == 0);
-    SELF_CHECK (!flags.quiet && !flags.cont && !flags.silent);
-    SELF_CHECK (strcmp (t2, non_flags_args) == 0);
-  }
-
-  /* Test parsing stops at a negative integer.  */
-  {
-    const char *t3 = "-123 non flags args";
-    const char *orig_t3 = t3;
-    qcs_flags flags;
-
-    SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t3",
-                                &t3,
-                                &flags) == 0);
-    SELF_CHECK (!flags.quiet && !flags.cont && !flags.silent);
-    SELF_CHECK (strcmp (t3, orig_t3) == 0);
-  }
-
-  /* Test mutual exclusion between -c and -s.  */
-  {
-    const char *t4 = "-c -s non flags args";
-    qcs_flags flags;
-
-    try
-      {
-       SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t4.cs",
-                                    &t4,
-                                    &flags) == 1);
-
-       (void) parse_flags_qcs ("test_parse_flags_qcs.t4.cs",
-                               &t4,
-                               &flags);
-       SELF_CHECK (false);
-      }
-    catch (const gdb_exception_error &ex)
-      {
-       SELF_CHECK (ex.reason == RETURN_ERROR);
-       SELF_CHECK (ex.error == GENERIC_ERROR);
-       SELF_CHECK
-         (strcmp (ex.what (),
-                  "test_parse_flags_qcs.t4.cs: "
-                  "-c and -s are mutually exclusive") == 0);
-      }
-  }
-
-}
-
 static void
 test_cli_utils ()
 {
   selftests::cli_utils::test_number_or_range_parser ();
-  selftests::cli_utils::test_parse_flags ();
-  selftests::cli_utils::test_parse_flags_qcs ();
 }
 
 }
This page took 0.032938 seconds and 4 git commands to generate.