aboutsummaryrefslogtreecommitdiff
path: root/gdb/go32-nat.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2009-04-19 18:29:34 +0000
committerEli Zaretskii <eliz@gnu.org>2009-04-19 18:29:34 +0000
commit10085bb5ab70a5f2761657ac83c1b83bbad97ead (patch)
tree712ac129489bd2e797f8b9dfb286ba3e19823a21 /gdb/go32-nat.c
parent155c8968d95e27131a80ae95bf6230ba2e19693b (diff)
downloadgdb-10085bb5ab70a5f2761657ac83c1b83bbad97ead.zip
gdb-10085bb5ab70a5f2761657ac83c1b83bbad97ead.tar.gz
gdb-10085bb5ab70a5f2761657ac83c1b83bbad97ead.tar.bz2
Set default host and target charsets in the DJGPP port.
* config/djgpp/config.sed (am_cv_langinfo_codeset) (bash_cv_langinfo_codeset, ac_cv_header_nl_types_h): Set to "yes" in all configure scripts that define ac_cv_env_CPP_value. * go32-nat.c (dos_codepage, nl_langinfo): New functions. Include langinfo.h. * config/djgpp/nl_types.h: New file. * config/djgpp/langinfo.h: New file. * config/i386/go32.mh (MH_CFLAGS): Add $(srcdir)/config/djgpp.
Diffstat (limited to 'gdb/go32-nat.c')
-rw-r--r--gdb/go32-nat.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 267df62..e49125f 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -53,6 +53,8 @@
#include <debug/redir.h>
#endif
+#include <langinfo.h>
+
#if __DJGPP_MINOR__ < 3
/* This code will be provided from DJGPP 2.03 on. Until then I code it
here */
@@ -938,6 +940,47 @@ init_go32_ops (void)
strcpy (gdbinit, "gdb.ini");
}
+/* Return the current DOS codepage number. */
+static int
+dos_codepage (void)
+{
+ __dpmi_regs regs;
+
+ regs.x.ax = 0x6601;
+ __dpmi_int (0x21, &regs);
+ if (!(regs.x.flags & 1))
+ return regs.x.bx & 0xffff;
+ else
+ return 437; /* default */
+}
+
+/* Limited emulation of `nl_langinfo', for charset.c. */
+char *
+nl_langinfo (nl_item item)
+{
+ char *retval;
+
+ switch (item)
+ {
+ case CODESET:
+ {
+ /* 8 is enough for SHORT_MAX + "CP" + null. */
+ char buf[8];
+ int blen = sizeof (buf);
+ int needed = snprintf (buf, blen, "CP%d", dos_codepage ());
+
+ if (needed > blen) /* should never happen */
+ buf[0] = 0;
+ retval = xstrdup (buf);
+ }
+ break;
+ default:
+ retval = xstrdup ("");
+ break;
+ }
+ return retval;
+}
+
unsigned short windows_major, windows_minor;
/* Compute the version Windows reports via Int 2Fh/AX=1600h. */