delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/05/03/14:01:07

From: "Juan Manuel Guerrero" <ST001906 AT HRZ1 DOT HRZ DOT TU-Darmstadt DOT De>
Organization: Darmstadt University of Technology
To: djgpp-workers AT delorie DOT com
Date: Thu, 3 May 2001 19:29:35 +0200
MIME-Version: 1.0
Subject: Patch for solving GNU/BORLAND gettext issue
X-mailer: Pegasus Mail for Windows (v2.54DE)
Message-ID: <2B6B504493@HRZ1.hrz.tu-darmstadt.de>
Reply-To: djgpp-workers AT delorie DOT com

This is a patch to resolve the name conflict existing
between GNU gettext() und BORLAND-compatibility gettext().
The patch is based on GNU gettext 0.10.37 and actual CVS tree.

Regards,
Guerrero, Juan Manuel


diff -acprNC5 djgpp.orig/include/conio.h djgpp/include/conio.h
*** djgpp.orig/include/conio.h	Sun Jul 12 18:16:24 1998
--- djgpp/include/conio.h	Thu May  3 18:05:54 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,118 ----
  
  #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, the gettext keyword will always
+    make reference to the GNU gettext function declared in libintl.h
+    and never to the BORLAND-compatibility gettext function declared
+    in conio.h. In this case, BORLAND-compatibility gettext function
+    will only be available as _conio_gettext. */
+ #ifndef __USE_GNU_GETTEXT
+ # 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/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi
*** djgpp.orig/src/docs/kb/wc204.txi	Sat Mar 31 11:33:42 2001
--- djgpp/src/docs/kb/wc204.txi	Thu May  3 17:25:22 2001
*************** would lose the exit status.
*** 373,377 ****
--- 373,390 ----
  
  @findex select AT r{, and termios emulation}
  File handles connected to the console device are no longer reported by
  the @code{select} function as not ready for input when termios functions
  are used to read those handles in cooked mode.
+ 
+ @findex gettext AT r{, resolving name conflict existing between GNU gettext and Borland-compatibility gettext functions}
+ The Borland-compatibility function @code{gettext} provided by the library
+ has been renamed to @code{_conio_gettext}.  This resolves the name conflict
+ existing between this function and the GNU @code{gettext} function provided
+ by @file{libintl.a}.  The Borland-compatibility function is still available
+ as @code{gettext} as long as the same source file does not include the
+ header file @file{libintl.h}.  If both headers, @file{libintl.h} and
+ @file{conio.h} are included by the same source file, the function name
+ @code{gettext} will always make reference to GNU @code{gettext} and never
+ to Borland-compatibility @code{gettext}.  In this case, the Borland-compatibility
+ function @code{gettext} will only be available as @code{_conio_gettext}.
+ 
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	Thu Jun  3 19:27:36 1999
--- djgpp/src/libc/pc_hw/co80/conio.c	Thu May  3 18:05:54 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	Fri Oct  6 18:56:28 2000
--- djgpp/src/libc/pc_hw/co80/conio.txh	Thu May  3 18:19:44 2001
*************** The line the cursor is on is deleted; li
*** 243,252 ****
--- 243,276 ----
  @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.
+ This is the former @code{gettext} function declared in @file{conio.h}
+ and provided by DJGPP's C library for compatibility with Borland C and
+ other compilers.   @ref{gettext}
+ @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 ****
--- 280,307 ----
  @end example
  
  @subheading Description
  
  Retrieve a block of screen characters into a buffer.
+ To resolve the name conflict existing between this function, provided
+ for compatibility with Borland C and other compilers and the GNU
+ @code{gettext} function from @file{libintl.a} declared in @file{libintl.h},
+ this function has been renamed into @ref{_conio_gettext}.  At the same time,
+ a macro @code{gettext} has been introduced in @file{conio.h} that will
+ expand into @ref{_conio_gettext} if @file{libintl.h} is not included
+ by the same source file.  In this case, the Borland-compatibility
+ @code{gettext} function is still available as @code{gettext}.  If the
+ inclusion of @code{libintl.h} is detected, the macro @code{gettext} will
+ not be defined to @ref{_conio_gettext} at all and the keyword @code{gettext}
+ will be reserved for the GNU @code{gettext} function.  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 by the same source file the
+ @code{gettext} keyword will always make reference to the GNU @code{gettext}
+ function and never to the Borland-compatibility @code{gettext} function.
+ In this case, the Borland-compatibility @code{gettext} function will only
+ be available as @ref{_conio_gettext}.
  
  @subheading Return Value
  
  1
  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019