From d64b85983bf0eee87f47733c8e80709f8f7dd0a7 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Mon, 11 Jun 2018 14:44:49 -0400 Subject: [PATCH] netbsd.locale: init --- pkgs/os-specific/bsd/netbsd/default.nix | 7 ++ pkgs/os-specific/bsd/netbsd/locale.patch | 85 ++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 pkgs/os-specific/bsd/netbsd/locale.patch diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix index 950694d0bfe3..aae11b6affcf 100644 --- a/pkgs/os-specific/bsd/netbsd/default.nix +++ b/pkgs/os-specific/bsd/netbsd/default.nix @@ -600,4 +600,11 @@ in rec { makeFlags = [ "BINDIR=/share" ]; }; + locale = netBSDDerivation { + path = "usr.bin/locale"; + version = "7.1.2"; + sha256 = "0kk6v9k2bygq0wf9gbinliqzqpzs9bgxn0ndyl2wcv3hh2bmsr9p"; + patches = [ ./locale.patch ]; + }; + } diff --git a/pkgs/os-specific/bsd/netbsd/locale.patch b/pkgs/os-specific/bsd/netbsd/locale.patch new file mode 100644 index 000000000000..1df9eb385625 --- /dev/null +++ b/pkgs/os-specific/bsd/netbsd/locale.patch @@ -0,0 +1,85 @@ +--- a/locale.c 2018-06-11 14:39:06.449762000 -0400 ++++ b/locale.c 2018-06-11 14:42:28.461122899 -0400 +@@ -56,14 +56,8 @@ + #include + #include + +-#include "citrus_namespace.h" +-#include "citrus_region.h" +-#include "citrus_lookup.h" +-#include "setlocale_local.h" +- + /* Local prototypes */ + void init_locales_list(void); +-void init_locales_list_alias(void); + void list_charmaps(void); + void list_locales(void); + const char *lookup_localecat(int); +@@ -221,6 +215,8 @@ + }; + #define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0])) + ++const char *_PathLocale = NULL; ++ + int + main(int argc, char *argv[]) + { +@@ -411,8 +407,7 @@ + while ((dp = readdir(dirp)) != NULL) { + /* exclude "." and "..", _LOCALE_ALIAS_NAME */ + if ((dp->d_name[0] != '.' || (dp->d_name[1] != '\0' && +- (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) && +- strcmp(_LOCALE_ALIAS_NAME, dp->d_name) != 0) { ++ (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))) { + s = strdup(dp->d_name); + if (s == NULL) + err(1, "could not allocate memory"); +@@ -431,48 +426,10 @@ + if (sl_find(locales, "C") == NULL) + sl_add(locales, "C"); + +- init_locales_list_alias(); +- + /* make output nicer, sort the list */ + qsort(locales->sl_str, locales->sl_cur, sizeof(char *), scmp); + } + +-void +-init_locales_list_alias(void) +-{ +- char aliaspath[PATH_MAX]; +- struct _lookup *hlookup; +- struct _region key, dat; +- size_t n; +- char *s, *t; +- +- _DIAGASSERT(locales != NULL); +- _DIAGASSERT(_PathLocale != NULL); +- +- (void)snprintf(aliaspath, sizeof(aliaspath), +- "%s/" _LOCALE_ALIAS_NAME, _PathLocale); +- +- if (_lookup_seq_open(&hlookup, aliaspath, +- _LOOKUP_CASE_SENSITIVE) == 0) { +- while (_lookup_seq_next(hlookup, &key, &dat) == 0) { +- n = _region_size((const struct _region *)&key); +- s = _region_head((const struct _region *)&key); +- for (t = s; n > 0 && *s!= '/'; --n, ++s); +- n = (size_t)(s - t); +- s = malloc(n + 1); +- if (s == NULL) +- err(1, "could not allocate memory"); +- memcpy(s, t, n); +- s[n] = '\0'; +- if (sl_find(locales, s) == NULL) +- sl_add(locales, s); +- else +- free(s); +- } +- _lookup_seq_close(hlookup); +- } +-} +- + /* + * Show current locale status, depending on environment variables + */