File tgif-4.2.5-HAVE_IMLIB.patch of Package tgif
--- README.libidn.original 2021-01-03 09:34:28.835096054 +0100
+++ README.libidn 2021-01-03 09:34:11.018864376 +0100
@@ -0,0 +1,17 @@
+Watchout!
+Recent distributions of linux always have stringprep_convert as part of
+libidn. Due to this a code simplification has been introduced that can
+be controlled by the compile time switch:
+
+MOREDEFINES = -DHAVE_LIBIDN
+
+in either Tgif.tmpl and / or Tgif.tmp-linux.
+
+If this is defined (and libidn is linked to tgif) the call to
+stringprep_convert is used directly, seveal function pointer definitions
+within inmethod.c are commented out.
+
+To revert to the original behavior simply remove the -DHAVE_LIBIDN from the
+compile time parameters and you will be back to the original behavior.
+
+Dieter Jurzitza / 2021-01-03
--- Tgif.tmpl.original 2011-06-28 04:04:59.000000000 +0200
+++ Tgif.tmpl 2021-01-02 23:29:59.920378207 +0100
@@ -53,7 +53,7 @@
-DDEFATTRGROUP=\"TANGRAM-II:Declaration:Events:Messages:Rewards:Initialization:Watches\" \@@\
-D_NO_NKF -D_NO_CHINPUT -D_NO_XCIN \@@\
-DUSE_XT_INITIALIZE -DPTHREAD
-MOREDEFINES =
+MOREDEFINES = -DHAVE_LIBIDN
XCOMM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
XCOMM Please see Imakefile for more defines to be added to MOREDEFINES above
--- Tgif.tmpl-linux.original 2011-06-28 04:04:59.000000000 +0200
+++ Tgif.tmpl-linux 2021-01-03 09:27:03.720978973 +0100
@@ -53,7 +53,7 @@
-DDEFATTRGROUP=\"TANGRAM-II:Declaration:Events:Messages:Rewards:Initialization:Watches\" \@@\
-D_NO_NKF -D_NO_CHINPUT -D_NO_XCIN \@@\
-DUSE_XT_INITIALIZE -DPTHREAD
-MOREDEFINES =
+MOREDEFINES = -DHAVE_LIBIDN
XCOMM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
XCOMM Please see Imakefile for more defines to be added to MOREDEFINES above
--- tgifdefs.h.original 2011-06-28 04:04:59.000000000 +0200
+++ tgifdefs.h 2021-01-06 19:26:16.567075162 +0100
@@ -37,6 +37,13 @@
#include <arpa/inet.h>
#include <netdb.h>
+#ifdef HAVE_LIBIDN
+#include <stringprep.h>
+#endif /* HAVE_LIBIDN */
+
+/* avoid messages about unused variables ... */
+#define UNUSED(p) ( (void) (p) )
+
#ifdef HAVE_GETTIMEOFDAY
#undef _NO_GETTIMEOFDAY
#endif /* HAVE_GETTIMEOFDAY */
--- inmethod.e.original 2011-06-28 04:04:57.000000000 +0200
+++ inmethod.e 2021-01-03 08:22:18.165350255 +0100
@@ -36,10 +36,16 @@
#define extern
#endif /*_INCLUDE_FROM_INMETHOD_C_*/
+#ifndef HAVE_LIBIDN
extern int Tgim_has_stringprep_convert ARGS_DECL((void));
extern char *Tgim_stringprep_convert ARGS_DECL((const char *str,
const char *to_codeset,
const char *from_codeset));
+#define IDNSTRSZ 1024
+#define LIBDIRS ((char const*[]) {"/lib/", "/lib64/", "/usr/lib/", "/usr/lib64/", "/usr/local/lib/", "/usr/local/lib64/"})
+#define LIBDIRSELEM 6
+#define LIBIDN "libidn.so."
+#endif /* HAVE_LIBIDN */
extern void CleanUpInputMethods ARGS_DECL((void));
extern int InitInputMethods ARGS_DECL((void));
--- inmethod.c.original 2011-06-28 04:04:57.000000000 +0200
+++ inmethod.c 2021-01-03 08:54:40.718538775 +0100
@@ -637,6 +637,7 @@
}
};
+#ifndef HAVE_LIBIDN
static void *gpLibIdnHandle=NULL;
static Tgim_stringprep_convert_Func *gpfn_stringprep_convert=NULL;
@@ -654,7 +655,24 @@
void InitTgim_stringprep_convert()
{
#if (!defined(_NO_IDNLIB) || defined(HAVE_LIBZ))
- gpLibIdnHandle = OPEN_DL("libidn.so", OPEN_DL_MODE);
+ int loop, len;
+ char libidnname[IDNSTRSZ], pathname[IDNSTRSZ];
+ extern void list_libdirectory (char *dirname, char *libidnname, int *done);
+
+ /* no better idea - loop through the list of libdirs and search for the entry with LIBIDN -
+ libidnname will contain the value at the end. */
+ for (loop=0; loop < LIBDIRSELEM; loop ++){
+ sprintf (&pathname[0], "%s", LIBDIRS[loop]);
+ list_libdirectory(&pathname[0], &libidnname[0], &loop);
+ }
+ if ((len=readlink(&libidnname[0], &libidnname[0], IDNSTRSZ-1))>0){
+ /* readlink() does not null terminate the string. Let us do this manually ... */
+ libidnname[len]='\0';
+ }
+ else {
+ libidnname[0]='\0';
+ }
+ gpLibIdnHandle = OPEN_DL(&libidnname[0], OPEN_DL_MODE);
if (gpLibIdnHandle != NULL) {
gpfn_stringprep_convert =
(Tgim_stringprep_convert_Func*)GET_DL_SYM(gpLibIdnHandle,
@@ -664,6 +682,33 @@
gpLibIdnHandle = NULL;
}
}
+}
+/* Search for LIBIDN within dirname and store the result in libidnname */
+void list_libdirectory(char *dirname, char *libidnname, int *done){
+ /* Scan files in directory */
+ struct dirent **files;
+ int n, i;
+
+ n = scandir(dirname, &files, NULL, alphasort);
+
+ /* Loop through file names */
+ if (n > 0){
+ for (i = 0; i < n; i++) {
+ /* Get pointer to file entry */
+ struct dirent *ent = files[i];
+ if (strstr (ent->d_name, LIBIDN)){
+ /* found it -> break the loops (both here and in the calling function ) */
+ i=n;
+ *done=LIBDIRSELEM;
+ sprintf(libidnname, "%s%s", dirname, ent->d_name);
+ }
+ }
+ /* Release file names */
+ for (i = 0; i < n; i++) {
+ free(files[i]);
+ }
+ free(files);
+ }
#endif /* (!defined(_NO_IDNLIB) || defined(HAVE_LIBZ)) */
}
@@ -687,10 +732,13 @@
#endif /* (!defined(_NO_IDNLIB) || defined(HAVE_LIBZ)) */
return NULL;
}
+#endif /* HAVE_LIBIDN */
void CleanUpInputMethods()
{
- CleanUpTgim_stringprep_convert();
+#ifndef HAVE_LIBIDN
+ CleanUpTgim_stringprep_convert();
+#endif /* HAVE_LIBIDN */
if (gnInputMethodIndex != INVALID &&
gstIMInfo[gnInputMethodIndex].pCleanUpFunc != NULL) {
(gstIMInfo[gnInputMethodIndex].pCleanUpFunc)(mainDisplay, mainWindow);
@@ -815,10 +863,12 @@
fprintf(stderr, "\n");
}
}
+#ifndef HAVE_LIBIDN
if (gnSingleOrDoubleByteInputMethod == TGIM_SBIM &&
gnInputMethod != INVALID) {
InitTgim_stringprep_convert();
}
+#endif /* HAVE_LIBIDN */
return TRUE;
}
--- text.c.original 2021-01-02 21:31:04.708772649 +0100
+++ text.c 2021-01-03 08:51:28.352008561 +0100
@@ -3808,8 +3808,12 @@
char *s;
int has_ch;
{
+#ifdef HAVE_LIBIDN
+ if (has_ch >= 2 && !canvasFontDoubleByte) {
+#else
if (has_ch >= 2 && !canvasFontDoubleByte &&
Tgim_has_stringprep_convert()) {
+#endif
char *psz=NULL, *psz1=NULL, *psz2=NULL, *psz_encoding=NULL;
char buf[MAXSTRING];
@@ -3830,8 +3834,12 @@
*psz2 = '-';
}
if (psz_encoding != NULL) {
- psz = Tgim_stringprep_convert(s, psz_encoding, "utf-8");
- if (psz != NULL && strlen(psz) == 1) {
+#ifdef HAVE_LIBIDN
+ psz = stringprep_convert(s, psz_encoding, "utf-8");
+#else
+ psz = Tgim_stringprep_convert(s, psz_encoding, "utf-8");
+#endif /* HAVE_LIBIDN */
+ if (psz != NULL && strlen(psz) == 1) {
s[0] = psz[0];
s[1] = '\0';
has_ch = 1;