Skip to content

Default to C.UTF-8, allow fallback to C #2616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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