lol

netbsd.locale: init

+92
+7
pkgs/os-specific/bsd/netbsd/default.nix
··· 600 600 makeFlags = [ "BINDIR=/share" ]; 601 601 }; 602 602 603 + locale = netBSDDerivation { 604 + path = "usr.bin/locale"; 605 + version = "7.1.2"; 606 + sha256 = "0kk6v9k2bygq0wf9gbinliqzqpzs9bgxn0ndyl2wcv3hh2bmsr9p"; 607 + patches = [ ./locale.patch ]; 608 + }; 609 + 603 610 }
+85
pkgs/os-specific/bsd/netbsd/locale.patch
··· 1 + --- a/locale.c 2018-06-11 14:39:06.449762000 -0400 2 + +++ b/locale.c 2018-06-11 14:42:28.461122899 -0400 3 + @@ -56,14 +56,8 @@ 4 + #include <stringlist.h> 5 + #include <unistd.h> 6 + 7 + -#include "citrus_namespace.h" 8 + -#include "citrus_region.h" 9 + -#include "citrus_lookup.h" 10 + -#include "setlocale_local.h" 11 + - 12 + /* Local prototypes */ 13 + void init_locales_list(void); 14 + -void init_locales_list_alias(void); 15 + void list_charmaps(void); 16 + void list_locales(void); 17 + const char *lookup_localecat(int); 18 + @@ -221,6 +215,8 @@ 19 + }; 20 + #define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0])) 21 + 22 + +const char *_PathLocale = NULL; 23 + + 24 + int 25 + main(int argc, char *argv[]) 26 + { 27 + @@ -411,8 +407,7 @@ 28 + while ((dp = readdir(dirp)) != NULL) { 29 + /* exclude "." and "..", _LOCALE_ALIAS_NAME */ 30 + if ((dp->d_name[0] != '.' || (dp->d_name[1] != '\0' && 31 + - (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) && 32 + - strcmp(_LOCALE_ALIAS_NAME, dp->d_name) != 0) { 33 + + (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))) { 34 + s = strdup(dp->d_name); 35 + if (s == NULL) 36 + err(1, "could not allocate memory"); 37 + @@ -431,48 +426,10 @@ 38 + if (sl_find(locales, "C") == NULL) 39 + sl_add(locales, "C"); 40 + 41 + - init_locales_list_alias(); 42 + - 43 + /* make output nicer, sort the list */ 44 + qsort(locales->sl_str, locales->sl_cur, sizeof(char *), scmp); 45 + } 46 + 47 + -void 48 + -init_locales_list_alias(void) 49 + -{ 50 + - char aliaspath[PATH_MAX]; 51 + - struct _lookup *hlookup; 52 + - struct _region key, dat; 53 + - size_t n; 54 + - char *s, *t; 55 + - 56 + - _DIAGASSERT(locales != NULL); 57 + - _DIAGASSERT(_PathLocale != NULL); 58 + - 59 + - (void)snprintf(aliaspath, sizeof(aliaspath), 60 + - "%s/" _LOCALE_ALIAS_NAME, _PathLocale); 61 + - 62 + - if (_lookup_seq_open(&hlookup, aliaspath, 63 + - _LOOKUP_CASE_SENSITIVE) == 0) { 64 + - while (_lookup_seq_next(hlookup, &key, &dat) == 0) { 65 + - n = _region_size((const struct _region *)&key); 66 + - s = _region_head((const struct _region *)&key); 67 + - for (t = s; n > 0 && *s!= '/'; --n, ++s); 68 + - n = (size_t)(s - t); 69 + - s = malloc(n + 1); 70 + - if (s == NULL) 71 + - err(1, "could not allocate memory"); 72 + - memcpy(s, t, n); 73 + - s[n] = '\0'; 74 + - if (sl_find(locales, s) == NULL) 75 + - sl_add(locales, s); 76 + - else 77 + - free(s); 78 + - } 79 + - _lookup_seq_close(hlookup); 80 + - } 81 + -} 82 + - 83 + /* 84 + * Show current locale status, depending on environment variables 85 + */