[gobject-introspection] giscanner: Make sure that the current path set from linemarks is also a real path
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Make sure that the current path set from linemarks is also a real path
- Date: Fri, 15 Nov 2013 08:28:18 +0000 (UTC)
commit 562258d22f983b135cfc5031cb023d6b07473150
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Thu Nov 14 18:25:00 2013 +0100
giscanner: Make sure that the current path set from linemarks is also a real path
This fixes the case when the include path doesn't contain any symlink,
but the path built by the preprocessor does.
https://bugzilla.gnome.org/show_bug.cgi?id=712211
giscanner/scannerlexer.l | 56 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index 7734938..f80a8d6 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -36,6 +36,10 @@
#include "sourcescanner.h"
#include "scannerparser.h"
+#ifdef USE_WINDOWS
+#include <windows.h>
+#endif
+
int lineno;
char linebuf[2000];
@@ -313,6 +317,47 @@ check_identifier (GISourceScanner *scanner,
return IDENTIFIER;
}
+static inline char *
+_realpath (const char *path)
+{
+#ifndef _WIN32
+ char buffer[1025];
+
+ return realpath (path, buffer) ? g_strdup (buffer) : NULL;
+#else
+ /* We don't want to include <windows.h> as it clashes horribly
+ * with token names from scannerparser.h. So just declare
+ * GetFullPathNameA() here unless we already defined it, like
+ * in giscanner.c.
+ */
+#ifndef USE_WINDOWS
+ extern __stdcall GetFullPathNameA(const char*, int, char*, char**);
+#endif
+ char *buffer;
+ char dummy;
+ int rc, len;
+
+ rc = GetFullPathNameA (path, 1, &dummy, NULL);
+ if (rc == 0)
+ {
+ /* Weird failure, so just return the input path as such */
+ return g_strdup (path);
+ }
+
+ len = rc + 1;
+ buffer = g_malloc (len);
+
+ rc = GetFullPathNameA (path, len, buffer, NULL);
+ if (rc == 0 || rc > len)
+ {
+ /* Weird failure again */
+ g_free (buffer);
+ return g_strdup (path);
+ }
+ return buffer;
+#endif
+}
+
/*
* # linenum "filename" flags
* See http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
@@ -323,10 +368,19 @@ process_linemarks (GISourceScanner *scanner)
{
char escaped_filename[1025];
char *filename;
+ char *real;
sscanf(yytext, "# %d \"%1024[^\"]\"", &lineno, escaped_filename);
filename = g_strcompress (escaped_filename);
- g_object_unref (scanner->current_file);
+
+ real = _realpath (filename);
+ if (real)
+ {
+ g_free (filename);
+ filename = real;
+ }
+
+ g_object_unref (scanner->current_file);
scanner->current_file = g_file_new_for_path (filename);
g_free (filename);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]