/* Shared general utility routines for GDB, the GNU debugger.
- Copyright (C) 1986-2015 Free Software Foundation, Inc.
+ Copyright (C) 1986-2016 Free Software Foundation, Inc.
This file is part of GDB.
#ifndef COMMON_UTILS_H
#define COMMON_UTILS_H
+#include <string>
+
/* If possible, define FUNCTION_NAME, a macro containing the name of
the function being defined. Since this macro may not always be
defined, all uses must be protected by appropriate macro definition
int xsnprintf (char *str, size_t size, const char *format, ...)
ATTRIBUTE_PRINTF (3, 4);
+/* Returns a std::string built from a printf-style format string. */
+std::string string_printf (const char* fmt, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
/* Make a copy of the string at PTR with LEN characters
(and add a null character at the end in the copy).
Uses malloc to get the space. Returns the address of the copy. */
return strncmp (string, pattern, strlen (pattern)) == 0;
}
+ULONGEST strtoulst (const char *num, const char **trailer, int base);
+
+/* Skip leading whitespace characters in INP, returning an updated
+ pointer. If INP is NULL, return NULL. */
+
+extern char *skip_spaces (char *inp);
+
+/* A const-correct version of the above. */
+
+extern const char *skip_spaces_const (const char *inp);
+
+/* Skip leading non-whitespace characters in INP, returning an updated
+ pointer. If INP is NULL, return NULL. */
+
+#define skip_to_space(INP) ((char *) skip_to_space_const (INP))
+
+/* A const-correct version of the above. */
+
+extern const char *skip_to_space_const (const char *inp);
+
#endif