Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: gdb/utils.c

Issue 16339009: Switch gdb command parameters parsing algorithm from UNIX rules to Windows rules. (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/utils.c
diff --git a/gdb/utils.c b/gdb/utils.c
index 556614996b8bc14a804c105e210ebfe80c010b4f..fa7a6ac22cb8fe66b6381bff47ceda6678e16ae3 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -78,6 +78,10 @@
#include "interps.h"
#include "gdb_regex.h"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#endif
+
#if !HAVE_DECL_MALLOC
extern PTR malloc (); /* ARI: PTR */
#endif
@@ -165,6 +169,20 @@ show_pagination_enabled (struct ui_file *file, int from_tty,
}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+static void
+do_freeargv (void *arg)
+{
+ int i = 0;
+ char** args = (char**) arg;
+ for (i = 0; args[i] != NULL; i++)
+ free(args[i]);
+ free(args);
+}
+
+#else
+
/* Cleanup utilities.
These are not defined in cleanups.c (nor declared in cleanups.h)
@@ -177,6 +195,8 @@ do_freeargv (void *arg)
freeargv ((char **) arg);
}
+#endif
+
struct cleanup *
make_cleanup_freeargv (char **arg)
{
@@ -3480,6 +3500,45 @@ ldirname (const char *filename)
return dirname;
}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+char **
+gdb_buildargv (const char *s)
+{
+ LPWSTR wide_string;
+ int wide_len;
+ int arg_len;
+ int num_args;
+ LPWSTR* args;
+ char** result;
+ int i;
+ if (s == NULL)
+ return NULL;
+ wide_len = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0);
+ wide_string = malloc(2 * wide_len);
+ if (wide_string == NULL)
+ malloc_failure (0);
+ MultiByteToWideChar(CP_UTF8, 0, s, -1, wide_string, wide_len);
+ args = CommandLineToArgvW(wide_string, &num_args);
+ free(wide_string);
+ result = malloc((num_args + 1) * sizeof(char*));
+ for (i = 0; i < num_args; i++)
+ {
+ arg_len = WideCharToMultiByte(CP_UTF8, 0, args[i], -1, NULL, 0,
+ NULL, NULL);
+ result[i] = malloc(arg_len);
+ if (result[i] == NULL)
+ malloc_failure(0);
+ WideCharToMultiByte(CP_UTF8, 0, args[i], -1, result[i], arg_len,
+ NULL, NULL);
+ }
+ result[num_args] = NULL;
+ LocalFree(args);
+ return result;
+}
+
+#else
+
/* Call libiberty's buildargv, and return the result.
If buildargv fails due to out-of-memory, call nomem.
Therefore, the returned value is guaranteed to be non-NULL,
@@ -3495,6 +3554,8 @@ gdb_buildargv (const char *s)
return argv;
}
+#endif
+
int
compare_positive_ints (const void *ap, const void *bp)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698