Skip to content

Commit

Permalink
unify platform encoding.c, support all
Browse files Browse the repository at this point in the history
Closes GH #1120.
Get support for other platform encodings for free.
  • Loading branch information
Reini Urban committed Nov 5, 2014
1 parent 3a6375c commit a31fbc5
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 495 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -3,6 +3,8 @@
+ Add imcc -d2 flag for MKCONST tracing.
+ Fix darwin --m=32 Parrot_sysmem_amount() #1113
+ Honor rlimit settings on all non-windows platforms. #935
+ Unify code for platform encodings, now supports all. #1120
e.g. unicode filenames or UTF-8 term output on cygwin, solaris, dragonfly
- Build
+ Set -mabi=64 for gcc --m=64 on mips, -m64 on powerpc #1110
+ Add --{en,dis}able-static #1104
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST
Expand Up @@ -1325,10 +1325,8 @@ src/platform/ansi/dl.c []
src/platform/ansi/exec.c []
src/platform/ansi/time.c []
src/platform/cygwin/math.c []
src/platform/darwin/encoding.c []
src/platform/darwin/hires_timer.c []
src/platform/darwin/sysmem.c []
src/platform/freebsd/encoding.c []
src/platform/generic/cpu_type.c []
src/platform/generic/dl.c []
src/platform/generic/encoding.c []
Expand All @@ -1348,10 +1346,7 @@ src/platform/generic/sysmem.c []
src/platform/generic/time.c []
src/platform/generic/uid.c []
src/platform/ia64/asm.s []
src/platform/linux/encoding.c []
src/platform/netbsd/encoding.c []
src/platform/netbsd/misc.c []
src/platform/openbsd/encoding.c []
src/platform/openbsd/math.c []
src/platform/solaris/math.c []
src/platform/solaris/time.c []
Expand Down
10 changes: 0 additions & 10 deletions config/gen/makefiles/root.in
Expand Up @@ -1840,14 +1840,10 @@ src/platform/ansi/time$(O) : src/platform/ansi/time.c $(PARROT_H_HEADERS)

src/platform/cygwin/math$(O) : src/platform/cygwin/math.c $(PARROT_H_HEADERS)

src/platform/darwin/encoding$(O) : src/platform/darwin/encoding.c $(PARROT_H_HEADERS)

src/platform/darwin/hires_timer$(O) : src/platform/darwin/hires_timer.c $(PARROT_H_HEADERS)

src/platform/darwin/sysmem$(O) : src/platform/darwin/sysmem.c $(PARROT_H_HEADERS)

src/platform/freebsd/encoding$(O) : src/platform/freebsd/encoding.c $(PARROT_H_HEADERS)

src/platform/generic/cpu_type$(O) : src/platform/generic/cpu_type.c $(PARROT_H_HEADERS)

src/platform/generic/dl$(O) : src/platform/generic/dl.c $(PARROT_H_HEADERS)
Expand Down Expand Up @@ -1888,14 +1884,8 @@ src/platform/generic/entropy$(O) : src/platform/generic/entropy.c $(PARROT_H_HEA

src/platform/win32/entropy$(O) : src/platform/win32/entropy.c $(PARROT_H_HEADERS)

src/platform/linux/encoding$(O) : src/platform/linux/encoding.c $(PARROT_H_HEADERS)

src/platform/netbsd/encoding$(O) : src/platform/netbsd/encoding.c $(PARROT_H_HEADERS)

src/platform/netbsd/misc$(O) : src/platform/netbsd/misc.c $(PARROT_H_HEADERS)

src/platform/openbsd/encoding$(O) : src/platform/openbsd/encoding.c $(PARROT_H_HEADERS)

src/platform/openbsd/math$(O) : src/platform/openbsd/math.c $(PARROT_H_HEADERS)

src/platform/solaris/math$(O) : src/platform/solaris/math.c $(PARROT_H_HEADERS)
Expand Down
96 changes: 0 additions & 96 deletions src/platform/darwin/encoding.c

This file was deleted.

94 changes: 0 additions & 94 deletions src/platform/freebsd/encoding.c

This file was deleted.

32 changes: 31 additions & 1 deletion src/platform/generic/encoding.c
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012, Parrot Foundation.
* Copyright (C) 2012-2014, Parrot Foundation.
*/

/*
Expand All @@ -22,6 +22,11 @@ Platform C string encoding management

#include "parrot/parrot.h"

#if defined(PARROT_HAS_HEADER_LOCALE) && defined(PARROT_HAS_HEADER_LANGINFO)
# include <locale.h>
# include <langinfo.h>
#endif

/* HEADERIZER HFILE: none */

/*
Expand All @@ -38,7 +43,32 @@ the OS, to an appropriate value.
void
Parrot_init_platform_encoding(SHIM_INTERP)
{
#if defined(PARROT_HAS_HEADER_LOCALE) && defined(PARROT_HAS_HEADER_LANGINFO)
const char *orig = setlocale(LC_CTYPE, NULL); /* store original locale */
setlocale(LC_CTYPE, ""); /* set locale to environment specification */
{
const char *codeset = nl_langinfo(CODESET);
if (STREQ(codeset, "UTF-8")
|| STREQ(codeset, "utf-8")) /* darwin 10.4 ppc */
Parrot_platform_encoding_ptr = Parrot_utf8_encoding_ptr;
else if (STREQ(codeset, "ISO-8859-1") /* linux */
|| STREQ(codeset, "ISO8859-1")) /* bsd */
Parrot_platform_encoding_ptr = Parrot_latin1_encoding_ptr;
else if (STREQ(codeset, "ANSI_X3.4-1968") /* linux */
|| STREQ(codeset, "US-ASCII") /* freebsd */
|| STREQ(codeset, "646")) /* bsd */
Parrot_platform_encoding_ptr = Parrot_ascii_encoding_ptr;
else {
/* Can't use Parrot_warn here, the interpreter is not ready */
fprintf(stderr,
"Unknown codeset `%s', defaulting to ASCII\n", codeset);
Parrot_platform_encoding_ptr = Parrot_ascii_encoding_ptr;
}
}
setlocale(LC_CTYPE, orig); /* restore original locale */
#else
Parrot_platform_encoding_ptr = Parrot_ascii_encoding_ptr;
#endif
}


Expand Down
94 changes: 0 additions & 94 deletions src/platform/linux/encoding.c

This file was deleted.

0 comments on commit a31fbc5

Please sign in to comment.