about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/slang
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/slang')
-rw-r--r--nixpkgs/pkgs/development/libraries/slang/default.nix90
-rw-r--r--nixpkgs/pkgs/development/libraries/slang/terminfo-dirs.patch172
2 files changed, 262 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/slang/default.nix b/nixpkgs/pkgs/development/libraries/slang/default.nix
new file mode 100644
index 000000000000..53d69a7e549d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/slang/default.nix
@@ -0,0 +1,90 @@
+{ lib, stdenv, fetchurl
+, libiconv
+, libpng
+, ncurses
+, pcre
+, readline
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "slang";
+  version = "2.3.2";
+
+  src = fetchurl {
+    url = "https://www.jedsoft.org/releases/slang/${pname}-${version}.tar.bz2";
+    sha256 = "sha256-/J47D8T2fDwfbUPJDBalxC0Re44oRXxbRoMbi1064xo=";
+  };
+
+  outputs = [ "out" "dev" "man" "doc" ];
+
+  patches = [ ./terminfo-dirs.patch ];
+
+  # Fix some wrong hardcoded paths
+  preConfigure = ''
+    sed -ie "s|/usr/lib/terminfo|${ncurses.out}/lib/terminfo|" configure
+    sed -ie "s|/usr/lib/terminfo|${ncurses.out}/lib/terminfo|" src/sltermin.c
+    sed -ie "s|/bin/ln|ln|" src/Makefile.in
+    sed -ie "s|-ltermcap|-lncurses|" ./configure
+  '';
+
+  configureFlags = [
+    "--with-pcre=${pcre.dev}"
+    "--with-png=${libpng.dev}"
+    "--with-readline=${readline.dev}"
+    "--with-z=${zlib.dev}"
+  ];
+
+  buildInputs = [
+    libpng
+    pcre
+    readline
+    zlib
+  ] ++ lib.optionals (stdenv.isDarwin) [ libiconv ];
+
+  propagatedBuildInputs = [ ncurses ];
+
+  buildFlags = lib.optional stdenv.hostPlatform.isStatic "static";
+  installTargets = lib.optional stdenv.hostPlatform.isStatic "install-static";
+
+  preBuild = ''
+    makeFlagsArray+=(AR_CR="${stdenv.cc.targetPrefix}ar cr")
+  '';
+
+  # slang 2.3.2 does not support parallel building
+  enableParallelBuilding = false;
+
+  postInstall = ''
+    find "$out"/lib/ -name '*.so' -exec chmod +x "{}" \;
+    sed '/^Libs:/s/$/ -lncurses/' -i "$dev"/lib/pkgconfig/slang.pc
+  '';
+
+  meta = with lib; {
+    description = "A small, embeddable multi-platform programming library";
+    longDescription = ''
+      S-Lang is an interpreted language that was designed from the start to be
+      easily embedded into a program to provide it with a powerful extension
+      language. Examples of programs that use S-Lang as an extension language
+      include the jed text editor and the slrn newsreader. Although S-Lang does
+      not exist as a separate application, it is distributed with a quite
+      capable program called slsh ("slang-shell") that embeds the interpreter
+      and allows one to execute S-Lang scripts, or simply experiment with S-Lang
+      at an interactive prompt. Many of the the examples in this document are
+      presented in the context of one of the above applications.
+
+      S-Lang is also a programmer's library that permits a programmer to develop
+      sophisticated platform-independent software. In addition to providing the
+      S-Lang interpreter, the library provides facilities for screen management,
+      keymaps, low-level terminal I/O, etc. However, this document is concerned
+      only with the extension language and does not address these other features
+      of the S-Lang library. For information about the other components of the
+      library, the reader is referred to the S-Lang Library C Programmer's
+      Guide.
+    '';
+    homepage = "http://www.jedsoft.org/slang/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+    mainProgram = "slsh";
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/slang/terminfo-dirs.patch b/nixpkgs/pkgs/development/libraries/slang/terminfo-dirs.patch
new file mode 100644
index 000000000000..2229b759a3d4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/slang/terminfo-dirs.patch
@@ -0,0 +1,172 @@
+commit c7aa0c07b6522fbbb47ef47bd22f47f1611e7423
+Author: John E. Davis <jed@jedsoft.org>
+Date:   Wed Nov 28 00:46:28 2018 -0500
+
+    pre2.3.3-5: Added support for TERMINFO_DIRS env var
+
+Modified: removed changes to changelog and version number.
+
+diff --git a/src/sltermin.c b/src/sltermin.c
+index a06d0e4..65d3bbc 100644
+--- a/src/sltermin.c
++++ b/src/sltermin.c
+@@ -133,6 +133,9 @@ static FILE *open_terminfo (char *file, SLterminfo_Type *h)
+    unsigned char buf[12];
+    int magic;
+ 
++#ifdef SLANG_UNTIC
++   (void) fprintf (stdout,"# Trying %s\n", file);
++#endif
+    /* Alan Cox reported a security problem here if the application using the
+     * library is setuid.  So, I need to make sure open the file as a normal
+     * user.  Unfortunately, there does not appear to be a portable way of
+@@ -269,10 +272,73 @@ static char *read_string_table (FILE *fp, SLterminfo_Type *t)
+  * are implemented by multiple links to the same compiled file.
+  */
+ 
++static FILE *try_open_tidir (SLterminfo_Type *ti, const char *tidir, const char *term)
++{
++   char file[1024];
++
++   if (sizeof (file) > strlen (tidir) + 5 + strlen (term))
++     {
++	FILE *fp;
++
++	sprintf (file, "%s/%c/%s", tidir, *term, term);
++	if (NULL != (fp = open_terminfo (file, ti)))
++	  return fp;
++
++	sprintf (file, "%s/%02x/%s", tidir, (unsigned char)*term, term);
++	if (NULL != (fp = open_terminfo (file, ti)))
++	  return fp;
++     }
++
++   return NULL;
++}
++
++static FILE *try_open_env (SLterminfo_Type *ti, const char *term, const char *envvar)
++{
++   char *tidir;
++
++   if (NULL == (tidir = _pSLsecure_getenv (envvar)))
++     return NULL;
++
++   return try_open_tidir (ti, tidir, term);
++}
++
++static FILE *try_open_home (SLterminfo_Type *ti, const char *term)
++{
++   char home_ti[1024];
++   char *env;
++
++   if (NULL == (env = _pSLsecure_getenv ("HOME")))
++     return NULL;
++
++   strncpy (home_ti, env, sizeof (home_ti) - 11);
++   home_ti [sizeof(home_ti) - 11] = 0;
++   strcat (home_ti, "/.terminfo");
++
++   return try_open_tidir (ti, home_ti, term);
++}
++
++static FILE *try_open_env_path (SLterminfo_Type *ti, const char *term, const char *envvar)
++{
++   char tidir[1024];
++   char *env;
++   unsigned int i;
++
++   if (NULL == (env = _pSLsecure_getenv (envvar)))
++     return NULL;
++
++   i = 0;
++   while (-1 != SLextract_list_element (env, i, ':', tidir, sizeof(tidir)))
++     {
++	FILE *fp = try_open_tidir (ti, tidir, term);
++	if (fp != NULL) return fp;
++	i++;
++     }
++
++   return NULL;
++}
++
+ static SLCONST char *Terminfo_Dirs [] =
+ {
+-   "", /* $TERMINFO */
+-   "", /* $HOME/.terminfo */
+ #ifdef MISC_TERMINFO_DIRS
+    MISC_TERMINFO_DIRS,
+ #endif
+@@ -287,6 +353,23 @@ static SLCONST char *Terminfo_Dirs [] =
+    NULL,
+ };
+ 
++static FILE *try_open_hardcoded (SLterminfo_Type *ti, const char *term)
++{
++   const char *tidir, **tidirs;
++
++   tidirs = Terminfo_Dirs;
++   while (NULL != (tidir = *tidirs++))
++     {
++	FILE *fp;
++
++	if ((*tidir != 0)
++	    && (NULL != (fp = try_open_tidir (ti, tidir, term))))
++	  return fp;
++     }
++
++   return NULL;
++}
++
+ void _pSLtt_tifreeent (SLterminfo_Type *t)
+ {
+    if (t == NULL)
+@@ -305,11 +388,7 @@ void _pSLtt_tifreeent (SLterminfo_Type *t)
+ 
+ SLterminfo_Type *_pSLtt_tigetent (SLCONST char *term)
+ {
+-   SLCONST char **tidirs, *tidir;
+    FILE *fp = NULL;
+-   char file[1024];
+-   static char home_ti [1024];
+-   char *env;
+    SLterminfo_Type *ti;
+ 
+    if (
+@@ -341,33 +420,10 @@ SLterminfo_Type *_pSLtt_tigetent (SLCONST char *term)
+    /* If we are on a termcap based system, use termcap */
+    if (0 == tcap_getent (term, ti)) return ti;
+ 
+-   if (NULL != (env = _pSLsecure_getenv ("TERMINFO")))
+-     Terminfo_Dirs[0] = env;
+-
+-   if (NULL != (env = _pSLsecure_getenv ("HOME")))
+-     {
+-	strncpy (home_ti, env, sizeof (home_ti) - 11);
+-	home_ti [sizeof(home_ti) - 11] = 0;
+-	strcat (home_ti, "/.terminfo");
+-	Terminfo_Dirs [1] = home_ti;
+-     }
+-
+-   tidirs = Terminfo_Dirs;
+-   while (NULL != (tidir = *tidirs++))
+-     {
+-	if (*tidir == 0)
+-	  continue;
+-
+-	if (sizeof (file) > strlen (tidir) + 5 + strlen (term))
+-	  {
+-	     sprintf (file, "%s/%c/%s", tidir, *term, term);
+-	     if (NULL != (fp = open_terminfo (file, ti)))
+-	       break;
+-	     sprintf (file, "%s/%02x/%s", tidir, (unsigned char)*term, term);
+-	     if (NULL != (fp = open_terminfo (file, ti)))
+-	       break;
+-	  }
+-     }
++   fp = try_open_env_path (ti, term, "TERMINFO_DIRS");
++   if (fp == NULL) fp = try_open_env (ti, term, "TERMINFO");
++   if (fp == NULL) fp = try_open_home (ti, term);
++   if (fp == NULL) fp = try_open_hardcoded (ti, term);
+ 
+ #ifdef SLANG_UNTIC
+    fp_open_label: