delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/24/09:33:51

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, 24 Aug 2000 15:29:30 +0200
MIME-Version: 1.0
Subject: GNU gettext and Borland-compatibility gettext
CC: salvador AT inti DOT gov DOT ar, pavenis AT lanet DOT lv
X-mailer: Pegasus Mail for Windows (v2.54DE)
Message-ID: <D4D93E76FAB@HRZ1.hrz.tu-darmstadt.de>
Reply-To: djgpp-workers AT delorie DOT com

I have uploaded to simtel.net an alpha version of the DJGPP port of
GNU gettext. It is available as:
  <ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/alphas/gtxt035b.zip>

The goal of this version is to solve the name conflict existing
between GNU gettext and BORLAND-compatibility gettext. This conflict
can not be resolved without some minor changes to libc.a and the one
system header file.
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 be **only** available as _conio_gettext.
Using the gettext keyword in the case that both headers
has been included makes always reference to GNU 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.

If the gtxt035b.zip package is installed it will create the following
directory:
   %DJDIR%/gnu/gtxt-010.35/djgpp/djdev-2.03
This directory will contain the following files:
   conio.diffs
   conio.h
   conio.o
conio.diffs is a patch based on **djdev203.zip** and **djlsr203.zip**
and can be ignored.
conio.h is the patched header file that must be installed in the include
directory and conio.o is the compiled patched conio.c file. The original
conio.o in libc.a must be replaced by this one.
Once again:
All the files mentioned above have been taken from the stock packages
**djdev203.zip and djlsr203.zip** and are intended for the normal user.

The patch that follows below is intended for the cvs tree.
Unfortunately I have no cvs read access so I had to download the needed files
via cvsweb. The changes are so small that they can be applied manually if the
patch does not work. I have added some text to conio.txi. Due to my
poor english skills feel free to change this text if my explanation
is more confusing than enligthening.

I have succesfully reconfigured and recompiled the following packages
using the new header and libc.a:
bsn128s.zip, fil316s.zip, grep24s.zip, mak3791s.zip, rcode35s.zip,
shl20is.zip, shl20js.zip, tar112as.zip, txi40s.zip, txt20s.zip
and lss340s.zip
AFAIK, lss340s.zip is the only package that uses BORLAND-compatibility
gettext from conio.h. I would seriously appreciate same feedback from
people (Salvador and Andris, perhaps?) that uses gtxt035b.zip so this
issue can be finished once for all. TIA.


Suggestions, comments, etc are welcome.

Regards,
Guerrero, Juan Manuel


diff -acrpNC5 cvs.orig/include/conio.h cvs/include/conio.h
*** cvs.orig/include/conio.h	Mon Aug  7 13:48:58 2000
--- cvs/include/conio.h	Thu Aug 24 14:30:48 2000
*************** 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 __dj_include_libintl_h_
+ # undef  gettext
+ # define gettext _conio_gettext
+ #endif
+ 
  #endif /* !_POSIX_SOURCE */
  #endif /* !__STRICT_ANSI__ */
  #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
  
  #ifndef __dj_ENFORCE_FUNCTION_CALLS
diff -acrpNC5 cvs.orig/src/libc/pc_hw/co80/conio.c cvs/src/libc/pc_hw/co80/conio.c
*** cvs.orig/src/libc/pc_hw/co80/conio.c	Mon Aug  7 13:58:04 2000
--- cvs/src/libc/pc_hw/co80/conio.c	Thu Aug 24 14:31:58 2000
*************** 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 -acrpNC5 cvs.orig/src/libc/pc_hw/co80/conio.txh cvs/src/libc/pc_hw/co80/conio.txh
*** cvs.orig/src/libc/pc_hw/co80/conio.txh	Tue Aug 22 15:29:16 2000
--- cvs/src/libc/pc_hw/co80/conio.txh	Mon Aug 21 22:58:02 2000
*************** 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
*** 255,265 ****
  @end example
  
  @subheading Description
  
  Retrieve a block of screen characters into a buffer.
! 
  @subheading Return Value
  
  1
  
  @subheading Portability
--- 277,296 ----
  @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
  
  @subheading Portability

- Raw text -


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