Mail Archives: djgpp-workers/2001/02/21/17:33:32
This is a patch for DJGPP's cvs tree.
It is needed to resolve the name conflict existing between GNU gettext()
and Borland-compatibility gettext(). To solve this conflict, Borland-
compatibility gettext() must be renamed.
In conio.[ch] I have renamed gettext to _conio_gettext.
In conio.h I have added same minor code that will check if libintl.h has
also been included. In this case, gettext from conio.h will **only** be
available as _conio_gettext. In the case that both headers, conio.h and
libintl.h, have been included by the same source file, the gettext keyword
will always make reference to GNU gettext() and Borland-compatibility
gettext() will only be available as _conio_gettext().
This has the following concequences for the user:
1) The user wants to use BORLAND-compatibility gettext from conio.h only.
In this case the user must include conio.h in the source file and the
gettext keyword makes *always* reference to BORLAND-compatibility gettext.
There are no user visible changes at all.
2) The user wants to use GNU gettext from libintl.h only.
In this case the user must include libintl.h in the source file and the
gettext keyword makes *always* reference to GNU gettext.
There are no user visible changes at all.
3) The user wants to use both gettext functions in the same source file.
In this case both headers, libintl.h and conio.h, must be included in the
source file and the keyword gettext makes **always** reference to
GNU gettext and **never** to BORLAND-compatibility gettext.
To use the BORLAND-compatibility gettext in this case the user must use
the keyword: _conio_gettext instead of gettext.
Regards,
Guerrero, Juan Manuel
diff -acprNC5 djgpp.orig/include/conio.h djgpp/include/conio.h
*** djgpp.orig/include/conio.h Wed Feb 21 12:40:52 2001
--- djgpp/include/conio.h Wed Feb 21 22:58:34 2001
*************** enum COLORS {
*** 62,79 ****
void blinkvideo(void);
char * cgets(char *_str);
void clreol(void);
void clrscr(void);
int _conio_kbhit(void); /* checks for ungetch char */
int cprintf(const char *_format, ...) __attribute__((format(printf,1,2)));
int cputs(const char *_str);
int cscanf(const char *_format, ...) __attribute__((format(scanf,1,2)));
void delline(void);
int getch(void);
int getche(void);
- int gettext(int _left, int _top, int _right, int _bottom, void *_destin);
void gettextinfo(struct text_info *_r);
void gotoxy(int _x, int _y);
void gppconio_init(void);
void highvideo(void);
void insline(void);
--- 62,79 ----
void blinkvideo(void);
char * cgets(char *_str);
void clreol(void);
void clrscr(void);
+ int _conio_gettext(int _left, int _top, int _right, int _bottom, void *_destin);
int _conio_kbhit(void); /* checks for ungetch char */
int cprintf(const char *_format, ...) __attribute__((format(printf,1,2)));
int cputs(const char *_str);
int cscanf(const char *_format, ...) __attribute__((format(scanf,1,2)));
void delline(void);
int getch(void);
int getche(void);
void gettextinfo(struct text_info *_r);
void gotoxy(int _x, int _y);
void gppconio_init(void);
void highvideo(void);
void insline(void);
*************** void window(int _left, int _top, int
*** 96,105 ****
--- 96,115 ----
#define kbhit _conio_kbhit /* Who ever includes gppconio.h probably
also wants _conio_kbhit and not kbhit
from libc */
+ /* This is to resolve the name clash between
+ gettext from conio.h and gettext from libintl.h.
+ IMPORTANT:
+ If both headers are included, gettext from libintl.h
+ takes ALWAYS precedence over gettext from conio.h. */
+ #ifndef __LIBINTL_H_INCLUDED__
+ # undef gettext
+ # define gettext _conio_gettext
+ #endif
+
#endif /* !_POSIX_SOURCE */
#endif /* !__STRICT_ANSI__ */
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
#ifndef __dj_ENFORCE_FUNCTION_CALLS
diff -acprNC5 djgpp.orig/src/libc/pc_hw/co80/conio.c djgpp/src/libc/pc_hw/co80/conio.c
*** djgpp.orig/src/libc/pc_hw/co80/conio.c Wed Feb 21 12:39:04 2001
--- djgpp/src/libc/pc_hw/co80/conio.c Wed Feb 21 23:02:24 2001
*************** puttext(int c, int r, int c2, int r2, vo
*** 88,98 ****
}
return 1;
}
int
! gettext(int c, int r, int c2, int r2, void *buf)
{
short *cbuf = (short *)buf;
/* we should check for valid parameters, and maybe return 0 */
r--, r2--, c--, c2--;
for (; r <= r2; r++)
--- 88,98 ----
}
return 1;
}
int
! _conio_gettext(int c, int r, int c2, int r2, void *buf)
{
short *cbuf = (short *)buf;
/* we should check for valid parameters, and maybe return 0 */
r--, r2--, c--, c2--;
for (; r <= r2; r++)
*************** cscanf(const char *fmt, ...)
*** 729,739 ****
int
movetext(int left, int top, int right, int bottom, int dleft, int dtop)
{
char *buf = alloca((right - left + 1) * (bottom - top + 1) * 2);
! gettext(left, top, right, bottom, buf);
puttext(dleft, dtop, dleft + right - left, dtop + bottom - top, buf);
return 1;
}
static void
--- 729,739 ----
int
movetext(int left, int top, int right, int bottom, int dleft, int dtop)
{
char *buf = alloca((right - left + 1) * (bottom - top + 1) * 2);
! _conio_gettext(left, top, right, bottom, buf);
puttext(dleft, dtop, dleft + right - left, dtop + bottom - top, buf);
return 1;
}
static void
diff -acprNC5 djgpp.orig/src/libc/pc_hw/co80/conio.txh djgpp/src/libc/pc_hw/co80/conio.txh
*** djgpp.orig/src/libc/pc_hw/co80/conio.txh Wed Feb 21 12:39:24 2001
--- djgpp/src/libc/pc_hw/co80/conio.txh Wed Feb 21 23:05:26 2001
*************** The line the cursor is on is deleted; li
*** 243,252 ****
--- 243,274 ----
@subheading Portability
@portability !ansi, !posix
@c ----------------------------------------------------------------------
+ @node _conio_gettext, conio
+ @subheading Syntax
+
+ @example
+ #include <conio.h>
+
+ int _conio_gettext(int _left, int _top, int _right, int _bottom, void *_destin);
+ @end example
+
+ @subheading Description
+
+ Retrieve a block of screen characters into a buffer.
+
+ @subheading Return Value
+
+ 1
+
+ @subheading Portability
+
+ @portability !ansi, !posix
+
+ @c ----------------------------------------------------------------------
@node gettext, conio
@subheading Syntax
@example
#include <conio.h>
*************** int gettext(int _left, int _top, int
*** 256,265 ****
--- 278,297 ----
@end example
@subheading Description
Retrieve a block of screen characters into a buffer.
+ @code{gettext} is a macro defined in @code{conio.h} that will expand
+ into @ref{_conio_gettext}. This is needed to resolve the name conflict
+ existing between the @code{gettext} function from @code{libintl.a}
+ defined in @code{libintl.h} and this one defined in @code{conio.h}.
+ If you want to use both @code{gettext} functions in the same source file
+ you must use @ref{_conio_gettext} to get the @code{gettext} function from
+ @code{conio.h}.
+ This means that if both headers are included in the same source file the
+ @code{gettext} keyword will always make reference to the @code{gettext}
+ function from @code{libintl.h}.
@subheading Return Value
1
- Raw text -