rb_scan_args()をPOSTARG対応にするパッチです。

    rb_scan_args(argc, argv, "11*2", &first, &optional, &array, &penult, &last);

のように、 * の後に数字を指定できます。

 ドキュメントもおおざっぱなまま放置されているので更新してみました。

-- 
Akinori MUSHA / http://akinori.org/
メールサーバが落ちているのでGmailより
SW5kZXg6IFJFQURNRS5FWFQKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gUkVBRE1FLkVYVAkocmV2aXNpb24gMjIy
NzIpCisrKyBSRUFETUUuRVhUCSh3b3JraW5nIGNvcHkpCkBAIC02NzgsMTUgKzY3OCwzNiBAQCBh
cmd1bWVudCBpcyB0aGUgQyBhcnJheSBvZiB0aGUgbWV0aG9kIGFyCiBhcmd1bWVudCBpcyB0aGUg
cmVjZWl2ZXIgb2YgdGhlIG1ldGhvZC4KIAogWW91IGNhbiB1c2UgdGhlIGZ1bmN0aW9uIHJiX3Nj
YW5fYXJncygpIHRvIGNoZWNrIGFuZCByZXRyaWV2ZSB0aGUKLWFyZ3VtZW50cy4gIEZvciBleGFt
cGxlLCAiMTEiIG1lYW5zIHRoYXQgdGhlIG1ldGhvZCByZXF1aXJlcyBhdCBsZWFzdCBvbmUKLWFy
Z3VtZW50LCBhbmQgYXQgbW9zdCByZWNlaXZlcyB0d28gYXJndW1lbnRzLgorYXJndW1lbnRzLiAg
VGhlIHRoaXJkIGFyZ3VtZW50IGlzIGEgc3RyaW5nIHRoYXQgc3BlY2lmaWVzIGhvdyB0bworY2Fw
dHVyZSBtZXRob2QgYXJndW1lbnRzIGFuZCBhc3NpZ24gdGhlbSB0byB0aGUgZm9sbG93aW5nIHZh
cmlhYmxlCityZWZlcmVuY2VzLiAgVGhlIGZvcm1hdCBjYW4gYmUgZGVzY3JpYmVkIGluIEFCTkYg
YXMgZm9sbG93czoKKworLS0KK3NjYW4tYXJnLXNwZWMgIDo9IChwcmUtYXJnLXNwZWMgW3Bvc3Qt
YXJn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