This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/5] Introduce build_debug_file_name
- From: Eli Zaretskii <eliz at gnu dot org>
- To: Gary Benson <gbenson at redhat dot com>
- Cc: gdb-patches at sourceware dot org, cedric dot buissart at gmail dot com
- Date: Tue, 16 Jun 2015 17:46:57 +0300
- Subject: Re: [PATCH 1/5] Introduce build_debug_file_name
- Authentication-results: sourceware.org; auth=none
- References: <1434447768-17328-1-git-send-email-gbenson at redhat dot com> <1434447768-17328-2-git-send-email-gbenson at redhat dot com>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> From: Gary Benson <gbenson@redhat.com>
> Cc: Cédric Buissart <cedric.buissart@gmail.com>
> Date: Tue, 16 Jun 2015 10:42:44 +0100
>
> +/* Build the filename of a separate debug file from an arbitrary
> + number of components. Returns an xmalloc'd string that must
> + be be freed by the caller. The final argument of this function
> + must be NULL to mark the end the argument list. */
> +
> +static char *
> +build_debug_file_name (const char *first, ...)
> +{
> + va_list ap;
> + const char *arg, *last;
> + VEC (char_ptr) *args = NULL;
> + struct cleanup *back_to = make_cleanup_free_char_ptr_vec (args);
> + int bufsiz = 0;
> + char *buf, *tmp;
> + int i;
> +
> + va_start (ap, first);
> + for (arg = first; arg; arg = va_arg (ap, const char *))
> + last = arg;
> + va_end (ap);
> +
> + va_start (ap, first);
> + for (arg = first; arg; arg = va_arg (ap, const char *))
> + {
> + if (arg == last)
> + tmp = xstrdup (arg);
> + else
> + {
> + int len;
> +
> + /* Strip leading separators from subdirectories. */
> + if (arg != first)
> + {
> + while (*arg != '\0' && IS_DIR_SEPARATOR (*arg))
> + arg++;
> + }
> +
> + /* Strip trailing separators. */
> + len = strlen (arg);
> +
> + while (len > 0 && IS_DIR_SEPARATOR (arg[len - 1]))
> + len--;
Was this logic tested with Windows-style "d:/foo" file names? E.g.,
what will happen if the first component is "d:/"?
Thanks.