From 10085bb5ab70a5f2761657ac83c1b83bbad97ead Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 19 Apr 2009 18:29:34 +0000 Subject: [PATCH] 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. --- gdb/ChangeLog | 17 +++++++++++++++ gdb/config/djgpp/config.sed | 6 ++++++ gdb/config/djgpp/langinfo.h | 35 ++++++++++++++++++++++++++++++ gdb/config/djgpp/nl_types.h | 25 +++++++++++++++++++++ gdb/config/i386/go32.mh | 4 +++- gdb/go32-nat.c | 43 +++++++++++++++++++++++++++++++++++++ 6 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 gdb/config/djgpp/langinfo.h create mode 100644 gdb/config/djgpp/nl_types.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a46ddeaa894..43407dba0c0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2009-04-19 Eli Zaretskii + + 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. + 2009-04-18 Carlos O'Donell * Makefile.in (MAKEHTML): Set to makeinfo --html. diff --git a/gdb/config/djgpp/config.sed b/gdb/config/djgpp/config.sed index 536a4454265..98882cfe7fd 100644 --- a/gdb/config/djgpp/config.sed +++ b/gdb/config/djgpp/config.sed @@ -25,6 +25,12 @@ s|\.gdbinit|gdb.ini|g s,config\\.h\\.in,config.h-in,g;t t\ s,po2tbl\\.sed\\.in,po2tblsed.in,g;t t +# We have an emulation of nl_langinfo in go32-nat.c that supports CODESET. +/^ac_cv_env_CPP_value=/a\ +am_cv_langinfo_codeset=yes\ +bash_cv_langinfo_codeset=yes\ +ac_cv_header_nl_types_h=yes + # Prevent splitting of config.status substitutions, because that # might break multi-line sed commands. /ac_max_sed_lines=[0-9]/s,=.*$,=`sed -n "$=" $tmp/subs.sed`, diff --git a/gdb/config/djgpp/langinfo.h b/gdb/config/djgpp/langinfo.h new file mode 100644 index 00000000000..631f3603ec7 --- /dev/null +++ b/gdb/config/djgpp/langinfo.h @@ -0,0 +1,35 @@ +/* langinfo.h file for DJGPP. + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Eli Zaretskii. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _LANGINFO_H +#define _LANGINFO_H + +#include + +enum { + CODESET, + /* Number of enumerated values. */ + _NL_NUM +}; + +#define CODESET CODESET + +extern char *nl_langinfo (nl_item); + +#endif /* _LANGINFO_H */ diff --git a/gdb/config/djgpp/nl_types.h b/gdb/config/djgpp/nl_types.h new file mode 100644 index 00000000000..012b5fa5dee --- /dev/null +++ b/gdb/config/djgpp/nl_types.h @@ -0,0 +1,25 @@ +/* nl_types.h for DJGPP. + Copyright (C) 2009 Free Software Foundation, Inc. + Written by Eli Zaretskii. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _NL_TYPES_H +#define _NL_TYPES_H + +typedef int nl_item; + +#endif /* _NL_TYPES_H */ diff --git a/gdb/config/i386/go32.mh b/gdb/config/i386/go32.mh index c488ab20ed9..73dc70ecdff 100644 --- a/gdb/config/i386/go32.mh +++ b/gdb/config/i386/go32.mh @@ -1,5 +1,7 @@ # Host: Intel x86 running DJGPP -MH_CFLAGS= + +# We include several header files from config/djgpp +MH_CFLAGS= -I$(srcdir)/config/djgpp NAT_FILE= nm-go32.h NATDEPFILES= go32-nat.o i386-nat.o diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 267df62b343..e49125f36dc 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -53,6 +53,8 @@ #include #endif +#include + #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, ®s); + 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. */ -- 2.30.2