Browse Source

Make the new locale location work

signals
Gavin Howard 3 years ago
parent
commit
c1075ce8c6
Signed by untrusted user who does not match committer: gavin
GPG Key ID: C08038BDF280D33E
  1. 2
      Makefile.in
  2. 5
      include/vm.h
  3. 4
      locale_install.sh
  4. 0
      locale_uninstall.sh
  5. 2
      src/data.c
  6. 2
      src/main.c
  7. 18
      src/vm.c

2
Makefile.in

@ -126,7 +126,7 @@ BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
CPPFLAGS1 = %%CPPFLAGS%%
CPPFLAGS2 = $(CPPFLAGS1) -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
CPPFLAGS3 = $(CPPFLAGS2) -I./include/ -DVERSION=$(VERSION) -DLOCALEDIR=$(LOCALEDIR)
CPPFLAGS4 = $(CPPFLAGS3) -DEXECPREFIX=$(EXEC_PREFIX)
CPPFLAGS4 = $(CPPFLAGS3) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC)
CPPFLAGS5 = $(CPPFLAGS4) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
CPPFLAGS6 = $(CPPFLAGS5) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
CPPFLAGS7 = $(CPPFLAGS6) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)

5
include/vm.h

@ -58,6 +58,7 @@
#define BC_VERSION GEN_STR2(VERSION)
#define BC_LOCALEDIR GEN_STR2(LOCALEDIR)
#define BC_EXECPREFIX GEN_STR2(EXECPREFIX)
#define BC_MAINEXEC GEN_STR2(MAINEXEC)
// Windows has deprecated isatty().
#ifdef _WIN32
@ -165,7 +166,7 @@ typedef struct BcVm {
const char *err_ids[BC_ERR_IDX_NELEMS];
const char *err_msgs[BC_ERROR_NELEMS];
const char *locale;
char *locale;
#if BC_ENABLE_NLS
nl_catd catalog;
@ -194,8 +195,6 @@ char* bc_vm_strdup(const char *str);
BcStatus bc_vm_error(BcError e, size_t line, ...);
extern const char bc_exec_prefix[];
#if BC_ENABLED
extern const char bc_lib[];
extern const char *bc_lib_name;

4
locale_install.sh

@ -47,8 +47,8 @@ for file in $catalog_dir/*.cat; do
if [ -L "$file" ]; then
link=$(readlink "$file")
linkname=$(basename "$link")
"$INSTALL" -Dlm 755 "../../$linkname/LC_MESSAGES/$link" "$loc"
linkname=$(removeext "$link")
"$INSTALL" -Dlm 755 "../../$linkname/LC_MESSAGES/$main_exec.cat" "$loc"
else
"$INSTALL" -Dm 755 "$file" "$loc"
fi

0
locale_uninstall.sh

2
src/data.c

@ -29,8 +29,6 @@
#include <program.h>
#include <vm.h>
const char bc_exec_prefix[] = BC_EXECPREFIX;
#if BC_ENABLE_SIGNALS
#if BC_ENABLED
const char bc_sig_msg[] = "\ninterrupt (type \"quit\" to exit)\n";

2
src/main.c

@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
int s;
char *name;
size_t len = strlen(bc_exec_prefix);
size_t len = strlen(BC_EXECPREFIX);
vm = calloc(1, sizeof(BcVm));
if (BC_ERR(!vm)) return (int) bc_vm_err(BC_ERROR_FATAL_ALLOC_ERR);

18
src/vm.c

@ -507,21 +507,21 @@ static void bc_vm_gettext() {
bc_vec_init(&dir, sizeof(char), NULL);
bc_vec_string(&dir, strlen(BC_LOCALEDIR), BC_LOCALEDIR);
bc_vec_concat(&dir, "/");
bc_vec_concat(&dir, vm->locale);
dot = strrchr(dir.v, '.');
dot = strrchr(vm->locale, '.');
if (dot) {
uintptr_t idx = ((uintptr_t) dot) - ((uintptr_t) dir.v);
bc_vec_npop(&dir, dir.len - idx);
bc_vec_pushByte(&dir, '\0');
uintptr_t idx = ((uintptr_t) dot) - ((uintptr_t) vm->locale);
vm->locale[idx] = '\0';
}
bc_vec_string(&dir, strlen(BC_LOCALEDIR), BC_LOCALEDIR);
bc_vec_concat(&dir, "/");
bc_vec_concat(&dir, vm->locale);
bc_vec_concat(&dir, "/LC_MESSAGES/");
bc_vec_concat(&dir, BC_MAINEXEC);
bc_vec_concat(&dir, ".cat");
vm->catalog = catopen(dir.v, NL_CAT_LOCALE);
vm->catalog = catopen(dir.v, NL_CAT_LOCALE);
set = msg = 1;
vm->error_header = catgets(vm->catalog, set, msg, bc_err_fmt);

Loading…
Cancel
Save