Skip to content

Instantly share code, notes, and snippets.

@SaitoAtsushi
SaitoAtsushi / port-pipe.scm
Created February 18, 2014 04:16
ポートをパイプっぽく使う手続き。 larceny, chez, ypsilon では動作 OK。 mosh, sagittarius ではクラッシュ。
#!r6rs
(import (rnrs)
(rnrs mutable-pairs))
(define (make-queue)
(cons '() '()))
(define (queue-empty? queue)
(null? (car queue)))
@SaitoAtsushi
SaitoAtsushi / custom-port-escape.scm
Created February 18, 2014 06:22
カスタムポートを通じて脱出。
#!r6rs
(import (rnrs))
(define (test)
(call/cc
(lambda(cc)
(let ((in (make-custom-binary-input-port "consumer" cc #f #f #f)))
(get-u8 in)))))
(define (print . x) (for-each (lambda(x)(write x)(newline)) x))
diff --git a/src/gauche/win-compat.h b/src/gauche/win-compat.h
index d3823d2..5237aa6 100755
--- a/src/gauche/win-compat.h
+++ b/src/gauche/win-compat.h
@@ -38,7 +38,7 @@ typedef unsigned long u_long;
#define _BSDTYPES_DEFINED
#endif /* _BSDTYPES_DEFINED */
#ifndef _T
-#define _T(x) (x) /* MSVC unicode macro */
+#define _T(x) TEXT(x) /* MSVC unicode macro */
diff --git a/src/libsys.scm b/src/libsys.scm
index 05333c9..9530891 100644
--- a/src/libsys.scm
+++ b/src/libsys.scm
@@ -383,7 +383,9 @@
(define-cproc sys-remove (filename::<const-cstring>) ::<void>
(let* ([r::int])
- (SCM_SYSCALL r (remove filename))
+ (.if "defined(GAUCHE_WINDOWS) && defined(UNICODE)"
diff -r d14ae1e74bea sitelib/json.scm
--- a/sitelib/json.scm Thu Apr 17 09:23:24 2014 +0200
+++ b/sitelib/json.scm Fri Apr 18 00:03:02 2014 +0900
@@ -130,15 +130,47 @@
(if (char=? (parse-results-token-value results) (string-ref str pos))
(loop (+ pos 1) (parse-results-next results))
(make-expected-result (parse-results-position starting-results) str))))))
+ (define (interpret-string-unicode-escape-low-sarrogate results high)
+ (let ((ch (parse-results-token-value results)))
+ (unless (char=? ch #\\)
@SaitoAtsushi
SaitoAtsushi / bencoding.sld
Last active August 29, 2015 14:00
BitTorrent で使われる bencoding 形式のデータのパーサと構築器
(define-library (bencoding)
(import (scheme base))
(export bencoding-parse bencoding-construct)
(begin
(define-syntax let1
(syntax-rules ()
((_ var expr body0 body1 ...)
(let ((var expr)) body0 body1 ...))))
diff --git a/configure.ac b/configure.ac
index 16448ce..c900f48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -452,7 +452,7 @@ dnl Also adds -DUNICODE to CFLAGS enable Windows wchar API,
dnl if GAUCHE_CHAR_ENCODING is UTF_8.
dnl ALTERNATIVE_GOSH is no-console version of gosh; only built on Windows.
case "$host" in
- *mingw*) LIBS="$LIBS -lnetapi32 -lshlwapi -lws2_32"
+ *mingw*) LIBS="$LIBS -lnetapi32 -lshlwapi -lws2_32 -lkernel32"
@SaitoAtsushi
SaitoAtsushi / gist:aa975a93646f6a7b4334
Created October 26, 2014 08:22
同期モードなら大丈夫なのに非同期にすると status 1 のときにしかハンドラが呼ばれない
#define sync_mode true // 非同期モード。 これを false にすると動く。
#include <windows.h>
#include <msxml2.h>
#include <comutil.h>
#include <cstdio>
#include <iostream>
#pragma comment(lib, "oleaut32.lib")
@SaitoAtsushi
SaitoAtsushi / let-scope.scm
Created November 14, 2014 02:58
Gauche と Scheme で結果が異なる。 ネストしている箇所の処理に何か違いが…?
(define (traverse proc obj)
(let loop ((obj obj))
(cond ((or (identifier? obj) (symbol? obj))
(proc obj))
((pair? obj)
(cons (loop (car obj)) (loop (cdr obj))))
((vector? obj)
(vector-map loop obj))
(else obj))))
@SaitoAtsushi
SaitoAtsushi / lib1.sld
Created January 15, 2015 17:59
(picrin protocol) の使用例。 ライブラリシステムとの相性?
(define-library (lib1)
(import
(scheme base)
(picrin protocol))
(begin
(define-protocol (SHOW t)
(show t))
)
(export show SHOW))