fix: arif_rime: prevent rime from logging to stderr
continuous-integration/drone Build is passing
Details
continuous-integration/drone Build is passing
Details
This commit is contained in:
parent
ca9098b4df
commit
b3e0bf9566
|
@ -22,6 +22,7 @@ LT_INIT([dlopen])
|
||||||
AC_PROG_AWK
|
AC_PROG_AWK
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
|
AC_PROG_CXX
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
include_HEADERS =
|
include_HEADERS =
|
||||||
|
noinst_HEADERS =
|
||||||
lib_LTLIBRARIES =
|
lib_LTLIBRARIES =
|
||||||
dist_man3_MANS =
|
dist_man3_MANS =
|
||||||
|
|
||||||
|
@ -14,12 +15,13 @@ dist_man3_MANS =
|
||||||
if BUILD_ARIF_RIME
|
if BUILD_ARIF_RIME
|
||||||
|
|
||||||
include_HEADERS += arif_rime.h
|
include_HEADERS += arif_rime.h
|
||||||
|
noinst_HEADERS += arif_rime_workaround.h
|
||||||
lib_LTLIBRARIES += libarifrime.la
|
lib_LTLIBRARIES += libarifrime.la
|
||||||
dist_man3_MANS += arif_rime.3
|
dist_man3_MANS += arif_rime.3
|
||||||
|
|
||||||
libarifrime_la_CPPFLAGS = $(RIME_CFLAGS) -I$(top_srcdir)/include
|
libarifrime_la_CPPFLAGS = $(RIME_CFLAGS) -I$(top_srcdir)/include
|
||||||
libarifrime_la_LDFLAGS = -module
|
libarifrime_la_LDFLAGS = -module
|
||||||
libarifrime_la_LIBADD = $(RIME_LIBS)
|
libarifrime_la_LIBADD = $(RIME_LIBS)
|
||||||
libarifrime_la_SOURCES = arif_rime.c
|
libarifrime_la_SOURCES = arif_rime.c arif_rime_workaround.cc
|
||||||
|
|
||||||
endif # BUILD_ARIF_RIME
|
endif # BUILD_ARIF_RIME
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include <rime_api.h>
|
#include <rime_api.h>
|
||||||
|
|
||||||
#include "arif_defs.h"
|
#include "arif_defs.h"
|
||||||
|
#include "arif_rime_workaround.h"
|
||||||
|
|
||||||
#ifndef ARIF_RIME_APP_NAME
|
#ifndef ARIF_RIME_APP_NAME
|
||||||
# define ARIF_RIME_APP_NAME "rime.arif"
|
# define ARIF_RIME_APP_NAME "rime.arif"
|
||||||
|
@ -283,6 +284,9 @@ init_rime (void)
|
||||||
traits.modules = get_modules("ARIF_RIME_MODULES");
|
traits.modules = get_modules("ARIF_RIME_MODULES");
|
||||||
|
|
||||||
rime_api->setup(&traits);
|
rime_api->setup(&traits);
|
||||||
|
// Prevent glog (used by Rime for logging) from writing to stderr,
|
||||||
|
// since it may break Readline output.
|
||||||
|
arif_rime_workaround_glog_nostderr();
|
||||||
rime_api->initialize(&traits);
|
rime_api->initialize(&traits);
|
||||||
|
|
||||||
// Rime uses static C++ variables to store its states, which get destroyed
|
// Rime uses static C++ variables to store its states, which get destroyed
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
* arif/examples/arif_rime_workaround.cc
|
||||||
|
* ----
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 CismonX <admin@cismon.net>
|
||||||
|
*
|
||||||
|
* This file is part of ARIF, Another Readline Input Framework.
|
||||||
|
*
|
||||||
|
* ARIF is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* ARIF is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with ARIF. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "arif_rime_workaround.h"
|
||||||
|
|
||||||
|
// It's better practice to just `#include <glog/logging.h>` here instead.
|
||||||
|
// However, we don't want to make glog our dependency just for the sake of
|
||||||
|
// this workaround.
|
||||||
|
|
||||||
|
namespace fLB {
|
||||||
|
bool FLAGS_alsologtostderr;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace fLI {
|
||||||
|
int FLAGS_stderrthreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
arif_rime_workaround_glog_nostderr (void)
|
||||||
|
{
|
||||||
|
// Rime sets this to true during init
|
||||||
|
fLB::FLAGS_alsologtostderr = false;
|
||||||
|
// default value is ERROR (2) instead of FATAL
|
||||||
|
fLI::FLAGS_stderrthreshold = 3;
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
* arif/examples/arif_rime_workaround.h
|
||||||
|
* ----
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 CismonX <admin@cismon.net>
|
||||||
|
*
|
||||||
|
* This file is part of ARIF, Another Readline Input Framework.
|
||||||
|
*
|
||||||
|
* ARIF is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* ARIF is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with ARIF. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ARIF_RIME_WORKAROUND_H_
|
||||||
|
#define ARIF_RIME_WORKAROUND_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
arif_rime_workaround_glog_nostderr (void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // !defined(ARIF_RIME_WORKAROUND_H_)
|
Loading…
Reference in New Issue