+/* See description in linespec.h. */
+
+void
+linespec_lex_to_end (char **stringp)
+{
+ linespec_parser parser;
+ struct cleanup *cleanup;
+ linespec_token token;
+ const char *orig;
+
+ if (stringp == NULL || *stringp == NULL)
+ return;
+
+ linespec_parser_new (&parser, 0, current_language, NULL, 0, NULL);
+ cleanup = make_cleanup (linespec_parser_delete, &parser);
+ parser.lexer.saved_arg = *stringp;
+ PARSER_STREAM (&parser) = orig = *stringp;
+
+ do
+ {
+ /* Stop before any comma tokens; we need it to keep it
+ as the next token in the string. */
+ token = linespec_lexer_peek_token (&parser);
+ if (token.type == LSTOKEN_COMMA)
+ break;
+ token = linespec_lexer_consume_token (&parser);
+ }
+ while (token.type != LSTOKEN_EOI && token.type != LSTOKEN_KEYWORD);
+
+ *stringp += PARSER_STREAM (&parser) - orig;
+ do_cleanups (cleanup);
+}
+
+/* A helper function for decode_line_full and decode_line_1 to
+ turn LOCATION into symtabs_and_lines. */
+
+static struct symtabs_and_lines
+event_location_to_sals (linespec_parser *parser,
+ const struct event_location *location)
+{
+ struct symtabs_and_lines result = {NULL, 0};
+
+ switch (event_location_type (location))
+ {
+ case LINESPEC_LOCATION:
+ {
+ PARSER_STATE (parser)->is_linespec = 1;
+ TRY
+ {
+ result = parse_linespec (parser, get_linespec_location (location));
+ }
+ CATCH (except, RETURN_MASK_ERROR)
+ {
+ throw_exception (except);
+ }
+ END_CATCH
+ }
+ break;
+
+ case ADDRESS_LOCATION:
+ result
+ = convert_address_location_to_sals (PARSER_STATE (parser),
+ get_address_location (location));
+ break;
+
+ case EXPLICIT_LOCATION:
+ {
+ const struct explicit_location *explicit_loc;
+
+ explicit_loc = get_explicit_location_const (location);
+ result = convert_explicit_location_to_sals (PARSER_STATE (parser),
+ PARSER_RESULT (parser),
+ explicit_loc);
+ }
+ break;
+
+ case PROBE_LOCATION:
+ /* Probes are handled by their own decoders. */
+ gdb_assert_not_reached ("attempt to decode probe location");
+ break;
+
+ default:
+ gdb_assert_not_reached ("unhandled event location type");
+ }
+
+ return result;
+}
+