Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
438c1add
Commit
438c1add
authored
Jan 08, 2007
by
J. Alexander Treuman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert log messages sent to stdout to the current locale's charset.
git-svn-id:
https://svn.musicpd.org/mpd/trunk@5227
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
90b4af03
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
9 deletions
+30
-9
localization.c
src/localization.c
+15
-1
localization.h
src/localization.h
+2
-0
log.c
src/log.c
+10
-1
main.c
src/main.c
+1
-1
path.c
src/path.c
+2
-6
No files found.
src/localization.c
View file @
438c1add
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
*/
*/
#include "localization.h"
#include "localization.h"
#include "charConv.h"
#include "utils.h"
#include "utils.h"
#include <stdlib.h>
#include <stdlib.h>
...
@@ -30,6 +31,19 @@
...
@@ -30,6 +31,19 @@
static
char
*
localeCharset
=
NULL
;
static
char
*
localeCharset
=
NULL
;
char
*
utf8ToLocaleCharset
(
char
*
str
)
{
static
char
*
ret
=
NULL
;
if
(
localeCharset
)
ret
=
convCharset
(
localeCharset
,
"UTF-8"
,
str
,
ret
);
if
(
!
ret
)
ret
=
xstrdup
(
str
);
return
ret
;
}
void
setLocaleCharset
(
char
*
charset
)
void
setLocaleCharset
(
char
*
charset
)
{
{
if
(
localeCharset
)
if
(
localeCharset
)
...
@@ -63,7 +77,7 @@ void initLocalization(void)
...
@@ -63,7 +77,7 @@ void initLocalization(void)
strcmp
(
currentLocale
,
"POSIX"
)
==
0
)
{
strcmp
(
currentLocale
,
"POSIX"
)
==
0
)
{
WARNING
(
"current locale is
\"
%s
\"\n
"
,
WARNING
(
"current locale is
\"
%s
\"\n
"
,
currentLocale
);
currentLocale
);
setLocaleCharset
(
xstrdup
(
""
));
setLocaleCharset
(
xstrdup
(
"
ISO-8859-1
"
));
}
else
if
((
temp
=
nl_langinfo
(
CODESET
)))
{
}
else
if
((
temp
=
nl_langinfo
(
CODESET
)))
{
setLocaleCharset
(
xstrdup
(
temp
));
setLocaleCharset
(
xstrdup
(
temp
));
}
else
{
}
else
{
...
...
src/localization.h
View file @
438c1add
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
char
*
utf8ToLocaleCharset
(
char
*
str
);
void
setLocaleCharset
(
char
*
charset
);
void
setLocaleCharset
(
char
*
charset
);
char
*
getLocaleCharset
(
void
);
char
*
getLocaleCharset
(
void
);
...
...
src/log.c
View file @
438c1add
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "conf.h"
#include "conf.h"
#include "myfprintf.h"
#include "myfprintf.h"
#include "utils.h"
#include "utils.h"
#include "localization.h"
#include <assert.h>
#include <assert.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -86,9 +87,17 @@ static void buffer_warning(const char *fmt, va_list args)
...
@@ -86,9 +87,17 @@ static void buffer_warning(const char *fmt, va_list args)
static
void
do_log
(
FILE
*
fp
,
const
char
*
fmt
,
va_list
args
)
static
void
do_log
(
FILE
*
fp
,
const
char
*
fmt
,
va_list
args
)
{
{
if
(
!
stdout_mode
)
char
buffer
[
BUFFER_LENGTH
+
1
];
char
*
localized
;
if
(
!
stdout_mode
)
{
fwrite
(
log_date
(),
15
,
1
,
fp
);
fwrite
(
log_date
(),
15
,
1
,
fp
);
vfprintf
(
fp
,
fmt
,
args
);
vfprintf
(
fp
,
fmt
,
args
);
}
else
{
vsnprintf
(
buffer
,
BUFFER_LENGTH
,
fmt
,
args
);
localized
=
utf8ToLocaleCharset
(
buffer
);
fputs
(
localized
,
fp
);
}
}
}
void
flushWarningLog
(
void
)
void
flushWarningLog
(
void
)
...
...
src/main.c
View file @
438c1add
...
@@ -429,6 +429,7 @@ int main(int argc, char *argv[])
...
@@ -429,6 +429,7 @@ int main(int argc, char *argv[])
initStats
();
initStats
();
initTagConfig
();
initTagConfig
();
initLocalization
();
initLog
(
options
.
verbose
);
initLog
(
options
.
verbose
);
if
(
options
.
createDB
<=
0
&&
!
options
.
updateDB
)
if
(
options
.
createDB
<=
0
&&
!
options
.
updateDB
)
...
@@ -438,7 +439,6 @@ int main(int argc, char *argv[])
...
@@ -438,7 +439,6 @@ int main(int argc, char *argv[])
open_log_files
(
options
.
stdOutput
);
open_log_files
(
options
.
stdOutput
);
initLocalization
();
initPaths
();
initPaths
();
initPermissions
();
initPermissions
();
initPlaylist
();
initPlaylist
();
...
...
src/path.c
View file @
438c1add
...
@@ -143,14 +143,10 @@ void initPaths(void)
...
@@ -143,14 +143,10 @@ void initPaths(void)
}
}
closedir
(
dir
);
closedir
(
dir
);
if
(
fsCharsetParam
)
{
if
(
fsCharsetParam
)
charset
=
xstrdup
(
fsCharsetParam
->
value
);
charset
=
xstrdup
(
fsCharsetParam
->
value
);
}
else
if
((
charset
=
getLocaleCharset
()))
{
else
if
((
charset
=
getLocaleCharset
()))
if
(
*
charset
==
'\0'
)
charset
=
NULL
;
else
charset
=
xstrdup
(
charset
);
charset
=
xstrdup
(
charset
);
}
if
(
charset
)
{
if
(
charset
)
{
setFsCharset
(
charset
);
setFsCharset
(
charset
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment