Skip to content

Commit

Permalink
Default to C.UTF-8 locale, allow fallback to C
Browse files Browse the repository at this point in the history
Mostly everything around us is UTF-8 these days, we need to get on with
the times. Especially now that glibc >= 2.35 finally supports it too.
Default to C.UTF-8 but allow disabling it via cmake option to fallback
to the traditional C locale instead.

Fixes: #2587
  • Loading branch information
pmatilai committed Aug 23, 2023
1 parent 59bbb93 commit 3be76d7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(rpm
)

# user configurable stuff
option(ENABLE_CUTF8 "Enable C.UTF-8 as default locale" ON)
option(ENABLE_NLS "Enable native language support" ON)
option(ENABLE_OPENMP "Enable OpenMP threading support" ON)
option(ENABLE_PYTHON "Enable Python bindings" ON)
Expand Down Expand Up @@ -145,6 +146,13 @@ function(makemacros)
set(RPMCANONOS ${host_os})
set(RPMCANONGNU -gnu)

if (ENABLE_CUTF8)
set(C_LOCALE "C.UTF-8")
else()
set(C_LOCALE "C")
endif()
message(INFO " using ${C_LOCALE} as default locale")

configure_file(platform.in platform @ONLY)
configure_file(rpmrc.in rpmrc @ONLY)
configure_file(macros.in macros @ONLY)
Expand Down
4 changes: 4 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ gettext (currently this is required to build rpm but we hope to
lift this requirement soon), available from
http://www.gnu.org/

By default, Rpm uses C.UTF-8 locale as it's default locale. If your
environment does not support this, you can make rpm use the traditional
C locale with -DENABLE_CUTF8=OFF.

If you are going to hack the sources (or compile from source repository)
you will need most of the GNU development tools including:
autoconf, automake, gettext, libtool, makeinfo, perl, GNU m4, GNU tar
Expand Down
2 changes: 1 addition & 1 deletion build/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
appendStringBuf(docScript, sdenv);
appendStringBuf(docScript, "=$RPM_BUILD_ROOT");
appendLineStringBuf(docScript, sd->dirname);
appendLineStringBuf(docScript, "export LC_ALL=C");
appendLineStringBuf(docScript, "export LC_ALL=" C_LOCALE);
appendStringBuf(docScript, "export ");
appendLineStringBuf(docScript, sdenv);
appendLineStringBuf(docScript, mkdocdir);
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@

#define UID_0_USER "@UID_0_USER@"
#define GID_0_GROUP "@GID_0_GROUP@"
#define C_LOCALE "@C_LOCALE@"

#define PACKAGE "@PROJECT_NAME@"
#define VERSION "@PROJECT_VERSION@"
Expand Down
2 changes: 1 addition & 1 deletion macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ Supplements: (%{name} = %{version}-%{release} and langpacks-%{1})\
RPM_PACKAGE_VERSION=\"%{VERSION}\"\
RPM_PACKAGE_RELEASE=\"%{RELEASE}\"\
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\
LANG=C\
LANG=@C_LOCALE@\
export LANG\
unset CDPATH DISPLAY ||:\
unset DEBUGINFOD_URLS ||:\
Expand Down
4 changes: 2 additions & 2 deletions rpmio/rpmglob.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ int rpmGlobPath(const char * pattern, rpmglobFlags flags,
t = setlocale(LC_CTYPE, NULL);
if (t)
old_ctype = xstrdup(t);
(void) setlocale(LC_COLLATE, "C");
(void) setlocale(LC_CTYPE, "C");
(void) setlocale(LC_COLLATE, C_LOCALE);
(void) setlocale(LC_CTYPE, C_LOCALE);
#endif

gl.gl_pathc = 0;
Expand Down

0 comments on commit 3be76d7

Please sign in to comment.