aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-05-05 16:55:28 +0000
committerNick Clifton <nickc@redhat.com>2006-05-05 16:55:28 +0000
commit56487c5507bb8501767f5f63963107dfef1308fa (patch)
tree622b75ddf1f0e53a82d10776eeeb9d51f39ad94b /gas
parentef75f0145e5e0255be469edad543db0bacf338af (diff)
downloadfsf-binutils-gdb-56487c5507bb8501767f5f63963107dfef1308fa.zip
fsf-binutils-gdb-56487c5507bb8501767f5f63963107dfef1308fa.tar.gz
fsf-binutils-gdb-56487c5507bb8501767f5f63963107dfef1308fa.tar.bz2
PR gas/2582
* dwarf2dbg.c (INSERT_DIR_SEPARATOR): New macro. Handles the insertion of a directory separator character into a string at a given offset. Uses heuristics to decide when to use a backslash character rather than a forward-slash character. (dwarf2_directive_loc): Use the macro. (out_debug_info): Likewise.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog10
-rw-r--r--gas/dwarf2dbg.c27
2 files changed, 35 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6bac5b5..82de3cc 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,13 @@
+2006-05-05 Nick Clifton <nickc@redhat.com>
+
+ PR gas/2582
+ * dwarf2dbg.c (INSERT_DIR_SEPARATOR): New macro. Handles the
+ insertion of a directory separator character into a string at a
+ given offset. Uses heuristics to decide when to use a backslash
+ character rather than a forward-slash character.
+ (dwarf2_directive_loc): Use the macro.
+ (out_debug_info): Likewise.
+
2006-05-05 Thiemo Seufer <ths@mips.com>
David Ung <davidu@mips.com>
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 661962f..65a0a26 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -46,6 +46,29 @@
#include "dwarf2dbg.h"
#include <filenames.h>
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+/* We need to decide which character to use as a directory separator.
+ Just because HAVE_DOS_BASED_FILE_SYSTEM is defined, it does not
+ necessarily mean that the backslash character is the one to use.
+ Some environments, eg Cygwin, can support both naming conventions.
+ So we use the heuristic that we only need to use the backslash if
+ the path is an absolute path starting with a DOS style drive
+ selector. eg C: or D: */
+# define INSERT_DIR_SEPARATOR(string, offset) \
+ do \
+ { \
+ if (offset > 1 \
+ && string[0] != 0 \
+ && string[1] == ':') \
+ string [offset] = '\\'; \
+ else \
+ string [offset] = '/'; \
+ } \
+ while (0)
+#else
+# define INSERT_DIR_SEPARATOR(string, offset) string[offset] = '/'
+#endif
+
#ifndef DWARF2_FORMAT
# define DWARF2_FORMAT() dwarf2_format_32bit
#endif
@@ -569,7 +592,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
char *cp = (char *) alloca (dir_len + 1 + file_len + 1);
memcpy (cp, dirs[files[filenum].dir], dir_len);
- cp[dir_len] = '/';
+ INSERT_DIR_SEPARATOR (cp, dir_len);
memcpy (cp + dir_len + 1, files[filenum].filename, file_len);
cp[dir_len + file_len + 1] = '\0';
listing_source_file (cp);
@@ -1464,7 +1487,7 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg)
len = strlen (dirs[files[1].dir]);
p = frag_more (len + 1);
memcpy (p, dirs[files[1].dir], len);
- p[len] = '/';
+ INSERT_DIR_SEPARATOR (p, len);
}
len = strlen (files[1].filename) + 1;
p = frag_more (len);