Rename _const functions to use overloading instead
[deliverable/binutils-gdb.git] / gdb / cli / cli-utils.h
index 3188bb78df03d3bb4cd506b0ea8e487d6837553a..0c25a7e21e6bb43a4831bf95c0ad5f1389e4a5d6 100644 (file)
@@ -1,6 +1,6 @@
 /* CLI utilities.
 
-   Copyright (C) 2011-2016 Free Software Foundation, Inc.
+   Copyright (C) 2011-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -33,9 +33,9 @@ extern int get_number_trailer (const char **pp, int trailer);
 
 /* Convenience.  Like get_number_trailer, but with no TRAILER.  */
 
-extern int get_number_const (const char **);
+extern int get_number (const char **);
 
-/* Like get_number_const, but takes a non-const "char **".  */
+/* Like the above, but takes a non-const "char **".  */
 
 extern int get_number (char **);
 
@@ -137,7 +137,16 @@ extern int number_is_in_list (const char *list, int number);
 /* Reverse S to the last non-whitespace character without skipping past
    START.  */
 
-extern char *remove_trailing_whitespace (const char *start, char *s);
+extern const char *remove_trailing_whitespace (const char *start,
+                                              const char *s);
+
+/* Same, for non-const S.  */
+
+static inline char *
+remove_trailing_whitespace (const char *start, char *s)
+{
+  return (char *) remove_trailing_whitespace (start, (const char *) s);
+}
 
 /* A helper function to extract an argument from *ARG.  An argument is
    delimited by whitespace.  The return value is either NULL if no
@@ -145,17 +154,26 @@ extern char *remove_trailing_whitespace (const char *start, char *s);
 
 extern char *extract_arg (char **arg);
 
-/* A const-correct version of "extract_arg".
+/* A const-correct version of the above.
 
    Since the returned value is xmalloc'd, it eventually needs to be
    xfree'ed, which prevents us from making it const as well.  */
 
-extern char *extract_arg_const (const char **arg);
+extern char *extract_arg (const char **arg);
 
 /* A helper function that looks for an argument at the start of a
    string.  The argument must also either be at the end of the string,
    or be followed by whitespace.  Returns 1 if it finds the argument,
    0 otherwise.  If the argument is found, it updates *STR.  */
-extern int check_for_argument (char **str, char *arg, int arg_len);
+extern int check_for_argument (const char **str, const char *arg, int arg_len);
+
+/* Same, for non-const STR.  */
+
+static inline int
+check_for_argument (char **str, const char *arg, int arg_len)
+{
+  return check_for_argument (const_cast<const char **> (str),
+                            arg, arg_len);
+}
 
 #endif /* CLI_UTILS_H */
This page took 0.027359 seconds and 4 git commands to generate.