Skip to content

Instantly share code, notes, and snippets.

@yatsuta
yatsuta / bind_c.patch
Created August 10, 2016 17:18
patch for R UTF8 problem of c function
--- bind.c.backup 2016-08-10 19:52:17.000000000 +0900
+++ bind.c 2016-08-11 01:24:41.000000000 +0900
@@ -496,6 +496,7 @@ static SEXP NewBase(SEXP base, SEXP tag)
/* This isn't strictly correct as we do not know that all the
components of the name were correctly translated. */
ans = mkCharCE(cbuf, CE_UTF8);
+ if (!ENC_KNOWN(base)) ans = mkCharCE(translateChar(ans), CE_NATIVE);
vmaxset(vmax);
}
else if (*CHAR(tag)) {
@yatsuta
yatsuta / indentr.pl
Created November 22, 2016 14:20
indent C headers for readability
$reserved = 0;
$indent = 0;
while (<>) {
if ($reserved) {
$indent++;
$reserved = 0;
}
if (/^#if/) {