1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/**/*.[ch]: removed trailing spaces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-04-22 08:04:13 +00:00
parent 36f8540a2b
commit 977267c2e0
92 changed files with 1588 additions and 1588 deletions

View file

@ -1,12 +1,12 @@
/* /*
* *
* Ruby BigDecimal(Variable decimal precision) extension library. * Ruby BigDecimal(Variable decimal precision) extension library.
* *
* Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp) * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
* *
* You may distribute under the terms of either the GNU General Public * You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file * License or the Artistic License, as specified in the README file
* of this BigDecimal distribution. * of this BigDecimal distribution.
* *
* NOTES: * NOTES:
* 2003-03-28 V1.0 checked in. * 2003-03-28 V1.0 checked in.
@ -29,10 +29,10 @@ extern "C" {
#define SZ_NINF "-Infinity" #define SZ_NINF "-Infinity"
/* /*
* #define VP_EXPORT other than static to let VP_ routines * #define VP_EXPORT other than static to let VP_ routines
* be called from outside of this module. * be called from outside of this module.
*/ */
#define VP_EXPORT static #define VP_EXPORT static
#define U_LONG unsigned long #define U_LONG unsigned long
#define S_LONG long #define S_LONG long
@ -96,7 +96,7 @@ typedef struct {
U_LONG frac[1]; /* Pointer to array of fraction part. */ U_LONG frac[1]; /* Pointer to array of fraction part. */
} Real; } Real;
/* /*
* ------------------ * ------------------
* EXPORTables. * EXPORTables.
* ------------------ * ------------------
@ -161,7 +161,7 @@ VP_EXPORT int VpPower(Real *y,Real *x,S_INT n);
/* VP constants */ /* VP constants */
VP_EXPORT Real *VpOne(void); VP_EXPORT Real *VpOne(void);
/* /*
* ------------------ * ------------------
* MACRO definitions. * MACRO definitions.
* ------------------ * ------------------

View file

@ -317,7 +317,7 @@ fdbm_shift(VALUE obj)
GetDBM2(obj, dbmp, dbm); GetDBM2(obj, dbmp, dbm);
dbmp->di_size = -1; dbmp->di_size = -1;
key = dbm_firstkey(dbm); key = dbm_firstkey(dbm);
if (!key.dptr) return Qnil; if (!key.dptr) return Qnil;
val = dbm_fetch(dbm, key); val = dbm_fetch(dbm, key);
keystr = rb_tainted_str_new(key.dptr, key.dsize); keystr = rb_tainted_str_new(key.dptr, key.dsize);

View file

@ -54,7 +54,7 @@ bubblebabble_str_new(VALUE str_digest)
p[j++] = consonants[16]; p[j++] = consonants[16];
p[j++] = vowels[seed / 6]; p[j++] = vowels[seed / 6];
break; break;
} }
byte1 = digest[i++]; byte1 = digest[i++];
p[j++] = vowels[(((byte1 >> 6) & 3) + seed) % 6]; p[j++] = vowels[(((byte1 >> 6) & 3) + seed) % 6];

View file

@ -7,7 +7,7 @@
* FILE: rmd160.h * FILE: rmd160.h
* *
* CONTENTS: Header file for a sample C-implementation of the * CONTENTS: Header file for a sample C-implementation of the
* RIPEMD-160 hash-function. * RIPEMD-160 hash-function.
* TARGET: any computer with an ANSI C compiler * TARGET: any computer with an ANSI C compiler
* *
* AUTHOR: Antoon Bosselaers, ESAT-COSIC * AUTHOR: Antoon Bosselaers, ESAT-COSIC

View file

@ -15,7 +15,7 @@
typedef struct { typedef struct {
uint32_t state[5]; uint32_t state[5];
uint32_t count[2]; uint32_t count[2];
uint8_t buffer[64]; uint8_t buffer[64];
} SHA1_CTX; } SHA1_CTX;
@ -35,5 +35,5 @@ void SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
#define SHA1_BLOCK_LENGTH 64 #define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20 #define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
#endif /* _SYS_SHA1_H_ */ #endif /* _SYS_SHA1_H_ */

View file

@ -27,9 +27,9 @@ void
Init_sha1() Init_sha1()
{ {
VALUE mDigest, cDigest_Base, cDigest_SHA1; VALUE mDigest, cDigest_Base, cDigest_SHA1;
rb_require("digest"); rb_require("digest");
mDigest = rb_path2class("Digest"); mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base"); cDigest_Base = rb_path2class("Digest::Base");

View file

@ -1,7 +1,7 @@
/* /*
* FILE: sha2.c * FILE: sha2.c
* AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
* *
* Copyright (c) 2000-2001, Aaron D. Gifford * Copyright (c) 2000-2001, Aaron D. Gifford
* All rights reserved. * All rights reserved.
* *
@ -16,7 +16,7 @@
* 3. Neither the name of the copyright holder nor the names of contributors * 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -77,7 +77,7 @@
* *
* And for little-endian machines, add: * And for little-endian machines, add:
* *
* #define BYTE_ORDER LITTLE_ENDIAN * #define BYTE_ORDER LITTLE_ENDIAN
* *
* Or for big-endian machines: * Or for big-endian machines:
* *
@ -494,7 +494,7 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
s1 = sigma1_256(s1); s1 = sigma1_256(s1);
/* Apply the SHA-256 compression function to update a..h */ /* Apply the SHA-256 compression function to update a..h */
T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
(W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0);
T2 = Sigma0_256(a) + Maj(a, b, c); T2 = Sigma0_256(a) + Maj(a, b, c);
h = g; h = g;

View file

@ -1,7 +1,7 @@
/* /*
* FILE: sha2.h * FILE: sha2.h
* AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
* *
* Copyright (c) 2000-2001, Aaron D. Gifford * Copyright (c) 2000-2001, Aaron D. Gifford
* All rights reserved. * All rights reserved.
* *
@ -16,7 +16,7 @@
* 3. Neither the name of the copyright holder nor the names of contributors * 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -51,7 +51,7 @@ extern "C" {
#ifdef RUBY #ifdef RUBY
# ifdef HAVE_PROTOTYPES # ifdef HAVE_PROTOTYPES
# undef NOPROTO # undef NOPROTO
# else # else
# define NOPROTO # define NOPROTO
# endif /* HAVE_PROTOTYPES */ # endif /* HAVE_PROTOTYPES */
@ -61,7 +61,7 @@ extern "C" {
# ifdef WORDS_BIGENDIAN # ifdef WORDS_BIGENDIAN
# define BYTE_ORDER BIG_ENDIAN # define BYTE_ORDER BIG_ENDIAN
# else # else
# define BYTE_ORDER LITTLE_ENDIAN # define BYTE_ORDER LITTLE_ENDIAN
# endif # endif
# endif /* BYTE_ORDER */ # endif /* BYTE_ORDER */
# define SHA2_USE_INTTYPES_H # define SHA2_USE_INTTYPES_H
@ -111,7 +111,7 @@ typedef unsigned long long uint64_t; /* 8-bytes (64-bits) */
* *
* #include <inttypes.h> * #include <inttypes.h>
* *
* If you choose to use <inttypes.h> then please define: * If you choose to use <inttypes.h> then please define:
* *
* #define SHA2_USE_INTTYPES_H * #define SHA2_USE_INTTYPES_H
* *

View file

@ -147,12 +147,12 @@ rb_dlcfunc_initialize(int argc, VALUE argv[], VALUE self)
struct cfunc_data *data; struct cfunc_data *data;
void *saddr; void *saddr;
const char *sname; const char *sname;
rb_scan_args(argc, argv, "13", &addr, &type, &name, &calltype); rb_scan_args(argc, argv, "13", &addr, &type, &name, &calltype);
saddr = (void*)(NUM2PTR(rb_Integer(addr))); saddr = (void*)(NUM2PTR(rb_Integer(addr)));
sname = NIL_P(name) ? NULL : StringValuePtr(name); sname = NIL_P(name) ? NULL : StringValuePtr(name);
TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, data); TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, data);
if( data->name ) xfree(data->name); if( data->name ) xfree(data->name);
data->ptr = saddr; data->ptr = saddr;
@ -286,9 +286,9 @@ rb_dlcfunc_inspect(VALUE self)
char *str; char *str;
int str_size; int str_size;
struct cfunc_data *cfunc; struct cfunc_data *cfunc;
TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, cfunc); TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, cfunc);
str_size = (cfunc->name ? strlen(cfunc->name) : 0) + 100; str_size = (cfunc->name ? strlen(cfunc->name) : 0) + 100;
str = ruby_xmalloc(str_size); str = ruby_xmalloc(str_size);
snprintf(str, str_size - 1, snprintf(str, str_size - 1,
@ -339,14 +339,14 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
memset(stack, 0, sizeof(DLSTACK_TYPE) * DLSTACK_SIZE); memset(stack, 0, sizeof(DLSTACK_TYPE) * DLSTACK_SIZE);
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, cfunc); TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, cfunc);
if( cfunc->ptr == 0 ){ if( cfunc->ptr == 0 ){
rb_raise(rb_eDLError, "can't call null-function"); rb_raise(rb_eDLError, "can't call null-function");
return Qnil; return Qnil;
} }
for( i = 0; i < RARRAY_LEN(ary); i++ ){ for( i = 0; i < RARRAY_LEN(ary); i++ ){
if( i >= DLSTACK_SIZE ){ if( i >= DLSTACK_SIZE ){
rb_raise(rb_eDLError, "too many arguments (stack overflow)"); rb_raise(rb_eDLError, "too many arguments (stack overflow)");
@ -354,7 +354,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
rb_check_safe_obj(RARRAY_PTR(ary)[i]); rb_check_safe_obj(RARRAY_PTR(ary)[i]);
stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]); stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
} }
/* calltype == CFUNC_CDECL */ /* calltype == CFUNC_CDECL */
if( cfunc->calltype == CFUNC_CDECL if( cfunc->calltype == CFUNC_CDECL
#ifndef FUNC_STDCALL #ifndef FUNC_STDCALL

View file

@ -104,7 +104,7 @@ rb_dlptr2cptr(VALUE val)
else{ else{
rb_raise(rb_eTypeError, "DL::PtrData was expected"); rb_raise(rb_eTypeError, "DL::PtrData was expected");
} }
return ptr; return ptr;
} }

View file

@ -133,7 +133,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
pwd = getpwuid(uid); pwd = getpwuid(uid);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid);
return setup_passwd(pwd); return setup_passwd(pwd);
#else #else
return Qnil; return Qnil;
#endif #endif
} }
@ -156,7 +156,7 @@ etc_getpwnam(VALUE obj, VALUE nam)
pwd = getpwnam(RSTRING_PTR(nam)); pwd = getpwnam(RSTRING_PTR(nam));
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING_PTR(nam)); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING_PTR(nam));
return setup_passwd(pwd); return setup_passwd(pwd);
#else #else
return Qnil; return Qnil;
#endif #endif
} }
@ -194,10 +194,10 @@ each_passwd(void)
} }
#endif #endif
/* Provides a convenient Ruby iterator which executes a block for each entry /* Provides a convenient Ruby iterator which executes a block for each entry
* in the /etc/passwd file. * in the /etc/passwd file.
* *
* The code block is passed an Struct::Passwd struct; see getpwent above for * The code block is passed an Struct::Passwd struct; see getpwent above for
* details. * details.
* *
* Example: * Example:
@ -229,7 +229,7 @@ etc_passwd(VALUE obj)
/* Iterates for each entry in the /etc/passwd file if a block is given. /* Iterates for each entry in the /etc/passwd file if a block is given.
* If no block is given, returns the enumerator. * If no block is given, returns the enumerator.
* *
* The code block is passed an Struct::Passwd struct; see getpwent above for * The code block is passed an Struct::Passwd struct; see getpwent above for
* details. * details.
* *
* Example: * Example:
@ -279,7 +279,7 @@ etc_endpwent(VALUE obj)
} }
/* Returns an entry from the /etc/passwd file. The first time it is called it /* Returns an entry from the /etc/passwd file. The first time it is called it
* opens the file and returns the first entry; each successive call returns * opens the file and returns the first entry; each successive call returns
* the next entry, or nil if the end of the file has been reached. * the next entry, or nil if the end of the file has been reached.
* *
* To close the file when processing is complete, call endpwent. * To close the file when processing is complete, call endpwent.
@ -296,8 +296,8 @@ etc_endpwent(VALUE obj)
* *
* - Passwd#gid contains the integer group ID (gid) of the user's primary group. * - Passwd#gid contains the integer group ID (gid) of the user's primary group.
* *
* - Passwd#gecos contains a longer String description of the user, such as * - Passwd#gecos contains a longer String description of the user, such as
* a full name. Some Unix systems provide structured information in the * a full name. Some Unix systems provide structured information in the
* gecos field, but this is system-dependent. * gecos field, but this is system-dependent.
* *
* - Passwd#dir contains the path to the home directory of the user as a String. * - Passwd#dir contains the path to the home directory of the user as a String.
@ -340,7 +340,7 @@ setup_group(struct group *grp)
} }
#endif #endif
/* Returns information about the group with specified integer group id (gid), /* Returns information about the group with specified integer group id (gid),
* as found in /etc/group. * as found in /etc/group.
* *
* The information is returned as a Struct::Group; see getgrent above for * The information is returned as a Struct::Group; see getgrent above for
@ -373,7 +373,7 @@ etc_getgrgid(int argc, VALUE *argv, VALUE obj)
#endif #endif
} }
/* Returns information about the group with specified String name, as found /* Returns information about the group with specified String name, as found
* in /etc/group. * in /etc/group.
* *
* The information is returned as a Struct::Group; see getgrent above for * The information is returned as a Struct::Group; see getgrent above for
@ -432,10 +432,10 @@ each_group(void)
} }
#endif #endif
/* Provides a convenient Ruby iterator which executes a block for each entry /* Provides a convenient Ruby iterator which executes a block for each entry
* in the /etc/group file. * in the /etc/group file.
* *
* The code block is passed an Struct::Group struct; see getgrent above for * The code block is passed an Struct::Group struct; see getgrent above for
* details. * details.
* *
* Example: * Example:
@ -468,7 +468,7 @@ etc_group(VALUE obj)
/* Iterates for each entry in the /etc/group file if a block is given. /* Iterates for each entry in the /etc/group file if a block is given.
* If no block is given, returns the enumerator. * If no block is given, returns the enumerator.
* *
* The code block is passed an Struct::Group struct; see getpwent above for * The code block is passed an Struct::Group struct; see getpwent above for
* details. * details.
* *
* Example: * Example:
@ -504,7 +504,7 @@ etc_setgrent(VALUE obj)
return Qnil; return Qnil;
} }
/* Ends the process of scanning through the /etc/group file begun by /* Ends the process of scanning through the /etc/group file begun by
* getgrent, and closes the file. * getgrent, and closes the file.
*/ */
static VALUE static VALUE
@ -517,7 +517,7 @@ etc_endgrent(VALUE obj)
} }
/* Returns an entry from the /etc/group file. The first time it is called it /* Returns an entry from the /etc/group file. The first time it is called it
* opens the file and returns the first entry; each successive call returns * opens the file and returns the first entry; each successive call returns
* the next entry, or nil if the end of the file has been reached. * the next entry, or nil if the end of the file has been reached.
* *
* To close the file when processing is complete, call endgrent. * To close the file when processing is complete, call endgrent.
@ -527,13 +527,13 @@ etc_endgrent(VALUE obj)
* - Group#name contains the name of the group as a String. * - Group#name contains the name of the group as a String.
* *
* - Group#passwd contains the encrypted password as a String. An 'x' is * - Group#passwd contains the encrypted password as a String. An 'x' is
* returned if password access to the group is not available; an empty * returned if password access to the group is not available; an empty
* string is returned if no password is needed to obtain membership of * string is returned if no password is needed to obtain membership of
* the group. * the group.
* *
* - Group#gid contains the group's numeric ID as an integer. * - Group#gid contains the group's numeric ID as an integer.
* *
* - Group#mem is an Array of Strings containing the short login names of the * - Group#mem is an Array of Strings containing the short login names of the
* members of the group. * members of the group.
*/ */
static VALUE static VALUE

View file

@ -42,7 +42,7 @@ pack up your own arguments to pass as args for locking functions, etc.
* Documented by mathew <meta@pobox.com> * Documented by mathew <meta@pobox.com>
* *
* = Usage * = Usage
* *
* To perform a fcntl(2) operation, use IO::fcntl in the core classes. * To perform a fcntl(2) operation, use IO::fcntl in the core classes.
* *
* To perform an open(2) operation, use IO::sysopen. * To perform an open(2) operation, use IO::sysopen.
@ -99,10 +99,10 @@ pack up your own arguments to pass as args for locking functions, etc.
* - O_ACCMODE - mask to extract read/write flags. * - O_ACCMODE - mask to extract read/write flags.
* *
* Example: * Example:
* *
* require 'fcntl' * require 'fcntl'
* *
* fd = IO::sysopen('/tmp/tempfile', * fd = IO::sysopen('/tmp/tempfile',
* Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT) * Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
* f = IO.open(fd) * f = IO.open(fd)
* f.syswrite("TEMP DATA") * f.syswrite("TEMP DATA")

View file

@ -44,7 +44,7 @@
* 1. Opening/creating a database, and filling it with some entries: * 1. Opening/creating a database, and filling it with some entries:
* *
* require 'gdbm' * require 'gdbm'
* *
* gdbm = GDBM.new("fruitstore.db") * gdbm = GDBM.new("fruitstore.db")
* gdbm["ananas"] = "3" * gdbm["ananas"] = "3"
* gdbm["banana"] = "8" * gdbm["banana"] = "8"
@ -54,7 +54,7 @@
* 2. Reading out a database: * 2. Reading out a database:
* *
* require 'gdbm' * require 'gdbm'
* *
* gdbm = GDBM.new("fruitstore.db") * gdbm = GDBM.new("fruitstore.db")
* gdbm.each_pair do |key, value| * gdbm.each_pair do |key, value|
* print "#{key}: #{value}\n" * print "#{key}: #{value}\n"
@ -206,19 +206,19 @@ fgdbm_initialize(int argc, VALUE *argv, VALUE obj)
if (flags & RUBY_GDBM_RW_BIT) { if (flags & RUBY_GDBM_RW_BIT) {
flags &= ~RUBY_GDBM_RW_BIT; flags &= ~RUBY_GDBM_RW_BIT;
dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
flags, mode, MY_FATAL_FUNC); flags, mode, MY_FATAL_FUNC);
} }
else { else {
dbm = 0; dbm = 0;
if (mode >= 0) if (mode >= 0)
dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC); GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC);
if (!dbm) if (!dbm)
dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
GDBM_WRITER|flags, 0, MY_FATAL_FUNC); GDBM_WRITER|flags, 0, MY_FATAL_FUNC);
if (!dbm) if (!dbm)
dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE, dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
GDBM_READER|flags, 0, MY_FATAL_FUNC); GDBM_READER|flags, 0, MY_FATAL_FUNC);
} }
@ -537,7 +537,7 @@ fgdbm_delete(VALUE obj, VALUE keystr)
* call-seq: * call-seq:
* gdbm.shift -> (key, value) or nil * gdbm.shift -> (key, value) or nil
* *
* Removes a key-value-pair from this database and returns it as a * Removes a key-value-pair from this database and returns it as a
* two-item array [ _key_, _value_ ]. Returns nil if the database is empty. * two-item array [ _key_, _value_ ]. Returns nil if the database is empty.
*/ */
static VALUE static VALUE
@ -619,7 +619,7 @@ fgdbm_clear(VALUE obj)
free(key.dptr); free(key.dptr);
rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno)); rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
} }
free(key.dptr); free(key.dptr);
} }
#else #else
while (key = gdbm_firstkey(dbm), key.dptr) { while (key = gdbm_firstkey(dbm), key.dptr) {

View file

@ -26,20 +26,20 @@
* == Summary * == Summary
* *
* Ruby extension for charset conversion. * Ruby extension for charset conversion.
* *
* == Abstract * == Abstract
* *
* Iconv is a wrapper class for the UNIX 95 <tt>iconv()</tt> function family, * Iconv is a wrapper class for the UNIX 95 <tt>iconv()</tt> function family,
* which translates string between various encoding systems. * which translates string between various encoding systems.
* *
* See Open Group's on-line documents for more details. * See Open Group's on-line documents for more details.
* * <tt>iconv.h</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html * * <tt>iconv.h</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html
* * <tt>iconv_open()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_open.html * * <tt>iconv_open()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_open.html
* * <tt>iconv()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html * * <tt>iconv()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html
* * <tt>iconv_close()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_close.html * * <tt>iconv_close()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_close.html
* *
* Which coding systems are available is platform-dependent. * Which coding systems are available is platform-dependent.
* *
* == Examples * == Examples
* *
* 1. Simple conversion between two charsets. * 1. Simple conversion between two charsets.
@ -622,7 +622,7 @@ get_iconv_opt(struct rb_iconv_opt_t *opt, VALUE options)
* *
* Creates new code converter from a coding-system designated with +from+ * Creates new code converter from a coding-system designated with +from+
* to another one designated with +to+. * to another one designated with +to+.
* *
* === Parameters * === Parameters
* *
* +to+:: encoding name for destination * +to+:: encoding name for destination
@ -1104,7 +1104,7 @@ iconv_failure_success(VALUE self)
* call-seq: failed * call-seq: failed
* *
* Returns substring of the original string passed to Iconv that starts at the * Returns substring of the original string passed to Iconv that starts at the
* character caused the exception. * character caused the exception.
*/ */
static VALUE static VALUE
iconv_failure_failed(VALUE self) iconv_failure_failed(VALUE self)
@ -1134,13 +1134,13 @@ iconv_failure_inspect(VALUE self)
/* /*
* Document-class: Iconv::InvalidEncoding * Document-class: Iconv::InvalidEncoding
* *
* Requested coding-system is not available on this system. * Requested coding-system is not available on this system.
*/ */
/* /*
* Document-class: Iconv::IllegalSequence * Document-class: Iconv::IllegalSequence
* *
* Input conversion stopped due to an input byte that does not belong to * Input conversion stopped due to an input byte that does not belong to
* the input codeset, or the output codeset does not contain the * the input codeset, or the output codeset does not contain the
* character. * character.
@ -1148,20 +1148,20 @@ iconv_failure_inspect(VALUE self)
/* /*
* Document-class: Iconv::InvalidCharacter * Document-class: Iconv::InvalidCharacter
* *
* Input conversion stopped due to an incomplete character or shift * Input conversion stopped due to an incomplete character or shift
* sequence at the end of the input buffer. * sequence at the end of the input buffer.
*/ */
/* /*
* Document-class: Iconv::OutOfRange * Document-class: Iconv::OutOfRange
* *
* Iconv library internal error. Must not occur. * Iconv library internal error. Must not occur.
*/ */
/* /*
* Document-class: Iconv::BrokenLibrary * Document-class: Iconv::BrokenLibrary
* *
* Detected a bug of underlying iconv(3) libray. * Detected a bug of underlying iconv(3) libray.
* * returns an error without setting errno properly * * returns an error without setting errno properly
*/ */

View file

@ -62,7 +62,7 @@ typedef struct JSON_Generator_StateStruct {
JSON_Generator_State *state; \ JSON_Generator_State *state; \
Data_Get_Struct(self, JSON_Generator_State, state); Data_Get_Struct(self, JSON_Generator_State, state);
/* /*
* Document-module: JSON::Ext::Generator * Document-module: JSON::Ext::Generator
* *
* This is the JSON generator implemented as a C extension. It can be * This is the JSON generator implemented as a C extension. It can be
@ -459,7 +459,7 @@ static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self)
return result; return result;
} }
/* /*
* Document-class: JSON::Ext::Generator::State * Document-class: JSON::Ext::Generator::State
* *
* This class is used to create State instances, that are use to hold data * This class is used to create State instances, that are use to hold data
@ -586,7 +586,7 @@ static VALUE cState_to_h(VALUE self)
* * *indent*: a string used to indent levels (default: ''), * * *indent*: a string used to indent levels (default: ''),
* * *space*: a string that is put after, a : or , delimiter (default: ''), * * *space*: a string that is put after, a : or , delimiter (default: ''),
* * *space_before*: a string that is put before a : pair delimiter (default: ''), * * *space_before*: a string that is put before a : pair delimiter (default: ''),
* * *object_nl*: a string that is put at the end of a JSON object (default: ''), * * *object_nl*: a string that is put at the end of a JSON object (default: ''),
* * *array_nl*: a string that is put at the end of a JSON array (default: ''), * * *array_nl*: a string that is put at the end of a JSON array (default: ''),
* * *check_circular*: true if checking for circular data structures * * *check_circular*: true if checking for circular data structures
* should be done, false (the default) otherwise. * should be done, false (the default) otherwise.
@ -808,7 +808,7 @@ static VALUE cState_allow_nan_p(VALUE self)
/* /*
* call-seq: seen?(object) * call-seq: seen?(object)
* *
* Returns _true_, if _object_ was already seen during this generating run. * Returns _true_, if _object_ was already seen during this generating run.
*/ */
static VALUE cState_seen_p(VALUE self, VALUE object) static VALUE cState_seen_p(VALUE self, VALUE object)
{ {
@ -820,7 +820,7 @@ static VALUE cState_seen_p(VALUE self, VALUE object)
* call-seq: remember(object) * call-seq: remember(object)
* *
* Remember _object_, to find out if it was already encountered (if a cyclic * Remember _object_, to find out if it was already encountered (if a cyclic
* data structure is rendered). * data structure is rendered).
*/ */
static VALUE cState_remember(VALUE self, VALUE object) static VALUE cState_remember(VALUE self, VALUE object)
{ {

View file

@ -6,9 +6,9 @@
/* /*
* Copyright 2001-2004 Unicode, Inc. * Copyright 2001-2004 Unicode, Inc.
* *
* Disclaimer * Disclaimer
* *
* This source code is provided as is by Unicode, Inc. No claims are * This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any * made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine * kind are expressed or implied. The recipient agrees to determine
@ -16,9 +16,9 @@
* purchased on magnetic or optical media from Unicode, Inc., the * purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media * sole remedy for any claim will be exchange of defective media
* within 90 days of receipt. * within 90 days of receipt.
* *
* Limitations on Rights to Redistribute This Code * Limitations on Rights to Redistribute This Code
* *
* Unicode, Inc. hereby grants the right to freely use the information * Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the * supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form * Unicode Standard, and to make copies of this file in any form
@ -49,7 +49,7 @@ static const char trailingBytesForUTF8[256] = {
* This table contains as many values as there might be trailing bytes * This table contains as many values as there might be trailing bytes
* in a UTF-8 sequence. * in a UTF-8 sequence.
*/ */
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL }; 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
/* /*

View file

@ -29,7 +29,7 @@ static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
static VALUE CNaN, CInfinity, CMinusInfinity; static VALUE CNaN, CInfinity, CMinusInfinity;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_object_class, i_array_class; i_chr, i_max_nesting, i_allow_nan, i_object_class, i_array_class;
#define MinusInfinity "-Infinity" #define MinusInfinity "-Infinity"
@ -201,7 +201,7 @@ tr11:
#line 92 "parser.rl" #line 92 "parser.rl"
{ {
VALUE v = Qnil; VALUE v = Qnil;
char *np = JSON_parse_value(json, p, pe, &v); char *np = JSON_parse_value(json, p, pe, &v);
if (np == NULL) { if (np == NULL) {
p--; {p++; cs = 9; goto _out;} p--; {p++; cs = 9; goto _out;}
} else { } else {
@ -503,7 +503,7 @@ tr2:
goto st21; goto st21;
tr5: tr5:
#line 202 "parser.rl" #line 202 "parser.rl"
{ {
char *np; char *np;
json->current_nesting++; json->current_nesting++;
np = JSON_parse_array(json, p, pe, result); np = JSON_parse_array(json, p, pe, result);
@ -513,7 +513,7 @@ tr5:
goto st21; goto st21;
tr9: tr9:
#line 210 "parser.rl" #line 210 "parser.rl"
{ {
char *np; char *np;
json->current_nesting++; json->current_nesting++;
np = JSON_parse_object(json, p, pe, result); np = JSON_parse_object(json, p, pe, result);
@ -1066,7 +1066,7 @@ tr2:
#line 312 "parser.rl" #line 312 "parser.rl"
{ {
VALUE v = Qnil; VALUE v = Qnil;
char *np = JSON_parse_value(json, p, pe, &v); char *np = JSON_parse_value(json, p, pe, &v);
if (np == NULL) { if (np == NULL) {
p--; {p++; cs = 3; goto _out;} p--; {p++; cs = 3; goto _out;}
} else { } else {
@ -1286,7 +1286,7 @@ static VALUE json_string_unescape(char *p, char *pe)
p++; p++;
break; break;
case 'u': case 'u':
if (p > pe - 4) { if (p > pe - 4) {
return Qnil; return Qnil;
} else { } else {
p = JSON_convert_UTF16_to_UTF8(result, p, pe, strictConversion); p = JSON_convert_UTF16_to_UTF8(result, p, pe, strictConversion);
@ -1474,7 +1474,7 @@ static const int JSON_en_main = 1;
#line 473 "parser.rl" #line 473 "parser.rl"
/* /*
* Document-class: JSON::Ext::Parser * Document-class: JSON::Ext::Parser
* *
* This is the JSON parser implemented as a C extension. It can be configured * This is the JSON parser implemented as a C extension. It can be configured

View file

@ -27,7 +27,7 @@ static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
static VALUE CNaN, CInfinity, CMinusInfinity; static VALUE CNaN, CInfinity, CMinusInfinity;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_object_class, i_array_class; i_chr, i_max_nesting, i_allow_nan, i_object_class, i_array_class;
#define MinusInfinity "-Infinity" #define MinusInfinity "-Infinity"
@ -91,7 +91,7 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
action parse_value { action parse_value {
VALUE v = Qnil; VALUE v = Qnil;
char *np = JSON_parse_value(json, fpc, pe, &v); char *np = JSON_parse_value(json, fpc, pe, &v);
if (np == NULL) { if (np == NULL) {
fhold; fbreak; fhold; fbreak;
} else { } else {
@ -199,7 +199,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
fhold; fbreak; fhold; fbreak;
} }
action parse_array { action parse_array {
char *np; char *np;
json->current_nesting++; json->current_nesting++;
np = JSON_parse_array(json, fpc, pe, result); np = JSON_parse_array(json, fpc, pe, result);
@ -207,7 +207,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
if (np == NULL) { fhold; fbreak; } else fexec np; if (np == NULL) { fhold; fbreak; } else fexec np;
} }
action parse_object { action parse_object {
char *np; char *np;
json->current_nesting++; json->current_nesting++;
np = JSON_parse_object(json, fpc, pe, result); np = JSON_parse_object(json, fpc, pe, result);
@ -311,7 +311,7 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
action parse_value { action parse_value {
VALUE v = Qnil; VALUE v = Qnil;
char *np = JSON_parse_value(json, fpc, pe, &v); char *np = JSON_parse_value(json, fpc, pe, &v);
if (np == NULL) { if (np == NULL) {
fhold; fbreak; fhold; fbreak;
} else { } else {
@ -385,7 +385,7 @@ static VALUE json_string_unescape(char *p, char *pe)
p++; p++;
break; break;
case 'u': case 'u':
if (p > pe - 4) { if (p > pe - 4) {
return Qnil; return Qnil;
} else { } else {
p = JSON_convert_UTF16_to_UTF8(result, p, pe, strictConversion); p = JSON_convert_UTF16_to_UTF8(result, p, pe, strictConversion);
@ -472,7 +472,7 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
) ignore*; ) ignore*;
}%% }%%
/* /*
* Document-class: JSON::Ext::Parser * Document-class: JSON::Ext::Parser
* *
* This is the JSON parser implemented as a C extension. It can be configured * This is the JSON parser implemented as a C extension. It can be configured

View file

@ -2,9 +2,9 @@
/* /*
* Copyright 2001-2004 Unicode, Inc. * Copyright 2001-2004 Unicode, Inc.
* *
* Disclaimer * Disclaimer
* *
* This source code is provided as is by Unicode, Inc. No claims are * This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any * made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine * kind are expressed or implied. The recipient agrees to determine
@ -12,9 +12,9 @@
* purchased on magnetic or optical media from Unicode, Inc., the * purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media * sole remedy for any claim will be exchange of defective media
* within 90 days of receipt. * within 90 days of receipt.
* *
* Limitations on Rights to Redistribute This Code * Limitations on Rights to Redistribute This Code
* *
* Unicode, Inc. hereby grants the right to freely use the information * Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the * supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form * Unicode Standard, and to make copies of this file in any form
@ -45,7 +45,7 @@ static const char trailingBytesForUTF8[256] = {
* This table contains as many values as there might be trailing bytes * This table contains as many values as there might be trailing bytes
* in a UTF-8 sequence. * in a UTF-8 sequence.
*/ */
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL }; 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
/* /*
@ -89,7 +89,7 @@ char *JSON_convert_UTF16_to_UTF8 (
UTF32 ch; UTF32 ch;
unsigned short bytesToWrite = 0; unsigned short bytesToWrite = 0;
const UTF32 byteMask = 0xBF; const UTF32 byteMask = 0xBF;
const UTF32 byteMark = 0x80; const UTF32 byteMark = 0x80;
ch = *tmpPtr++; ch = *tmpPtr++;
/* If we have a surrogate pair, convert to UTF32 first. */ /* If we have a surrogate pair, convert to UTF32 first. */
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {

View file

@ -39,7 +39,7 @@
/* /*
* Select Default Output Encoding * Select Default Output Encoding
* *
*/ */
/* #define DEFAULT_CODE_JIS */ /* #define DEFAULT_CODE_JIS */

View file

@ -820,7 +820,7 @@ nkf_buf_new(int length)
buf->capa = length; buf->capa = length;
buf->len = 0; buf->len = 0;
return buf; return buf;
} }
#if 0 #if 0
static void static void
@ -5870,7 +5870,7 @@ finished:
/* /*
* int options(unsigned char *cp) * int options(unsigned char *cp)
* *
* return values: * return values:
* 0: success * 0: success
* -1: ArgumentError * -1: ArgumentError

View file

@ -1,7 +1,7 @@
/* /*
* *
* nkf.h - Header file for nkf * nkf.h - Header file for nkf
* *
* $Id$ * $Id$
*/ */

View file

@ -203,7 +203,7 @@ rb_nkf_guess(VALUE obj, VALUE src)
/* /*
* NKF - Ruby extension for Network Kanji Filter * NKF - Ruby extension for Network Kanji Filter
* *
* == Description * == Description
* *
@ -341,7 +341,7 @@ rb_nkf_guess(VALUE obj, VALUE src)
* To see ISO8859-1 (Latin-1) -l is necessary. * To see ISO8859-1 (Latin-1) -l is necessary.
* *
* [-mB] Decode MIME base64 encoded stream. Remove header or other part before * [-mB] Decode MIME base64 encoded stream. Remove header or other part before
* conversion. * conversion.
* *
* [-mQ] Decode MIME quoted stream. '_' in quoted stream is converted to space. * [-mQ] Decode MIME quoted stream. '_' in quoted stream is converted to space.
* *

View file

@ -15,7 +15,7 @@
/* objspace library extends ObjectSpace module and add several /* objspace library extends ObjectSpace module and add several
* methods to get internal statistic information about * methods to get internal statistic information about
* object/memory management. * object/memory management.
* *
* Generally, you *SHOULD NOT*use this library if you do not know * Generally, you *SHOULD NOT*use this library if you do not know
* about the MRI implementation. Mainly, this library is for (memory) * about the MRI implementation. Mainly, this library is for (memory)
* profiler developers and MRI developers who need to know how MRI * profiler developers and MRI developers who need to know how MRI
@ -203,7 +203,7 @@ cos_i(void *vstart, void *vend, size_t stride, void *data)
* *
* It returns a hash as: * It returns a hash as:
* {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...} * {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...}
* *
* If the optional argument, result_hash, is given, * If the optional argument, result_hash, is given,
* it is overwritten and returned. * it is overwritten and returned.
* This is intended to avoid probe effect. * This is intended to avoid probe effect.
@ -532,7 +532,7 @@ count_tdata_objects(int argc, VALUE *argv, VALUE self)
/* objspace library extends ObjectSpace module and add several /* objspace library extends ObjectSpace module and add several
* methods to get internal statistic information about * methods to get internal statistic information about
* object/memory management. * object/memory management.
* *
* Generally, you *SHOULD NOT*use this library if you do not know * Generally, you *SHOULD NOT*use this library if you do not know
* about the MRI implementation. Mainly, this library is for (memory) * about the MRI implementation. Mainly, this library is for (memory)
* profiler developers and MRI developers who need to know how MRI * profiler developers and MRI developers who need to know how MRI

View file

@ -41,7 +41,7 @@ int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data)
{ {
return CRYPTO_set_ex_data(&str->ex_data, idx, data); return CRYPTO_set_ex_data(&str->ex_data, idx, data);
} }
void *X509_STORE_get_ex_data(X509_STORE *str, int idx) void *X509_STORE_get_ex_data(X509_STORE *str, int idx)
{ {
return CRYPTO_get_ex_data(&str->ex_data, idx); return CRYPTO_get_ex_data(&str->ex_data, idx);
@ -111,7 +111,7 @@ HMAC_CTX_cleanup(HMAC_CTX *ctx)
#endif #endif
#if !defined(HAVE_EVP_CIPHER_CTX_COPY) #if !defined(HAVE_EVP_CIPHER_CTX_COPY)
/* /*
* this function does not exist in OpenSSL yet... or ever?. * this function does not exist in OpenSSL yet... or ever?.
* a future version may break this function. * a future version may break this function.
* tested on 0.9.7d. * tested on 0.9.7d.
@ -180,12 +180,12 @@ OSSL_X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const
(ASN1_STRING *)(*a)->serialNumber, (ASN1_STRING *)(*a)->serialNumber,
(ASN1_STRING *)(*b)->serialNumber)); (ASN1_STRING *)(*b)->serialNumber));
} }
int int
X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev) X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
{ {
X509_CRL_INFO *inf; X509_CRL_INFO *inf;
inf = crl->crl; inf = crl->crl;
if (!inf->revoked) if (!inf->revoked)
inf->revoked = sk_X509_REVOKED_new(OSSL_X509_REVOKED_cmp); inf->revoked = sk_X509_REVOKED_new(OSSL_X509_REVOKED_cmp);
@ -313,7 +313,7 @@ PEM_def_callback(char *buf, int num, int w, void *key)
{ {
int i,j; int i,j;
const char *prompt; const char *prompt;
if (key) { if (key) {
i = strlen(key); i = strlen(key);
i = (i > num) ? num : i; i = (i > num) ? num : i;

View file

@ -48,7 +48,7 @@ string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len
* Data Conversion * Data Conversion
*/ */
STACK_OF(X509) * STACK_OF(X509) *
ossl_x509_ary2sk0(VALUE ary) ossl_x509_ary2sk0(VALUE ary)
{ {
STACK_OF(X509) *sk; STACK_OF(X509) *sk;
VALUE val; VALUE val;
@ -57,13 +57,13 @@ ossl_x509_ary2sk0(VALUE ary)
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
sk = sk_X509_new_null(); sk = sk_X509_new_null();
if (!sk) ossl_raise(eOSSLError, NULL); if (!sk) ossl_raise(eOSSLError, NULL);
for (i = 0; i < RARRAY_LEN(ary); i++) { for (i = 0; i < RARRAY_LEN(ary); i++) {
val = rb_ary_entry(ary, i); val = rb_ary_entry(ary, i);
if (!rb_obj_is_kind_of(val, cX509Cert)) { if (!rb_obj_is_kind_of(val, cX509Cert)) {
sk_X509_pop_free(sk, X509_free); sk_X509_pop_free(sk, X509_free);
ossl_raise(eOSSLError, "object not X509 cert in array"); ossl_raise(eOSSLError, "object not X509 cert in array");
} }
x509 = DupX509CertPtr(val); /* NEED TO DUP */ x509 = DupX509CertPtr(val); /* NEED TO DUP */
sk_X509_push(sk, x509); sk_X509_push(sk, x509);
@ -157,7 +157,7 @@ ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
{ {
int len, status = 0; int len, status = 0;
VALUE rflag, pass; VALUE rflag, pass;
if (pwd || !rb_block_given_p()) if (pwd || !rb_block_given_p())
return PEM_def_callback(buf, max_len, flag, pwd); return PEM_def_callback(buf, max_len, flag, pwd);
@ -192,12 +192,12 @@ int ossl_verify_cb_idx;
VALUE VALUE
ossl_call_verify_cb_proc(struct ossl_verify_cb_args *args) ossl_call_verify_cb_proc(struct ossl_verify_cb_args *args)
{ {
return rb_funcall(args->proc, rb_intern("call"), 2, return rb_funcall(args->proc, rb_intern("call"), 2,
args->preverify_ok, args->store_ctx); args->preverify_ok, args->store_ctx);
} }
int int
ossl_verify_cb(int ok, X509_STORE_CTX *ctx) ossl_verify_cb(int ok, X509_STORE_CTX *ctx)
{ {
VALUE proc, rctx, ret; VALUE proc, rctx, ret;

View file

@ -27,7 +27,7 @@ asn1time_to_time(ASN1_TIME *time)
{ {
struct tm tm; struct tm tm;
VALUE argv[6]; VALUE argv[6];
if (!time || !time->data) return Qnil; if (!time || !time->data) return Qnil;
memset(&tm, 0, sizeof(struct tm)); memset(&tm, 0, sizeof(struct tm));
@ -36,7 +36,7 @@ asn1time_to_time(ASN1_TIME *time)
if (sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon, if (sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
ossl_raise(rb_eTypeError, "bad UTCTIME format"); ossl_raise(rb_eTypeError, "bad UTCTIME format");
} }
if (tm.tm_year < 69) { if (tm.tm_year < 69) {
tm.tm_year += 2000; tm.tm_year += 2000;
} else { } else {
@ -47,7 +47,7 @@ asn1time_to_time(ASN1_TIME *time)
if (sscanf((const char *)time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon, if (sscanf((const char *)time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" ); ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" );
} }
break; break;
default: default:
rb_warning("unknown time format"); rb_warning("unknown time format");
@ -144,7 +144,7 @@ ASN1_INTEGER *
num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai) num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
{ {
BIGNUM *bn = GetBNPtr(obj); BIGNUM *bn = GetBNPtr(obj);
if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) { if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
ossl_raise(eOSSLError, NULL); ossl_raise(eOSSLError, NULL);
} }
@ -321,7 +321,7 @@ decode_int(unsigned char* der, int length)
{ {
ASN1_INTEGER *ai; ASN1_INTEGER *ai;
const unsigned char *p; const unsigned char *p;
VALUE ret; VALUE ret;
int status = 0; int status = 0;
p = der; p = der;
@ -361,7 +361,7 @@ decode_enum(unsigned char* der, int length)
{ {
ASN1_ENUMERATED *ai; ASN1_ENUMERATED *ai;
const unsigned char *p; const unsigned char *p;
VALUE ret; VALUE ret;
int status = 0; int status = 0;
p = der; p = der;
@ -524,7 +524,7 @@ ossl_asn1_get_asn1type(VALUE obj)
case V_ASN1_ISO64STRING: /* FALLTHROUGH */ case V_ASN1_ISO64STRING: /* FALLTHROUGH */
case V_ASN1_GENERALSTRING: /* FALLTHROUGH */ case V_ASN1_GENERALSTRING: /* FALLTHROUGH */
case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */ case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
case V_ASN1_BMPSTRING: case V_ASN1_BMPSTRING:
ptr = obj_to_asn1str(value); ptr = obj_to_asn1str(value);
free_func = ASN1_STRING_free; free_func = ASN1_STRING_free;
break; break;
@ -660,8 +660,8 @@ ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
return self; return self;
} }
static VALUE static VALUE
join_der_i(VALUE i, VALUE str) join_der_i(VALUE i, VALUE str)
{ {
i = ossl_to_der_if_possible(i); i = ossl_to_der_if_possible(i);
StringValue(i); StringValue(i);
@ -737,7 +737,7 @@ ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
rb_yield(arg); rb_yield(arg);
} }
length -= hlen; length -= hlen;
off += hlen; off += hlen;
if(len > length) ossl_raise(eASN1Error, "value is too short"); if(len > length) ossl_raise(eASN1Error, "value is too short");
if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE) if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
tag_class = sPRIVATE; tag_class = sPRIVATE;

View file

@ -32,12 +32,12 @@ ASN1_INTEGER *num_to_asn1integer(VALUE, ASN1_INTEGER *);
* ASN1 module * ASN1 module
*/ */
extern VALUE mASN1; extern VALUE mASN1;
extern VALUE eASN1Error; extern VALUE eASN1Error;
extern VALUE cASN1Data; extern VALUE cASN1Data;
extern VALUE cASN1Primitive; extern VALUE cASN1Primitive;
extern VALUE cASN1Constructive; extern VALUE cASN1Constructive;
extern VALUE cASN1Boolean; /* BOOLEAN */ extern VALUE cASN1Boolean; /* BOOLEAN */
extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */ extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
extern VALUE cASN1BitString; /* BIT STRING */ extern VALUE cASN1BitString; /* BIT STRING */

View file

@ -72,7 +72,7 @@ ossl_protect_membio2str(BIO *bio, int *status)
return rb_protect((VALUE(*)_((VALUE)))ossl_membio2str0, (VALUE)bio, status); return rb_protect((VALUE(*)_((VALUE)))ossl_membio2str0, (VALUE)bio, status);
} }
VALUE VALUE
ossl_membio2str(BIO *bio) ossl_membio2str(BIO *bio)
{ {
VALUE ret; VALUE ret;

View file

@ -380,7 +380,7 @@ ossl_bn_div(VALUE self, VALUE other)
} }
WrapBN(CLASS_OF(self), obj1, r1); WrapBN(CLASS_OF(self), obj1, r1);
WrapBN(CLASS_OF(self), obj2, r2); WrapBN(CLASS_OF(self), obj2, r2);
return rb_ary_new3(2, obj1, obj2); return rb_ary_new3(2, obj1, obj2);
} }
@ -591,7 +591,7 @@ ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
ossl_raise(eBNError, NULL); ossl_raise(eBNError, NULL);
} }
WrapBN(klass, obj, result); WrapBN(klass, obj, result);
return obj; return obj;
} }
@ -615,14 +615,14 @@ static VALUE
ossl_bn_copy(VALUE self, VALUE other) ossl_bn_copy(VALUE self, VALUE other)
{ {
BIGNUM *bn1, *bn2; BIGNUM *bn1, *bn2;
rb_check_frozen(self); rb_check_frozen(self);
if (self == other) return self; if (self == other) return self;
GetBN(self, bn1); GetBN(self, bn1);
bn2 = GetBNPtr(other); bn2 = GetBNPtr(other);
if (!BN_copy(bn1, bn2)) { if (!BN_copy(bn1, bn2)) {
ossl_raise(eBNError, NULL); ossl_raise(eBNError, NULL);
} }
@ -793,7 +793,7 @@ Init_ossl_bn()
* value_one - DON'T IMPL. * value_one - DON'T IMPL.
* set_word * set_word
* get_word */ * get_word */
rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, -1); rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, -1);
rb_define_singleton_method(cBN, "pseudo_rand", ossl_bn_s_pseudo_rand, -1); rb_define_singleton_method(cBN, "pseudo_rand", ossl_bn_s_pseudo_rand, -1);
rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1); rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1);

View file

@ -287,7 +287,7 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest); digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
GetCipher(self, ctx); GetCipher(self, ctx);
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt, EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
(unsigned char *)RSTRING_PTR(vpass), RSTRING_LEN(vpass), iter, key, iv); (unsigned char *)RSTRING_PTR(vpass), RSTRING_LEN(vpass), iter, key, iv);
if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1) if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
ossl_raise(eCipherError, NULL); ossl_raise(eCipherError, NULL);
OPENSSL_cleanse(key, sizeof key); OPENSSL_cleanse(key, sizeof key);
@ -305,7 +305,7 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
* +data+ is a nonempty string. * +data+ is a nonempty string.
* +buffer+ is an optional string to store the result. * +buffer+ is an optional string to store the result.
*/ */
static VALUE static VALUE
ossl_cipher_update(int argc, VALUE *argv, VALUE self) ossl_cipher_update(int argc, VALUE *argv, VALUE self)
{ {
EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX *ctx;
@ -345,7 +345,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
* *
* See EVP_CipherFinal_ex for further information. * See EVP_CipherFinal_ex for further information.
*/ */
static VALUE static VALUE
ossl_cipher_final(VALUE self) ossl_cipher_final(VALUE self)
{ {
EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX *ctx;
@ -445,7 +445,7 @@ ossl_cipher_set_key_length(VALUE self, VALUE key_length)
{ {
int len = NUM2INT(key_length); int len = NUM2INT(key_length);
EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX *ctx;
GetCipher(self, ctx); GetCipher(self, ctx);
if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1) if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1)
ossl_raise(eCipherError, NULL); ossl_raise(eCipherError, NULL);
@ -515,7 +515,7 @@ static VALUE ossl_cipher_block_size() { }
/* /*
* INIT * INIT
*/ */
void void
Init_ossl_cipher(void) Init_ossl_cipher(void)
{ {
#if 0 /* let rdoc know about mOSSL */ #if 0 /* let rdoc know about mOSSL */

View file

@ -33,8 +33,8 @@
VALUE cConfig; VALUE cConfig;
VALUE eConfigError; VALUE eConfigError;
/* /*
* Public * Public
*/ */
static CONF *parse_config(VALUE, CONF*); static CONF *parse_config(VALUE, CONF*);
@ -154,7 +154,7 @@ ossl_config_initialize(int argc, VALUE *argv, VALUE self)
_CONF_new_data(conf); _CONF_new_data(conf);
} }
#endif #endif
return self; return self;
} }
@ -187,7 +187,7 @@ ossl_config_add_value(VALUE self, VALUE section, VALUE name, VALUE value)
OPENSSL_free(cv); OPENSSL_free(cv);
ossl_raise(eConfigError, "_CONF_add_string failure"); ossl_raise(eConfigError, "_CONF_add_string failure");
} }
return value; return value;
#endif #endif
} }
@ -233,7 +233,7 @@ static VALUE
ossl_config_get_value_old(int argc, VALUE *argv, VALUE self) ossl_config_get_value_old(int argc, VALUE *argv, VALUE self)
{ {
VALUE section, name; VALUE section, name;
rb_scan_args(argc, argv, "11", &section, &name); rb_scan_args(argc, argv, "11", &section, &name);
/* support conf.value(nil, "HOME") -> conf.get_value("", "HOME") */ /* support conf.value(nil, "HOME") -> conf.get_value("", "HOME") */

View file

@ -56,14 +56,14 @@ GetDigestPtr(VALUE obj)
VALUE VALUE
ossl_digest_new(const EVP_MD *md) ossl_digest_new(const EVP_MD *md)
{ {
VALUE ret; VALUE ret;
EVP_MD_CTX *ctx; EVP_MD_CTX *ctx;
ret = ossl_digest_alloc(cDigest); ret = ossl_digest_alloc(cDigest);
GetDigest(ret, ctx); GetDigest(ret, ctx);
EVP_DigestInit_ex(ctx, md, NULL); EVP_DigestInit_ex(ctx, md, NULL);
return ret; return ret;
} }
@ -104,7 +104,7 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
GetDigest(self, ctx); GetDigest(self, ctx);
EVP_DigestInit_ex(ctx, md, NULL); EVP_DigestInit_ex(ctx, md, NULL);
if (!NIL_P(data)) return ossl_digest_update(self, data); if (!NIL_P(data)) return ossl_digest_update(self, data);
return self; return self;
} }
@ -113,7 +113,7 @@ static VALUE
ossl_digest_copy(VALUE self, VALUE other) ossl_digest_copy(VALUE self, VALUE other)
{ {
EVP_MD_CTX *ctx1, *ctx2; EVP_MD_CTX *ctx1, *ctx2;
rb_check_frozen(self); rb_check_frozen(self);
if (self == other) return self; if (self == other) return self;

View file

@ -29,7 +29,7 @@
GetPKCS7(obj, engine); \ GetPKCS7(obj, engine); \
} while (0) } while (0)
/* /*
* Classes * Classes
*/ */
VALUE cEngine; VALUE cEngine;
@ -327,7 +327,7 @@ ossl_engine_inspect(VALUE self)
{ {
VALUE str; VALUE str;
const char *cname = rb_class2name(rb_obj_class(self)); const char *cname = rb_class2name(rb_obj_class(self));
str = rb_str_new2("#<"); str = rb_str_new2("#<");
rb_str_cat2(str, cname); rb_str_cat2(str, cname);
rb_str_cat2(str, " id=\""); rb_str_cat2(str, " id=\"");

View file

@ -80,7 +80,7 @@ static VALUE
ossl_hmac_copy(VALUE self, VALUE other) ossl_hmac_copy(VALUE self, VALUE other)
{ {
HMAC_CTX *ctx1, *ctx2; HMAC_CTX *ctx1, *ctx2;
rb_check_frozen(self); rb_check_frozen(self);
if (self == other) return self; if (self == other) return self;
@ -139,7 +139,7 @@ ossl_hmac_digest(VALUE self)
GetHMAC(self, ctx); GetHMAC(self, ctx);
hmac_final(ctx, &buf, &buf_len); hmac_final(ctx, &buf, &buf_len);
digest = ossl_buf2str((char *)buf, buf_len); digest = ossl_buf2str((char *)buf, buf_len);
return digest; return digest;
} }
@ -247,7 +247,7 @@ Init_ossl_hmac()
rb_define_alloc_func(cHMAC, ossl_hmac_alloc); rb_define_alloc_func(cHMAC, ossl_hmac_alloc);
rb_define_singleton_method(cHMAC, "digest", ossl_hmac_s_digest, 3); rb_define_singleton_method(cHMAC, "digest", ossl_hmac_s_digest, 3);
rb_define_singleton_method(cHMAC, "hexdigest", ossl_hmac_s_hexdigest, 3); rb_define_singleton_method(cHMAC, "hexdigest", ossl_hmac_s_hexdigest, 3);
rb_define_method(cHMAC, "initialize", ossl_hmac_initialize, 2); rb_define_method(cHMAC, "initialize", ossl_hmac_initialize, 2);
rb_define_copy_func(cHMAC, ossl_hmac_copy); rb_define_copy_func(cHMAC, ossl_hmac_copy);

View file

@ -91,7 +91,7 @@ ossl_spki_to_der(VALUE self)
if (i2d_NETSCAPE_SPKI(spki, &p) <= 0) if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
ossl_raise(eX509CertError, NULL); ossl_raise(eX509CertError, NULL);
ossl_str_adjust(str, p); ossl_str_adjust(str, p);
return str; return str;
} }
@ -187,7 +187,7 @@ ossl_spki_set_challenge(VALUE self, VALUE str)
RSTRING_LEN(str))) { RSTRING_LEN(str))) {
ossl_raise(eSPKIError, NULL); ossl_raise(eSPKIError, NULL);
} }
return str; return str;
} }

View file

@ -558,7 +558,7 @@ ossl_ocspbres_get_status(VALUE self)
} }
return ret; return ret;
} }
static VALUE static VALUE
ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self) ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)

View file

@ -81,7 +81,7 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
STACK_OF(X509) *x509s; STACK_OF(X509) *x509s;
int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0; int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0;
PKCS12 *p12; PKCS12 *p12;
rb_scan_args(argc, argv, "46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype); rb_scan_args(argc, argv, "46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype);
passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass); passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass);
friendlyname = NIL_P(name) ? NULL : StringValuePtr(name); friendlyname = NIL_P(name) ? NULL : StringValuePtr(name);

View file

@ -68,7 +68,7 @@
#define ossl_pkcs7_set_err_string(o,v) rb_iv_set((o), "@error_string", (v)) #define ossl_pkcs7_set_err_string(o,v) rb_iv_set((o), "@error_string", (v))
#define ossl_pkcs7_get_err_string(o) rb_iv_get((o), "@error_string") #define ossl_pkcs7_get_err_string(o) rb_iv_get((o), "@error_string")
/* /*
* Classes * Classes
*/ */
VALUE cPKCS7; VALUE cPKCS7;
@ -295,7 +295,7 @@ ossl_pkcs7_alloc(VALUE klass)
ossl_raise(ePKCS7Error, NULL); ossl_raise(ePKCS7Error, NULL);
} }
WrapPKCS7(klass, obj, pkcs7); WrapPKCS7(klass, obj, pkcs7);
return obj; return obj;
} }
@ -495,7 +495,7 @@ ossl_pkcs7_get_signer(VALUE self)
PKCS7_SIGNER_INFO *si; PKCS7_SIGNER_INFO *si;
int num, i; int num, i;
VALUE ary; VALUE ary;
GetPKCS7(self, pkcs7); GetPKCS7(self, pkcs7);
if (!(sk = PKCS7_get_signer_info(pkcs7))) { if (!(sk = PKCS7_get_signer_info(pkcs7))) {
OSSL_Debug("OpenSSL::PKCS7#get_signer_info == NULL!"); OSSL_Debug("OpenSSL::PKCS7#get_signer_info == NULL!");
@ -537,7 +537,7 @@ ossl_pkcs7_get_recipient(VALUE self)
PKCS7_RECIP_INFO *si; PKCS7_RECIP_INFO *si;
int num, i; int num, i;
VALUE ary; VALUE ary;
GetPKCS7(self, pkcs7); GetPKCS7(self, pkcs7);
if (PKCS7_type_is_enveloped(pkcs7)) if (PKCS7_type_is_enveloped(pkcs7))
sk = pkcs7->d.enveloped->recipientinfo; sk = pkcs7->d.enveloped->recipientinfo;
@ -777,7 +777,7 @@ ossl_pkcs7_add_data(VALUE self, VALUE data)
} }
if(!PKCS7_dataFinal(pkcs7, out)) goto err; if(!PKCS7_dataFinal(pkcs7, out)) goto err;
ossl_pkcs7_set_data(self, Qnil); ossl_pkcs7_set_data(self, Qnil);
err: err:
BIO_free(out); BIO_free(out);
BIO_free(in); BIO_free(in);
@ -1021,10 +1021,10 @@ Init_ossl_pkcs7()
cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject); cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject);
rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc); rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc);
rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1); rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1);
rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0); rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0);
rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0); rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0);
rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0); rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0);
#define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x)) #define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x))

View file

@ -214,7 +214,7 @@ Init_ossl_pkey()
#if 0 /* let rdoc know about mOSSL */ #if 0 /* let rdoc know about mOSSL */
mOSSL = rb_define_module("OpenSSL"); mOSSL = rb_define_module("OpenSSL");
#endif #endif
mPKey = rb_define_module_under(mOSSL, "PKey"); mPKey = rb_define_module_under(mOSSL, "PKey");
ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError); ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);

View file

@ -85,7 +85,7 @@ static DH *
dh_generate(int size, int gen) dh_generate(int size, int gen)
{ {
DH *dh; DH *dh;
dh = DH_generate_parameters(size, gen, dh = DH_generate_parameters(size, gen,
rb_block_given_p() ? ossl_generate_cb : NULL, rb_block_given_p() ? ossl_generate_cb : NULL,
NULL); NULL);
@ -244,7 +244,7 @@ ossl_dh_export(VALUE self)
*/ */
static VALUE static VALUE
ossl_dh_to_der(VALUE self) ossl_dh_to_der(VALUE self)
{ {
EVP_PKEY *pkey; EVP_PKEY *pkey;
unsigned char *p; unsigned char *p;
long len; long len;
@ -284,7 +284,7 @@ ossl_dh_get_params(VALUE self)
rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dh->g)); rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dh->g));
rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dh->pub_key)); rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dh->pub_key));
rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dh->priv_key)); rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dh->priv_key));
return hash; return hash;
} }
@ -351,7 +351,7 @@ ossl_dh_check_params(VALUE self)
DH *dh; DH *dh;
EVP_PKEY *pkey; EVP_PKEY *pkey;
int codes; int codes;
GetPKeyDH(self, pkey); GetPKeyDH(self, pkey);
dh = pkey->pkey.dh; dh = pkey->pkey.dh;
@ -436,10 +436,10 @@ static unsigned char DEFAULT_DH_512_PRIM[] = {
0x08, 0x04, 0x8c, 0x52, 0x8f, 0xe3, 0x4a, 0x31, 0x08, 0x04, 0x8c, 0x52, 0x8f, 0xe3, 0x4a, 0x31,
0x44, 0x47, 0x19, 0xa1, 0x4a, 0xc8, 0x8b, 0xcb, 0x44, 0x47, 0x19, 0xa1, 0x4a, 0xc8, 0x8b, 0xcb,
}; };
static unsigned char DEFAULT_DH_512_GEN[] = { 0x02 }; static unsigned char DEFAULT_DH_512_GEN[] = { 0x02 };
DH *OSSL_DEFAULT_DH_512 = NULL; DH *OSSL_DEFAULT_DH_512 = NULL;
/* /*
* -----BEGIN DH PARAMETERS----- * -----BEGIN DH PARAMETERS-----
* MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ * MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ
* AV/ZD2AWPbrTqV76mGRgJg4EddgT1zG0jq3rnFdMj2XzkBYx3BVvfR0Arnby0RHR * AV/ZD2AWPbrTqV76mGRgJg4EddgT1zG0jq3rnFdMj2XzkBYx3BVvfR0Arnby0RHR

View file

@ -320,7 +320,7 @@ ossl_dsa_get_params(VALUE self)
rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dsa->g)); rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dsa->g));
rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dsa->pub_key)); rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dsa->pub_key));
rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dsa->priv_key)); rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dsa->priv_key));
return hash; return hash;
} }

View file

@ -274,7 +274,7 @@ static VALUE ossl_ec_key_get_group(VALUE self)
* the group. * the group.
* *
* Setting the group will immediately destroy any previously assigned group object. * Setting the group will immediately destroy any previously assigned group object.
* The group is internally copied by OpenSSL. Modifying the original group after * The group is internally copied by OpenSSL. Modifying the original group after
* assignment will not effect the internal key structure. * assignment will not effect the internal key structure.
* (your changes may be lost). BE CAREFUL. * (your changes may be lost). BE CAREFUL.
* *
@ -1023,7 +1023,7 @@ static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v)
} }
/* call-seq: /* call-seq:
* group.point_conversion_form => :uncompressed | :compressed | :hybrid * group.point_conversion_form => :uncompressed | :compressed | :hybrid
* *
* See the OpenSSL documentation for EC_GROUP_get_point_conversion_form() * See the OpenSSL documentation for EC_GROUP_get_point_conversion_form()
*/ */
@ -1043,7 +1043,7 @@ static VALUE ossl_ec_group_get_point_conversion_form(VALUE self)
case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break; case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break;
default: rb_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form); default: rb_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form);
} }
return ID2SYM(ret); return ID2SYM(ret);
} }
@ -1270,7 +1270,7 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "1st argument must be OpenSSL::PKey::EC::Group"); rb_raise(rb_eArgError, "1st argument must be OpenSSL::PKey::EC::Group");
group_v = arg1; group_v = arg1;
SafeRequire_EC_GROUP(group_v, group); SafeRequire_EC_GROUP(group_v, group);
if (rb_obj_is_kind_of(arg2, cBN)) { if (rb_obj_is_kind_of(arg2, cBN)) {
const BIGNUM *bn = GetBNPtr(arg2); const BIGNUM *bn = GetBNPtr(arg2);

View file

@ -124,7 +124,7 @@ ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass)
* * +pass+ is an optional string with the password to decrypt the encoded key. * * +pass+ is an optional string with the password to decrypt the encoded key.
* *
* === Examples * === Examples
* * RSA.new(2048) -> rsa * * RSA.new(2048) -> rsa
* * RSA.new(File.read("rsa.pem")) -> rsa * * RSA.new(File.read("rsa.pem")) -> rsa
* * RSA.new(File.read("rsa.pem"), "mypassword") -> rsa * * RSA.new(File.read("rsa.pem"), "mypassword") -> rsa
*/ */
@ -211,7 +211,7 @@ ossl_rsa_is_private(VALUE self)
EVP_PKEY *pkey; EVP_PKEY *pkey;
GetPKeyRSA(self, pkey); GetPKeyRSA(self, pkey);
return (RSA_PRIVATE(self, pkey->pkey.rsa)) ? Qtrue : Qfalse; return (RSA_PRIVATE(self, pkey->pkey.rsa)) ? Qtrue : Qfalse;
} }
@ -262,7 +262,7 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self)
} }
} }
str = ossl_membio2str(out); str = ossl_membio2str(out);
return str; return str;
} }
@ -346,7 +346,7 @@ ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
pad); pad);
if (buf_len < 0) ossl_raise(eRSAError, NULL); if (buf_len < 0) ossl_raise(eRSAError, NULL);
rb_str_set_len(str, buf_len); rb_str_set_len(str, buf_len);
return str; return str;
} }
@ -375,7 +375,7 @@ ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
pad); pad);
if (buf_len < 0) ossl_raise(eRSAError, NULL); if (buf_len < 0) ossl_raise(eRSAError, NULL);
rb_str_set_len(str, buf_len); rb_str_set_len(str, buf_len);
return str; return str;
} }
@ -435,7 +435,7 @@ ossl_rsa_get_params(VALUE self)
rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(pkey->pkey.rsa->dmp1)); rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(pkey->pkey.rsa->dmp1));
rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(pkey->pkey.rsa->dmq1)); rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(pkey->pkey.rsa->dmq1));
rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(pkey->pkey.rsa->iqmp)); rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(pkey->pkey.rsa->iqmp));
return hash; return hash;
} }
@ -479,7 +479,7 @@ ossl_rsa_to_public_key(VALUE self)
EVP_PKEY *pkey; EVP_PKEY *pkey;
RSA *rsa; RSA *rsa;
VALUE obj; VALUE obj;
GetPKeyRSA(self, pkey); GetPKeyRSA(self, pkey);
/* err check performed by rsa_instance */ /* err check performed by rsa_instance */
rsa = RSAPublicKey_dup(pkey->pkey.rsa); rsa = RSAPublicKey_dup(pkey->pkey.rsa);
@ -498,7 +498,7 @@ static VALUE
ossl_rsa_blinding_on(VALUE self) ossl_rsa_blinding_on(VALUE self)
{ {
EVP_PKEY *pkey; EVP_PKEY *pkey;
GetPKeyRSA(self, pkey); GetPKeyRSA(self, pkey);
if (RSA_blinding_on(pkey->pkey.rsa, ossl_bn_ctx) != 1) { if (RSA_blinding_on(pkey->pkey.rsa, ossl_bn_ctx) != 1) {
@ -511,7 +511,7 @@ static VALUE
ossl_rsa_blinding_off(VALUE self) ossl_rsa_blinding_off(VALUE self)
{ {
EVP_PKEY *pkey; EVP_PKEY *pkey;
GetPKeyRSA(self, pkey); GetPKeyRSA(self, pkey);
RSA_blinding_off(pkey->pkey.rsa); RSA_blinding_off(pkey->pkey.rsa);

View file

@ -91,7 +91,7 @@ static const char *ossl_ssl_attrs[] = {
#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME #ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
"hostname", "hostname",
#endif #endif
"sync_close", "sync_close",
}; };
ID ID_callback_state; ID ID_callback_state;
@ -304,7 +304,7 @@ static VALUE
ossl_call_session_get_cb(VALUE ary) ossl_call_session_get_cb(VALUE ary)
{ {
VALUE ssl_obj, sslctx_obj, cb; VALUE ssl_obj, sslctx_obj, cb;
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
ssl_obj = rb_ary_entry(ary, 0); ssl_obj = rb_ary_entry(ary, 0);
@ -351,7 +351,7 @@ static VALUE
ossl_call_session_new_cb(VALUE ary) ossl_call_session_new_cb(VALUE ary)
{ {
VALUE ssl_obj, sslctx_obj, cb; VALUE ssl_obj, sslctx_obj, cb;
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
ssl_obj = rb_ary_entry(ary, 0); ssl_obj = rb_ary_entry(ary, 0);
@ -398,7 +398,7 @@ static VALUE
ossl_call_session_remove_cb(VALUE ary) ossl_call_session_remove_cb(VALUE ary)
{ {
VALUE sslctx_obj, cb; VALUE sslctx_obj, cb;
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
sslctx_obj = rb_ary_entry(ary, 0); sslctx_obj = rb_ary_entry(ary, 0);
@ -1585,7 +1585,7 @@ Init_ossl_ssl()
rb_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0); rb_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0);
rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF)); rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF));
rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */ rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */
rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER)); rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER));

View file

@ -22,7 +22,7 @@
OSSL_Check_Kind(obj, cSSLSession); \ OSSL_Check_Kind(obj, cSSLSession); \
GetSSLSession(obj, sess); \ GetSSLSession(obj, sess); \
} while (0) } while (0)
extern VALUE mSSL; extern VALUE mSSL;
extern VALUE eSSLError; extern VALUE eSSLError;
extern VALUE cSSLSocket; extern VALUE cSSLSocket;

View file

@ -15,7 +15,7 @@
OSSL_Check_Kind(obj, cSSLSession); \ OSSL_Check_Kind(obj, cSSLSession); \
GetSSLSession(obj, sess); \ GetSSLSession(obj, sess); \
} while (0) } while (0)
VALUE cSSLSession; VALUE cSSLSession;
static VALUE eSSLSession; static VALUE eSSLSession;
@ -214,7 +214,7 @@ static VALUE ossl_ssl_session_to_pem(VALUE self)
BUF_MEM *buf; BUF_MEM *buf;
VALUE str; VALUE str;
int i; int i;
GetSSLSession(self, ctx); GetSSLSession(self, ctx);
if (!(out = BIO_new(BIO_s_mem()))) { if (!(out = BIO_new(BIO_s_mem()))) {
@ -246,7 +246,7 @@ static VALUE ossl_ssl_session_to_text(VALUE self)
BIO *out; BIO *out;
BUF_MEM *buf; BUF_MEM *buf;
VALUE str; VALUE str;
GetSSLSession(self, ctx); GetSSLSession(self, ctx);
if (!(out = BIO_new(BIO_s_mem()))) { if (!(out = BIO_new(BIO_s_mem()))) {
@ -264,7 +264,7 @@ static VALUE ossl_ssl_session_to_text(VALUE self)
return str; return str;
} }
void Init_ossl_ssl_session(void) void Init_ossl_ssl_session(void)
{ {

View file

@ -41,7 +41,7 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr)
{ {
X509_ATTRIBUTE *new; X509_ATTRIBUTE *new;
VALUE obj; VALUE obj;
if (!attr) { if (!attr) {
new = X509_ATTRIBUTE_new(); new = X509_ATTRIBUTE_new();
} else { } else {
@ -77,7 +77,7 @@ ossl_x509attr_alloc(VALUE klass)
X509_ATTRIBUTE *attr; X509_ATTRIBUTE *attr;
VALUE obj; VALUE obj;
if (!(attr = X509_ATTRIBUTE_new())) if (!(attr = X509_ATTRIBUTE_new()))
ossl_raise(eX509AttrError, NULL); ossl_raise(eX509AttrError, NULL);
WrapX509Attr(klass, obj, attr); WrapX509Attr(klass, obj, attr);
@ -123,14 +123,14 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid)
X509_ATTRIBUTE *attr; X509_ATTRIBUTE *attr;
ASN1_OBJECT *obj; ASN1_OBJECT *obj;
char *s; char *s;
s = StringValuePtr(oid); s = StringValuePtr(oid);
obj = OBJ_txt2obj(s, 0); obj = OBJ_txt2obj(s, 0);
if(!obj) obj = OBJ_txt2obj(s, 1); if(!obj) obj = OBJ_txt2obj(s, 1);
if(!obj) ossl_raise(eX509AttrError, NULL); if(!obj) ossl_raise(eX509AttrError, NULL);
GetX509Attr(self, attr); GetX509Attr(self, attr);
X509_ATTRIBUTE_set1_object(attr, obj); X509_ATTRIBUTE_set1_object(attr, obj);
return oid; return oid;
} }
@ -157,7 +157,7 @@ ossl_x509attr_get_oid(VALUE self)
i2a_ASN1_OBJECT(out, oid); i2a_ASN1_OBJECT(out, oid);
ret = ossl_membio2str(out); ret = ossl_membio2str(out);
} }
return ret; return ret;
} }
@ -251,7 +251,7 @@ ossl_x509attr_to_der(VALUE self)
p = (unsigned char *)RSTRING_PTR(str); p = (unsigned char *)RSTRING_PTR(str);
if(i2d_X509_ATTRIBUTE(attr, &p) <= 0) if(i2d_X509_ATTRIBUTE(attr, &p) <= 0)
ossl_raise(eX509AttrError, NULL); ossl_raise(eX509AttrError, NULL);
rb_str_set_len(str, p - (unsigned char*)RSTRING_PTR(str)); rb_str_set_len(str, p - (unsigned char*)RSTRING_PTR(str));
return str; return str;
} }

View file

@ -55,7 +55,7 @@ ossl_x509_new(X509 *x509)
return obj; return obj;
} }
VALUE VALUE
ossl_x509_new_from_file(VALUE filename) ossl_x509_new_from_file(VALUE filename)
{ {
X509 *x509; X509 *x509;
@ -111,7 +111,7 @@ DupX509CertPtr(VALUE obj)
/* /*
* Private * Private
*/ */
static VALUE static VALUE
ossl_x509_alloc(VALUE klass) ossl_x509_alloc(VALUE klass)
{ {
X509 *x509; X509 *x509;
@ -130,7 +130,7 @@ ossl_x509_alloc(VALUE klass)
* Certificate.new => cert * Certificate.new => cert
* Certificate.new(string) => cert * Certificate.new(string) => cert
*/ */
static VALUE static VALUE
ossl_x509_initialize(int argc, VALUE *argv, VALUE self) ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
{ {
BIO *in; BIO *in;
@ -152,7 +152,7 @@ ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
} }
BIO_free(in); BIO_free(in);
if (!x509) ossl_raise(eX509CertError, NULL); if (!x509) ossl_raise(eX509CertError, NULL);
return self; return self;
} }
@ -169,7 +169,7 @@ ossl_x509_copy(VALUE self, VALUE other)
x509 = X509_dup(b); x509 = X509_dup(b);
if (!x509) ossl_raise(eX509CertError, NULL); if (!x509) ossl_raise(eX509CertError, NULL);
DATA_PTR(self) = x509; DATA_PTR(self) = x509;
X509_free(a); X509_free(a);
@ -180,7 +180,7 @@ ossl_x509_copy(VALUE self, VALUE other)
* call-seq: * call-seq:
* cert.to_der => string * cert.to_der => string
*/ */
static VALUE static VALUE
ossl_x509_to_der(VALUE self) ossl_x509_to_der(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -196,7 +196,7 @@ ossl_x509_to_der(VALUE self)
if (i2d_X509(x509, &p) <= 0) if (i2d_X509(x509, &p) <= 0)
ossl_raise(eX509CertError, NULL); ossl_raise(eX509CertError, NULL);
ossl_str_adjust(str, p); ossl_str_adjust(str, p);
return str; return str;
} }
@ -204,7 +204,7 @@ ossl_x509_to_der(VALUE self)
* call-seq: * call-seq:
* cert.to_pem => string * cert.to_pem => string
*/ */
static VALUE static VALUE
ossl_x509_to_pem(VALUE self) ossl_x509_to_pem(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -253,7 +253,7 @@ ossl_x509_to_text(VALUE self)
/* /*
* Makes from X509 X509_REQuest * Makes from X509 X509_REQuest
*/ */
static VALUE static VALUE
ossl_x509_to_req(VALUE self) ossl_x509_to_req(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -275,7 +275,7 @@ ossl_x509_to_req(VALUE self)
* call-seq: * call-seq:
* cert.version => integer * cert.version => integer
*/ */
static VALUE static VALUE
ossl_x509_get_version(VALUE self) ossl_x509_get_version(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -289,7 +289,7 @@ ossl_x509_get_version(VALUE self)
* call-seq: * call-seq:
* cert.version = integer => integer * cert.version = integer => integer
*/ */
static VALUE static VALUE
ossl_x509_set_version(VALUE self, VALUE version) ossl_x509_set_version(VALUE self, VALUE version)
{ {
X509 *x509; X509 *x509;
@ -310,7 +310,7 @@ ossl_x509_set_version(VALUE self, VALUE version)
* call-seq: * call-seq:
* cert.serial => integer * cert.serial => integer
*/ */
static VALUE static VALUE
ossl_x509_get_serial(VALUE self) ossl_x509_get_serial(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -324,7 +324,7 @@ ossl_x509_get_serial(VALUE self)
* call-seq: * call-seq:
* cert.serial = integer => integer * cert.serial = integer => integer
*/ */
static VALUE static VALUE
ossl_x509_set_serial(VALUE self, VALUE num) ossl_x509_set_serial(VALUE self, VALUE num)
{ {
X509 *x509; X509 *x509;
@ -341,7 +341,7 @@ ossl_x509_set_serial(VALUE self, VALUE num)
* call-seq: * call-seq:
* cert.signature_algorithm => string * cert.signature_algorithm => string
*/ */
static VALUE static VALUE
ossl_x509_get_signature_algorithm(VALUE self) ossl_x509_get_signature_algorithm(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -365,7 +365,7 @@ ossl_x509_get_signature_algorithm(VALUE self)
* call-seq: * call-seq:
* cert.subject => name * cert.subject => name
*/ */
static VALUE static VALUE
ossl_x509_get_subject(VALUE self) ossl_x509_get_subject(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -383,7 +383,7 @@ ossl_x509_get_subject(VALUE self)
* call-seq: * call-seq:
* cert.subject = name => name * cert.subject = name => name
*/ */
static VALUE static VALUE
ossl_x509_set_subject(VALUE self, VALUE subject) ossl_x509_set_subject(VALUE self, VALUE subject)
{ {
X509 *x509; X509 *x509;
@ -400,7 +400,7 @@ ossl_x509_set_subject(VALUE self, VALUE subject)
* call-seq: * call-seq:
* cert.issuer => name * cert.issuer => name
*/ */
static VALUE static VALUE
ossl_x509_get_issuer(VALUE self) ossl_x509_get_issuer(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -418,7 +418,7 @@ ossl_x509_get_issuer(VALUE self)
* call-seq: * call-seq:
* cert.issuer = name => name * cert.issuer = name => name
*/ */
static VALUE static VALUE
ossl_x509_set_issuer(VALUE self, VALUE issuer) ossl_x509_set_issuer(VALUE self, VALUE issuer)
{ {
X509 *x509; X509 *x509;
@ -435,7 +435,7 @@ ossl_x509_set_issuer(VALUE self, VALUE issuer)
* call-seq: * call-seq:
* cert.not_before => time * cert.not_before => time
*/ */
static VALUE static VALUE
ossl_x509_get_not_before(VALUE self) ossl_x509_get_not_before(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -453,7 +453,7 @@ ossl_x509_get_not_before(VALUE self)
* call-seq: * call-seq:
* cert.not_before = time => time * cert.not_before = time => time
*/ */
static VALUE static VALUE
ossl_x509_set_not_before(VALUE self, VALUE time) ossl_x509_set_not_before(VALUE self, VALUE time)
{ {
X509 *x509; X509 *x509;
@ -472,7 +472,7 @@ ossl_x509_set_not_before(VALUE self, VALUE time)
* call-seq: * call-seq:
* cert.not_after => time * cert.not_after => time
*/ */
static VALUE static VALUE
ossl_x509_get_not_after(VALUE self) ossl_x509_get_not_after(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -490,7 +490,7 @@ ossl_x509_get_not_after(VALUE self)
* call-seq: * call-seq:
* cert.not_before = time => time * cert.not_before = time => time
*/ */
static VALUE static VALUE
ossl_x509_set_not_after(VALUE self, VALUE time) ossl_x509_set_not_after(VALUE self, VALUE time)
{ {
X509 *x509; X509 *x509;
@ -509,7 +509,7 @@ ossl_x509_set_not_after(VALUE self, VALUE time)
* call-seq: * call-seq:
* cert.public_key => key * cert.public_key => key
*/ */
static VALUE static VALUE
ossl_x509_get_public_key(VALUE self) ossl_x509_get_public_key(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -527,7 +527,7 @@ ossl_x509_get_public_key(VALUE self)
* call-seq: * call-seq:
* cert.public_key = key => key * cert.public_key = key => key
*/ */
static VALUE static VALUE
ossl_x509_set_public_key(VALUE self, VALUE key) ossl_x509_set_public_key(VALUE self, VALUE key)
{ {
X509 *x509; X509 *x509;
@ -544,7 +544,7 @@ ossl_x509_set_public_key(VALUE self, VALUE key)
* call-seq: * call-seq:
* cert.sign(key, digest) => self * cert.sign(key, digest) => self
*/ */
static VALUE static VALUE
ossl_x509_sign(VALUE self, VALUE key, VALUE digest) ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
{ {
X509 *x509; X509 *x509;
@ -567,7 +567,7 @@ ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
* *
* Checks that cert signature is made with PRIVversion of this PUBLIC 'key' * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
*/ */
static VALUE static VALUE
ossl_x509_verify(VALUE self, VALUE key) ossl_x509_verify(VALUE self, VALUE key)
{ {
X509 *x509; X509 *x509;
@ -578,7 +578,7 @@ ossl_x509_verify(VALUE self, VALUE key)
GetX509(self, x509); GetX509(self, x509);
if ((i = X509_verify(x509, pkey)) < 0) { if ((i = X509_verify(x509, pkey)) < 0) {
ossl_raise(eX509CertError, NULL); ossl_raise(eX509CertError, NULL);
} }
if (i > 0) { if (i > 0) {
return Qtrue; return Qtrue;
} }
@ -592,7 +592,7 @@ ossl_x509_verify(VALUE self, VALUE key)
* *
* Checks if 'key' is PRIV key for this cert * Checks if 'key' is PRIV key for this cert
*/ */
static VALUE static VALUE
ossl_x509_check_private_key(VALUE self, VALUE key) ossl_x509_check_private_key(VALUE self, VALUE key)
{ {
X509 *x509; X509 *x509;
@ -613,7 +613,7 @@ ossl_x509_check_private_key(VALUE self, VALUE key)
* call-seq: * call-seq:
* cert.extensions => [extension...] * cert.extensions => [extension...]
*/ */
static VALUE static VALUE
ossl_x509_get_extensions(VALUE self) ossl_x509_get_extensions(VALUE self)
{ {
X509 *x509; X509 *x509;
@ -639,7 +639,7 @@ ossl_x509_get_extensions(VALUE self)
* call-seq: * call-seq:
* cert.extensions = [ext...] => [ext...] * cert.extensions = [ext...] => [ext...]
*/ */
static VALUE static VALUE
ossl_x509_set_extensions(VALUE self, VALUE ary) ossl_x509_set_extensions(VALUE self, VALUE ary)
{ {
X509 *x509; X509 *x509;
@ -671,7 +671,7 @@ ossl_x509_set_extensions(VALUE self, VALUE ary)
* call-seq: * call-seq:
* cert.add_extension(extension) => extension * cert.add_extension(extension) => extension
*/ */
static VALUE static VALUE
ossl_x509_add_extension(VALUE self, VALUE extension) ossl_x509_add_extension(VALUE self, VALUE extension)
{ {
X509 *x509; X509 *x509;
@ -725,7 +725,7 @@ ossl_x509_inspect(VALUE self)
/* /*
* INIT * INIT
*/ */
void void
Init_ossl_x509cert() Init_ossl_x509cert()
{ {
eX509CertError = rb_define_class_under(mX509, "CertificateError", eOSSLError); eX509CertError = rb_define_class_under(mX509, "CertificateError", eOSSLError);
@ -735,7 +735,7 @@ Init_ossl_x509cert()
rb_define_alloc_func(cX509Cert, ossl_x509_alloc); rb_define_alloc_func(cX509Cert, ossl_x509_alloc);
rb_define_method(cX509Cert, "initialize", ossl_x509_initialize, -1); rb_define_method(cX509Cert, "initialize", ossl_x509_initialize, -1);
rb_define_copy_func(cX509Cert, ossl_x509_copy); rb_define_copy_func(cX509Cert, ossl_x509_copy);
rb_define_method(cX509Cert, "to_der", ossl_x509_to_der, 0); rb_define_method(cX509Cert, "to_der", ossl_x509_to_der, 0);
rb_define_method(cX509Cert, "to_pem", ossl_x509_to_pem, 0); rb_define_method(cX509Cert, "to_pem", ossl_x509_to_pem, 0);
rb_define_alias(cX509Cert, "to_s", "to_pem"); rb_define_alias(cX509Cert, "to_s", "to_pem");

View file

@ -66,14 +66,14 @@ ossl_x509crl_new(X509_CRL *crl)
tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new(); tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
if(!tmp) ossl_raise(eX509CRLError, NULL); if(!tmp) ossl_raise(eX509CRLError, NULL);
WrapX509CRL(cX509CRL, obj, tmp); WrapX509CRL(cX509CRL, obj, tmp);
return obj; return obj;
} }
/* /*
* PRIVATE * PRIVATE
*/ */
static VALUE static VALUE
ossl_x509crl_alloc(VALUE klass) ossl_x509crl_alloc(VALUE klass)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -87,7 +87,7 @@ ossl_x509crl_alloc(VALUE klass)
return obj; return obj;
} }
static VALUE static VALUE
ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self) ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self)
{ {
BIO *in; BIO *in;
@ -130,7 +130,7 @@ ossl_x509crl_copy(VALUE self, VALUE other)
return self; return self;
} }
static VALUE static VALUE
ossl_x509crl_get_version(VALUE self) ossl_x509crl_get_version(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -142,7 +142,7 @@ ossl_x509crl_get_version(VALUE self)
return LONG2NUM(ver); return LONG2NUM(ver);
} }
static VALUE static VALUE
ossl_x509crl_set_version(VALUE self, VALUE version) ossl_x509crl_set_version(VALUE self, VALUE version)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -159,7 +159,7 @@ ossl_x509crl_set_version(VALUE self, VALUE version)
return version; return version;
} }
static VALUE static VALUE
ossl_x509crl_get_signature_algorithm(VALUE self) ossl_x509crl_get_signature_algorithm(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -181,7 +181,7 @@ ossl_x509crl_get_signature_algorithm(VALUE self)
return str; return str;
} }
static VALUE static VALUE
ossl_x509crl_get_issuer(VALUE self) ossl_x509crl_get_issuer(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -191,7 +191,7 @@ ossl_x509crl_get_issuer(VALUE self)
return ossl_x509name_new(X509_CRL_get_issuer(crl)); /* NO DUP - don't free */ return ossl_x509name_new(X509_CRL_get_issuer(crl)); /* NO DUP - don't free */
} }
static VALUE static VALUE
ossl_x509crl_set_issuer(VALUE self, VALUE issuer) ossl_x509crl_set_issuer(VALUE self, VALUE issuer)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -204,7 +204,7 @@ ossl_x509crl_set_issuer(VALUE self, VALUE issuer)
return issuer; return issuer;
} }
static VALUE static VALUE
ossl_x509crl_get_last_update(VALUE self) ossl_x509crl_get_last_update(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -214,7 +214,7 @@ ossl_x509crl_get_last_update(VALUE self)
return asn1time_to_time(X509_CRL_get_lastUpdate(crl)); return asn1time_to_time(X509_CRL_get_lastUpdate(crl));
} }
static VALUE static VALUE
ossl_x509crl_set_last_update(VALUE self, VALUE time) ossl_x509crl_set_last_update(VALUE self, VALUE time)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -229,7 +229,7 @@ ossl_x509crl_set_last_update(VALUE self, VALUE time)
return time; return time;
} }
static VALUE static VALUE
ossl_x509crl_get_next_update(VALUE self) ossl_x509crl_get_next_update(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -239,7 +239,7 @@ ossl_x509crl_get_next_update(VALUE self)
return asn1time_to_time(X509_CRL_get_nextUpdate(crl)); return asn1time_to_time(X509_CRL_get_nextUpdate(crl));
} }
static VALUE static VALUE
ossl_x509crl_set_next_update(VALUE self, VALUE time) ossl_x509crl_set_next_update(VALUE self, VALUE time)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -280,7 +280,7 @@ ossl_x509crl_get_revoked(VALUE self)
return ary; return ary;
} }
static VALUE static VALUE
ossl_x509crl_set_revoked(VALUE self, VALUE ary) ossl_x509crl_set_revoked(VALUE self, VALUE ary)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -306,7 +306,7 @@ ossl_x509crl_set_revoked(VALUE self, VALUE ary)
return ary; return ary;
} }
static VALUE static VALUE
ossl_x509crl_add_revoked(VALUE self, VALUE revoked) ossl_x509crl_add_revoked(VALUE self, VALUE revoked)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -322,7 +322,7 @@ ossl_x509crl_add_revoked(VALUE self, VALUE revoked)
return revoked; return revoked;
} }
static VALUE static VALUE
ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest) ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -339,7 +339,7 @@ ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
return self; return self;
} }
static VALUE static VALUE
ossl_x509crl_verify(VALUE self, VALUE key) ossl_x509crl_verify(VALUE self, VALUE key)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -356,7 +356,7 @@ ossl_x509crl_verify(VALUE self, VALUE key)
return Qfalse; return Qfalse;
} }
static VALUE static VALUE
ossl_x509crl_to_der(VALUE self) ossl_x509crl_to_der(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -379,7 +379,7 @@ ossl_x509crl_to_der(VALUE self)
return str; return str;
} }
static VALUE static VALUE
ossl_x509crl_to_pem(VALUE self) ossl_x509crl_to_pem(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -402,7 +402,7 @@ ossl_x509crl_to_pem(VALUE self)
return str; return str;
} }
static VALUE static VALUE
ossl_x509crl_to_text(VALUE self) ossl_x509crl_to_text(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -428,7 +428,7 @@ ossl_x509crl_to_text(VALUE self)
/* /*
* Gets X509v3 extensions as array of X509Ext objects * Gets X509v3 extensions as array of X509Ext objects
*/ */
static VALUE static VALUE
ossl_x509crl_get_extensions(VALUE self) ossl_x509crl_get_extensions(VALUE self)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -454,7 +454,7 @@ ossl_x509crl_get_extensions(VALUE self)
/* /*
* Sets X509_EXTENSIONs * Sets X509_EXTENSIONs
*/ */
static VALUE static VALUE
ossl_x509crl_set_extensions(VALUE self, VALUE ary) ossl_x509crl_set_extensions(VALUE self, VALUE ary)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -481,7 +481,7 @@ ossl_x509crl_set_extensions(VALUE self, VALUE ary)
return ary; return ary;
} }
static VALUE static VALUE
ossl_x509crl_add_extension(VALUE self, VALUE extension) ossl_x509crl_add_extension(VALUE self, VALUE extension)
{ {
X509_CRL *crl; X509_CRL *crl;
@ -501,7 +501,7 @@ ossl_x509crl_add_extension(VALUE self, VALUE extension)
/* /*
* INIT * INIT
*/ */
void void
Init_ossl_x509crl() Init_ossl_x509crl()
{ {
eX509CRLError = rb_define_class_under(mX509, "CRLError", eOSSLError); eX509CRLError = rb_define_class_under(mX509, "CRLError", eOSSLError);
@ -511,7 +511,7 @@ Init_ossl_x509crl()
rb_define_alloc_func(cX509CRL, ossl_x509crl_alloc); rb_define_alloc_func(cX509CRL, ossl_x509crl_alloc);
rb_define_method(cX509CRL, "initialize", ossl_x509crl_initialize, -1); rb_define_method(cX509CRL, "initialize", ossl_x509crl_initialize, -1);
rb_define_copy_func(cX509CRL, ossl_x509crl_copy); rb_define_copy_func(cX509CRL, ossl_x509crl_copy);
rb_define_method(cX509CRL, "version", ossl_x509crl_get_version, 0); rb_define_method(cX509CRL, "version", ossl_x509crl_get_version, 0);
rb_define_method(cX509CRL, "version=", ossl_x509crl_set_version, 1); rb_define_method(cX509CRL, "version=", ossl_x509crl_set_version, 1);
rb_define_method(cX509CRL, "signature_algorithm", ossl_x509crl_get_signature_algorithm, 0); rb_define_method(cX509CRL, "signature_algorithm", ossl_x509crl_get_signature_algorithm, 0);

View file

@ -49,7 +49,7 @@ VALUE eX509ExtError;
/* /*
* Public * Public
*/ */
VALUE VALUE
ossl_x509ext_new(X509_EXTENSION *ext) ossl_x509ext_new(X509_EXTENSION *ext)
{ {
X509_EXTENSION *new; X509_EXTENSION *new;
@ -103,7 +103,7 @@ ossl_x509extfactory_free(X509V3_CTX *ctx)
OPENSSL_free(ctx); OPENSSL_free(ctx);
} }
static VALUE static VALUE
ossl_x509extfactory_alloc(VALUE klass) ossl_x509extfactory_alloc(VALUE klass)
{ {
X509V3_CTX *ctx; X509V3_CTX *ctx;
@ -115,7 +115,7 @@ ossl_x509extfactory_alloc(VALUE klass)
return obj; return obj;
} }
static VALUE static VALUE
ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert) ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert)
{ {
X509V3_CTX *ctx; X509V3_CTX *ctx;
@ -127,7 +127,7 @@ ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert)
return cert; return cert;
} }
static VALUE static VALUE
ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert) ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert)
{ {
X509V3_CTX *ctx; X509V3_CTX *ctx;
@ -139,7 +139,7 @@ ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert)
return cert; return cert;
} }
static VALUE static VALUE
ossl_x509extfactory_set_subject_req(VALUE self, VALUE req) ossl_x509extfactory_set_subject_req(VALUE self, VALUE req)
{ {
X509V3_CTX *ctx; X509V3_CTX *ctx;
@ -151,7 +151,7 @@ ossl_x509extfactory_set_subject_req(VALUE self, VALUE req)
return req; return req;
} }
static VALUE static VALUE
ossl_x509extfactory_set_crl(VALUE self, VALUE crl) ossl_x509extfactory_set_crl(VALUE self, VALUE crl)
{ {
X509V3_CTX *ctx; X509V3_CTX *ctx;
@ -181,7 +181,7 @@ ossl_x509extfactory_set_config(VALUE self, VALUE config)
#define rb_f_fork rb_f_notimplement #define rb_f_fork rb_f_notimplement
#endif #endif
static VALUE static VALUE
ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self) ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self)
{ {
/*X509V3_CTX *ctx;*/ /*X509V3_CTX *ctx;*/
@ -211,7 +211,7 @@ ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self)
* ["ln", "critical,value"] or the same for sn * ["ln", "critical,value"] or the same for sn
* ["ln", "value"] => not critical * ["ln", "value"] => not critical
*/ */
static VALUE static VALUE
ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self) ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
{ {
X509V3_CTX *ctx; X509V3_CTX *ctx;
@ -351,7 +351,7 @@ ossl_x509ext_set_critical(VALUE self, VALUE flag)
return flag; return flag;
} }
static VALUE static VALUE
ossl_x509ext_get_oid(VALUE obj) ossl_x509ext_get_oid(VALUE obj)
{ {
X509_EXTENSION *ext; X509_EXTENSION *ext;
@ -427,7 +427,7 @@ void
Init_ossl_x509ext() Init_ossl_x509ext()
{ {
eX509ExtError = rb_define_class_under(mX509, "ExtensionError", eOSSLError); eX509ExtError = rb_define_class_under(mX509, "ExtensionError", eOSSLError);
cX509ExtFactory = rb_define_class_under(mX509, "ExtensionFactory", rb_cObject); cX509ExtFactory = rb_define_class_under(mX509, "ExtensionFactory", rb_cObject);
rb_define_alloc_func(cX509ExtFactory, ossl_x509extfactory_alloc); rb_define_alloc_func(cX509ExtFactory, ossl_x509extfactory_alloc);

View file

@ -41,7 +41,7 @@ VALUE eX509NameError;
/* /*
* Public * Public
*/ */
VALUE VALUE
ossl_x509name_new(X509_NAME *name) ossl_x509name_new(X509_NAME *name)
{ {
X509_NAME *new; X509_NAME *new;
@ -56,7 +56,7 @@ ossl_x509name_new(X509_NAME *name)
ossl_raise(eX509NameError, NULL); ossl_raise(eX509NameError, NULL);
} }
WrapX509Name(cX509Name, obj, new); WrapX509Name(cX509Name, obj, new);
return obj; return obj;
} }
@ -222,7 +222,7 @@ ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
* call-seq: * call-seq:
* name.to_a => [[name, data, type], ...] * name.to_a => [[name, data, type], ...]
*/ */
static VALUE static VALUE
ossl_x509name_to_a(VALUE self) ossl_x509name_to_a(VALUE self)
{ {
X509_NAME *name; X509_NAME *name;
@ -333,7 +333,7 @@ ossl_x509name_to_der(VALUE self)
/* /*
* INIT * INIT
*/ */
void void
Init_ossl_x509name() Init_ossl_x509name()
{ {
VALUE utf8str, ptrstr, ia5str, hash; VALUE utf8str, ptrstr, ia5str, hash;

View file

@ -81,7 +81,7 @@ DupX509ReqPtr(VALUE obj)
/* /*
* Private functions * Private functions
*/ */
static VALUE static VALUE
ossl_x509req_alloc(VALUE klass) ossl_x509req_alloc(VALUE klass)
{ {
X509_REQ *req; X509_REQ *req;
@ -95,7 +95,7 @@ ossl_x509req_alloc(VALUE klass)
return obj; return obj;
} }
static VALUE static VALUE
ossl_x509req_initialize(int argc, VALUE *argv, VALUE self) ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)
{ {
BIO *in; BIO *in;
@ -138,7 +138,7 @@ ossl_x509req_copy(VALUE self, VALUE other)
return self; return self;
} }
static VALUE static VALUE
ossl_x509req_to_pem(VALUE self) ossl_x509req_to_pem(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -181,7 +181,7 @@ ossl_x509req_to_der(VALUE self)
return str; return str;
} }
static VALUE static VALUE
ossl_x509req_to_text(VALUE self) ossl_x509req_to_text(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -208,7 +208,7 @@ ossl_x509req_to_text(VALUE self)
/* /*
* Makes X509 from X509_REQuest * Makes X509 from X509_REQuest
*/ */
static VALUE static VALUE
ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key) ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key)
{ {
X509_REQ *req; X509_REQ *req;
@ -224,7 +224,7 @@ ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key)
} }
#endif #endif
static VALUE static VALUE
ossl_x509req_get_version(VALUE self) ossl_x509req_get_version(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -236,7 +236,7 @@ ossl_x509req_get_version(VALUE self)
return LONG2FIX(version); return LONG2FIX(version);
} }
static VALUE static VALUE
ossl_x509req_set_version(VALUE self, VALUE version) ossl_x509req_set_version(VALUE self, VALUE version)
{ {
X509_REQ *req; X509_REQ *req;
@ -253,7 +253,7 @@ ossl_x509req_set_version(VALUE self, VALUE version)
return version; return version;
} }
static VALUE static VALUE
ossl_x509req_get_subject(VALUE self) ossl_x509req_get_subject(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -267,7 +267,7 @@ ossl_x509req_get_subject(VALUE self)
return ossl_x509name_new(name); return ossl_x509name_new(name);
} }
static VALUE static VALUE
ossl_x509req_set_subject(VALUE self, VALUE subject) ossl_x509req_set_subject(VALUE self, VALUE subject)
{ {
X509_REQ *req; X509_REQ *req;
@ -281,7 +281,7 @@ ossl_x509req_set_subject(VALUE self, VALUE subject)
return subject; return subject;
} }
static VALUE static VALUE
ossl_x509req_get_signature_algorithm(VALUE self) ossl_x509req_get_signature_algorithm(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -304,7 +304,7 @@ ossl_x509req_get_signature_algorithm(VALUE self)
return str; return str;
} }
static VALUE static VALUE
ossl_x509req_get_public_key(VALUE self) ossl_x509req_get_public_key(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -318,7 +318,7 @@ ossl_x509req_get_public_key(VALUE self)
return ossl_pkey_new(pkey); /* NO DUP - OK */ return ossl_pkey_new(pkey); /* NO DUP - OK */
} }
static VALUE static VALUE
ossl_x509req_set_public_key(VALUE self, VALUE key) ossl_x509req_set_public_key(VALUE self, VALUE key)
{ {
X509_REQ *req; X509_REQ *req;
@ -333,7 +333,7 @@ ossl_x509req_set_public_key(VALUE self, VALUE key)
return key; return key;
} }
static VALUE static VALUE
ossl_x509req_sign(VALUE self, VALUE key, VALUE digest) ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
{ {
X509_REQ *req; X509_REQ *req;
@ -353,7 +353,7 @@ ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
/* /*
* Checks that cert signature is made with PRIVversion of this PUBLIC 'key' * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
*/ */
static VALUE static VALUE
ossl_x509req_verify(VALUE self, VALUE key) ossl_x509req_verify(VALUE self, VALUE key)
{ {
X509_REQ *req; X509_REQ *req;
@ -372,7 +372,7 @@ ossl_x509req_verify(VALUE self, VALUE key)
return Qfalse; return Qfalse;
} }
static VALUE static VALUE
ossl_x509req_get_attributes(VALUE self) ossl_x509req_get_attributes(VALUE self)
{ {
X509_REQ *req; X509_REQ *req;
@ -396,7 +396,7 @@ ossl_x509req_get_attributes(VALUE self)
return ary; return ary;
} }
static VALUE static VALUE
ossl_x509req_set_attributes(VALUE self, VALUE ary) ossl_x509req_set_attributes(VALUE self, VALUE ary)
{ {
X509_REQ *req; X509_REQ *req;
@ -421,7 +421,7 @@ ossl_x509req_set_attributes(VALUE self, VALUE ary)
return ary; return ary;
} }
static VALUE static VALUE
ossl_x509req_add_attribute(VALUE self, VALUE attr) ossl_x509req_add_attribute(VALUE self, VALUE attr)
{ {
X509_REQ *req; X509_REQ *req;
@ -437,7 +437,7 @@ ossl_x509req_add_attribute(VALUE self, VALUE attr)
/* /*
* X509_REQUEST init * X509_REQUEST init
*/ */
void void
Init_ossl_x509req() Init_ossl_x509req()
{ {
eX509ReqError = rb_define_class_under(mX509, "RequestError", eOSSLError); eX509ReqError = rb_define_class_under(mX509, "RequestError", eOSSLError);

View file

@ -36,7 +36,7 @@ VALUE eX509RevError;
/* /*
* PUBLIC * PUBLIC
*/ */
VALUE VALUE
ossl_x509revoked_new(X509_REVOKED *rev) ossl_x509revoked_new(X509_REVOKED *rev)
{ {
X509_REVOKED *new; X509_REVOKED *new;
@ -71,7 +71,7 @@ DupX509RevokedPtr(VALUE obj)
/* /*
* PRIVATE * PRIVATE
*/ */
static VALUE static VALUE
ossl_x509revoked_alloc(VALUE klass) ossl_x509revoked_alloc(VALUE klass)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -85,14 +85,14 @@ ossl_x509revoked_alloc(VALUE klass)
return obj; return obj;
} }
static VALUE static VALUE
ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self) ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
{ {
/* EMPTY */ /* EMPTY */
return self; return self;
} }
static VALUE static VALUE
ossl_x509revoked_get_serial(VALUE self) ossl_x509revoked_get_serial(VALUE self)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -102,7 +102,7 @@ ossl_x509revoked_get_serial(VALUE self)
return asn1integer_to_num(rev->serialNumber); return asn1integer_to_num(rev->serialNumber);
} }
static VALUE static VALUE
ossl_x509revoked_set_serial(VALUE self, VALUE num) ossl_x509revoked_set_serial(VALUE self, VALUE num)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -113,7 +113,7 @@ ossl_x509revoked_set_serial(VALUE self, VALUE num)
return num; return num;
} }
static VALUE static VALUE
ossl_x509revoked_get_time(VALUE self) ossl_x509revoked_get_time(VALUE self)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -123,7 +123,7 @@ ossl_x509revoked_get_time(VALUE self)
return asn1time_to_time(rev->revocationDate); return asn1time_to_time(rev->revocationDate);
} }
static VALUE static VALUE
ossl_x509revoked_set_time(VALUE self, VALUE time) ossl_x509revoked_set_time(VALUE self, VALUE time)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -140,7 +140,7 @@ ossl_x509revoked_set_time(VALUE self, VALUE time)
/* /*
* Gets X509v3 extensions as array of X509Ext objects * Gets X509v3 extensions as array of X509Ext objects
*/ */
static VALUE static VALUE
ossl_x509revoked_get_extensions(VALUE self) ossl_x509revoked_get_extensions(VALUE self)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -166,7 +166,7 @@ ossl_x509revoked_get_extensions(VALUE self)
/* /*
* Sets X509_EXTENSIONs * Sets X509_EXTENSIONs
*/ */
static VALUE static VALUE
ossl_x509revoked_set_extensions(VALUE self, VALUE ary) ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
@ -196,7 +196,7 @@ static VALUE
ossl_x509revoked_add_extension(VALUE self, VALUE ext) ossl_x509revoked_add_extension(VALUE self, VALUE ext)
{ {
X509_REVOKED *rev; X509_REVOKED *rev;
GetX509Rev(self, rev); GetX509Rev(self, rev);
if(!X509_REVOKED_add_ext(rev, DupX509ExtPtr(ext), -1)) { if(!X509_REVOKED_add_ext(rev, DupX509ExtPtr(ext), -1)) {
ossl_raise(eX509RevError, NULL); ossl_raise(eX509RevError, NULL);

View file

@ -54,7 +54,7 @@ VALUE eX509StoreError;
/* /*
* Public functions * Public functions
*/ */
VALUE VALUE
ossl_x509store_new(X509_STORE *store) ossl_x509store_new(X509_STORE *store)
{ {
VALUE obj; VALUE obj;
@ -76,19 +76,19 @@ GetX509StorePtr(VALUE obj)
X509_STORE * X509_STORE *
DupX509StorePtr(VALUE obj) DupX509StorePtr(VALUE obj)
{ {
X509_STORE *store; X509_STORE *store;
SafeGetX509Store(obj, store); SafeGetX509Store(obj, store);
CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE); CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE);
return store; return store;
} }
/* /*
* Private functions * Private functions
*/ */
static VALUE static VALUE
ossl_x509store_alloc(VALUE klass) ossl_x509store_alloc(VALUE klass)
{ {
X509_STORE *store; X509_STORE *store;
@ -171,7 +171,7 @@ ossl_x509store_set_purpose(VALUE self, VALUE purpose)
#if (OPENSSL_VERSION_NUMBER >= 0x00907000L) #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
X509_STORE *store; X509_STORE *store;
long p = NUM2LONG(purpose); long p = NUM2LONG(purpose);
GetX509Store(self, store); GetX509Store(self, store);
X509_STORE_set_purpose(store, p); X509_STORE_set_purpose(store, p);
#else #else
@ -197,14 +197,14 @@ ossl_x509store_set_trust(VALUE self, VALUE trust)
return trust; return trust;
} }
static VALUE static VALUE
ossl_x509store_set_time(VALUE self, VALUE time) ossl_x509store_set_time(VALUE self, VALUE time)
{ {
rb_iv_set(self, "@time", time); rb_iv_set(self, "@time", time);
return time; return time;
} }
static VALUE static VALUE
ossl_x509store_add_file(VALUE self, VALUE file) ossl_x509store_add_file(VALUE self, VALUE file)
{ {
X509_STORE *store; X509_STORE *store;
@ -225,7 +225,7 @@ ossl_x509store_add_file(VALUE self, VALUE file)
return self; return self;
} }
static VALUE static VALUE
ossl_x509store_add_path(VALUE self, VALUE dir) ossl_x509store_add_path(VALUE self, VALUE dir)
{ {
X509_STORE *store; X509_STORE *store;
@ -293,7 +293,7 @@ static VALUE ossl_x509stctx_get_err(VALUE);
static VALUE ossl_x509stctx_get_err_string(VALUE); static VALUE ossl_x509stctx_get_err_string(VALUE);
static VALUE ossl_x509stctx_get_chain(VALUE); static VALUE ossl_x509stctx_get_chain(VALUE);
static VALUE static VALUE
ossl_x509store_verify(int argc, VALUE *argv, VALUE self) ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
{ {
VALUE cert, chain; VALUE cert, chain;
@ -350,7 +350,7 @@ ossl_x509stctx_free(X509_STORE_CTX *ctx)
X509_STORE_CTX_free(ctx); X509_STORE_CTX_free(ctx);
} }
static VALUE static VALUE
ossl_x509stctx_alloc(VALUE klass) ossl_x509stctx_alloc(VALUE klass)
{ {
X509_STORE_CTX *ctx; X509_STORE_CTX *ctx;
@ -442,7 +442,7 @@ ossl_x509stctx_get_chain(VALUE self)
return ary; return ary;
} }
static VALUE static VALUE
ossl_x509stctx_get_err(VALUE self) ossl_x509stctx_get_err(VALUE self)
{ {
X509_STORE_CTX *ctx; X509_STORE_CTX *ctx;
@ -463,7 +463,7 @@ ossl_x509stctx_set_error(VALUE self, VALUE err)
return err; return err;
} }
static VALUE static VALUE
ossl_x509stctx_get_err_string(VALUE self) ossl_x509stctx_get_err_string(VALUE self)
{ {
X509_STORE_CTX *ctx; X509_STORE_CTX *ctx;
@ -475,7 +475,7 @@ ossl_x509stctx_get_err_string(VALUE self)
return rb_str_new2(X509_verify_cert_error_string(err)); return rb_str_new2(X509_verify_cert_error_string(err));
} }
static VALUE static VALUE
ossl_x509stctx_get_err_depth(VALUE self) ossl_x509stctx_get_err_depth(VALUE self)
{ {
X509_STORE_CTX *ctx; X509_STORE_CTX *ctx;
@ -485,7 +485,7 @@ ossl_x509stctx_get_err_depth(VALUE self)
return INT2FIX(X509_STORE_CTX_get_error_depth(ctx)); return INT2FIX(X509_STORE_CTX_get_error_depth(ctx));
} }
static VALUE static VALUE
ossl_x509stctx_get_curr_cert(VALUE self) ossl_x509stctx_get_curr_cert(VALUE self)
{ {
X509_STORE_CTX *ctx; X509_STORE_CTX *ctx;
@ -577,7 +577,7 @@ ossl_x509stctx_set_time(VALUE self, VALUE time)
/* /*
* INIT * INIT
*/ */
void void
Init_ossl_x509store() Init_ossl_x509store()
{ {
VALUE x509stctx; VALUE x509stctx;

View file

@ -1,9 +1,9 @@
/* /*
cparse.c -- Racc Runtime Core cparse.c -- Racc Runtime Core
Copyright (c) 1999-2006 Minero Aoki Copyright (c) 1999-2006 Minero Aoki
This library is free software. This library is free software.
You can distribute/modify this program under the same terms of ruby. You can distribute/modify this program under the same terms of ruby.
@ -293,7 +293,7 @@ lexer_i(VALUE block_args, VALUE data, VALUE self)
extract_user_token(v, block_args, &tok, &val); extract_user_token(v, block_args, &tok, &val);
parse_main(v, tok, val, 1); parse_main(v, tok, val, 1);
if (v->fin && v->fin != CP_FIN_ACCEPT) if (v->fin && v->fin != CP_FIN_ACCEPT)
rb_iter_break(); rb_iter_break();
return Qnil; return Qnil;
} }
@ -460,7 +460,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
if (resume) if (resume)
goto resume; goto resume;
while (1) { while (1) {
D_puts(""); D_puts("");
D_puts("---- enter new loop ----"); D_puts("---- enter new loop ----");
@ -519,7 +519,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
act_fixed: act_fixed:
D_printf("act=%ld\n", act); D_printf("act=%ld\n", act);
goto handle_act; goto handle_act;
notfound: notfound:
D_puts("(act) not found: use default"); D_puts("(act) not found: use default");
act_value = AREF(v->action_default, v->curstate); act_value = AREF(v->action_default, v->curstate);
@ -620,7 +620,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
D_puts("(err) found: can handle error token"); D_puts("(err) found: can handle error token");
break; break;
error_pop: error_pop:
D_puts("(err) act not found: can't handle error token; pop"); D_puts("(err) act not found: can't handle error token; pop");

View file

@ -81,7 +81,7 @@ static char **readline_attempted_completion_function(const char *text,
* GNU Readline:: http://www.gnu.org/directory/readline.html * GNU Readline:: http://www.gnu.org/directory/readline.html
* libedit:: http://www.thrysoee.dk/editline/ * libedit:: http://www.thrysoee.dk/editline/
* *
* Reads one inputted line with line edit by Readline.readline method. * Reads one inputted line with line edit by Readline.readline method.
* At this time, the facilitatation completion and the key * At this time, the facilitatation completion and the key
* bind like Emacs can be operated like GNU Readline. * bind like Emacs can be operated like GNU Readline.
* *
@ -173,9 +173,9 @@ readline_get(VALUE prompt)
* *
* * Catches the Interrupt exception by pressed ^C after returns * * Catches the Interrupt exception by pressed ^C after returns
* terminal status: * terminal status:
* *
* require "readline" * require "readline"
* *
* stty_save = `stty -g`.chomp * stty_save = `stty -g`.chomp
* begin * begin
* while buf = Readline.readline * while buf = Readline.readline
@ -187,25 +187,25 @@ readline_get(VALUE prompt)
* end * end
* end * end
* end * end
* *
* * Catches the INT signal by pressed ^C after returns terminal * * Catches the INT signal by pressed ^C after returns terminal
* status: * status:
* *
* require "readline" * require "readline"
* *
* stty_save = `stty -g`.chomp * stty_save = `stty -g`.chomp
* trap("INT") { system "stty", stty_save; exit } * trap("INT") { system "stty", stty_save; exit }
* *
* while buf = Readline.readline * while buf = Readline.readline
* p buf * p buf
* end * end
* *
* * Ignores pressing ^C: * * Ignores pressing ^C:
* *
* require "readline" * require "readline"
* *
* trap("INT", "SIG_IGN") * trap("INT", "SIG_IGN")
* *
* while buf = Readline.readline * while buf = Readline.readline
* p buf * p buf
* end * end
@ -215,18 +215,18 @@ readline_get(VALUE prompt)
* the same it as last one. * the same it as last one.
* *
* require "readline" * require "readline"
* *
* while buf = Readline.readline("> ", true) * while buf = Readline.readline("> ", true)
* # p Readline::HISTORY.to_a * # p Readline::HISTORY.to_a
* Readline::HISTORY.pop if /^\s*$/ =~ buf * Readline::HISTORY.pop if /^\s*$/ =~ buf
* *
* begin * begin
* if Readline::HISTORY[Readline::HISTORY.length-2] == buf * if Readline::HISTORY[Readline::HISTORY.length-2] == buf
* Readline::HISTORY.pop * Readline::HISTORY.pop
* end * end
* rescue IndexError * rescue IndexError
* end * end
* *
* # p Readline::HISTORY.to_a * # p Readline::HISTORY.to_a
* print "-> ", buf, "\n" * print "-> ", buf, "\n"
* end * end
@ -389,7 +389,7 @@ readline_s_set_completion_case_fold(VALUE self, VALUE val)
* Readline.completion_case_fold= method. * Readline.completion_case_fold= method.
* *
* require "readline" * require "readline"
* *
* Readline.completion_case_fold = "This is a String." * Readline.completion_case_fold = "This is a String."
* p Readline.completion_case_fold # => "This is a String." * p Readline.completion_case_fold # => "This is a String."
* *
@ -521,7 +521,7 @@ readline_attempted_completion_function(const char *text, int start, int end)
* *
* Set terminal size to +rows+ and +columns+. * Set terminal size to +rows+ and +columns+.
* *
* See GNU Readline's rl_set_screen_size function. * See GNU Readline's rl_set_screen_size function.
* *
* Raises NotImplementedError if the using readline library does not support. * Raises NotImplementedError if the using readline library does not support.
* *
@ -545,7 +545,7 @@ readline_s_set_screen_size(VALUE self, VALUE rows, VALUE columns)
* *
* Returns the terminal's rows and columns. * Returns the terminal's rows and columns.
* *
* See GNU Readline's rl_get_screen_size function. * See GNU Readline's rl_get_screen_size function.
* *
* Raises NotImplementedError if the using readline library does not support. * Raises NotImplementedError if the using readline library does not support.
* *
@ -556,7 +556,7 @@ readline_s_get_screen_size(VALUE self)
{ {
int rows, columns; int rows, columns;
VALUE res; VALUE res;
rb_secure(4); rb_secure(4);
rl_get_screen_size(&rows, &columns); rl_get_screen_size(&rows, &columns);
res = rb_ary_new(); res = rb_ary_new();
@ -667,20 +667,20 @@ readline_s_emacs_editing_mode_p(VALUE self)
* *
* For example: * For example:
* require "readline" * require "readline"
* *
* Readline.readline("> ", true) * Readline.readline("> ", true)
* Readline.completion_append_character = " " * Readline.completion_append_character = " "
* *
* Result: * Result:
* > * >
* Input "/var/li". * Input "/var/li".
* *
* > /var/li * > /var/li
* Press TAB key. * Press TAB key.
* *
* > /var/lib * > /var/lib
* Completes "b" and appends " ". So, you can continuously input "/usr". * Completes "b" and appends " ". So, you can continuously input "/usr".
* *
* > /var/lib /usr * > /var/lib /usr
* *
* NOTE: Only one character can be specified. When "string" is * NOTE: Only one character can be specified. When "string" is
@ -788,7 +788,7 @@ readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
* *
* Gets the basic list of characters that signal a break between words * Gets the basic list of characters that signal a break between words
* for the completer routine. * for the completer routine.
* *
* Raises NotImplementedError if the using readline library does not support. * Raises NotImplementedError if the using readline library does not support.
* *
* Raises SecurityError exception if $SAFE is 4. * Raises SecurityError exception if $SAFE is 4.
@ -849,7 +849,7 @@ readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
* *
* Gets the basic list of characters that signal a break between words * Gets the basic list of characters that signal a break between words
* for rl_complete_internal(). * for rl_complete_internal().
* *
* Raises NotImplementedError if the using readline library does not support. * Raises NotImplementedError if the using readline library does not support.
* *
* Raises SecurityError exception if $SAFE is 4. * Raises SecurityError exception if $SAFE is 4.
@ -1143,7 +1143,7 @@ static VALUE
hist_push_method(int argc, VALUE *argv, VALUE self) hist_push_method(int argc, VALUE *argv, VALUE self)
{ {
VALUE str; VALUE str;
rb_secure(4); rb_secure(4);
while (argc--) { while (argc--) {
str = *argv++; str = *argv++;
@ -1422,7 +1422,7 @@ Init_readline()
#if defined HAVE_RL_LIBRARY_VERSION #if defined HAVE_RL_LIBRARY_VERSION
version = rb_str_new_cstr(rl_library_version); version = rb_str_new_cstr(rl_library_version);
#if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY #if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY
if (strncmp(rl_library_version, EDIT_LINE_LIBRARY_VERSION, if (strncmp(rl_library_version, EDIT_LINE_LIBRARY_VERSION,
strlen(EDIT_LINE_LIBRARY_VERSION)) == 0) { strlen(EDIT_LINE_LIBRARY_VERSION)) == 0) {
add_history("1"); add_history("1");
if (history_get(history_get_offset_func(0)) == NULL) { if (history_get(history_get_offset_func(0)) == NULL) {

View file

@ -186,7 +186,7 @@ sdbm_prep(char *dirname, char *pagname, int flags, int mode)
db->blkptr = 0; db->blkptr = 0;
db->keyptr = 0; db->keyptr = 0;
/* /*
* adjust user flags so that WRONLY becomes RDWR, * adjust user flags so that WRONLY becomes RDWR,
* as required by this package. Also set our internal * as required by this package. Also set our internal
* flag for RDONLY. * flag for RDONLY.
*/ */
@ -407,7 +407,7 @@ makroom(register DBM *db, long int hash, int need)
* need to read in anything. BUT we have to write the current * need to read in anything. BUT we have to write the current
* [deferred] page out, as the window of failure is too great. * [deferred] page out, as the window of failure is too great.
*/ */
db->curbit = 2 * db->curbit + db->curbit = 2 * db->curbit +
((hash & (db->hmask + 1)) ? 2 : 1); ((hash & (db->hmask + 1)) ? 2 : 1);
db->hmask |= (db->hmask + 1); db->hmask |= (db->hmask + 1);
@ -483,7 +483,7 @@ getpage(register DBM *db, register long int hash)
* see if the block we need is already in memory. * see if the block we need is already in memory.
* note: this lookaside cache has about 10% hit rate. * note: this lookaside cache has about 10% hit rate.
*/ */
if (pagb != db->pagbno) { if (pagb != db->pagbno) {
/* /*
* note: here, we assume a "hole" is read as 0s. * note: here, we assume a "hole" is read as 0s.
* if not, must zero pagbuf first. * if not, must zero pagbuf first.
@ -608,8 +608,8 @@ getnext(register DBM *db)
#define exhash(item) sdbm_hash((item).dptr, (item).dsize) #define exhash(item) sdbm_hash((item).dptr, (item).dsize)
/* /*
* forward * forward
*/ */
static int seepair proto((char *, int, char *, int)); static int seepair proto((char *, int, char *, int));
@ -829,7 +829,7 @@ splpage(char *pag, char *new, long int sbit)
n = GET_SHORT(ino,0); n = GET_SHORT(ino,0);
for (ino++; n > 0; ino += 2) { for (ino++; n > 0; ino += 2) {
key.dptr = cur + GET_SHORT(ino,0); key.dptr = cur + GET_SHORT(ino,0);
key.dsize = off - GET_SHORT(ino,0); key.dsize = off - GET_SHORT(ino,0);
val.dptr = cur + GET_SHORT(ino,1); val.dptr = cur + GET_SHORT(ino,1);
val.dsize = GET_SHORT(ino,0) - GET_SHORT(ino,1); val.dsize = GET_SHORT(ino,0) - GET_SHORT(ino,1);
@ -842,13 +842,13 @@ splpage(char *pag, char *new, long int sbit)
n -= 2; n -= 2;
} }
debug(("%d split %d/%d\n", ((short *) cur)[0] / 2, debug(("%d split %d/%d\n", ((short *) cur)[0] / 2,
((short *) new)[0] / 2, ((short *) new)[0] / 2,
((short *) pag)[0] / 2)); ((short *) pag)[0] / 2));
} }
/* /*
* check page sanity: * check page sanity:
* number of entries should be something * number of entries should be something
* reasonable, and all offsets in the index should be in order. * reasonable, and all offsets in the index should be in order.
* this could be made more rigorous. * this could be made more rigorous.
@ -891,7 +891,7 @@ chkpage(char *pag)
* [this seems to work remarkably well, in fact better * [this seems to work remarkably well, in fact better
* then the ndbm hash function. Replace at your own risk] * then the ndbm hash function. Replace at your own risk]
* use: 65599 nice. * use: 65599 nice.
* 65587 even better. * 65587 even better.
*/ */
long long
sdbm_hash(register char *str, register int len) sdbm_hash(register char *str, register int len)

View file

@ -293,7 +293,7 @@ fsdbm_shift(VALUE obj)
fdbm_modify(obj); fdbm_modify(obj);
GetDBM2(obj, dbmp, dbm); GetDBM2(obj, dbmp, dbm);
key = sdbm_firstkey(dbm); key = sdbm_firstkey(dbm);
if (!key.dptr) return Qnil; if (!key.dptr) return Qnil;
val = sdbm_fetch(dbm, key); val = sdbm_fetch(dbm, key);
keystr = rb_external_str_new(key.dptr, key.dsize); keystr = rb_external_str_new(key.dptr, key.dsize);

View file

@ -2,7 +2,7 @@
* sdbm - ndbm work-alike hashed database library * sdbm - ndbm work-alike hashed database library
* based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978). * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
* author: oz@nexus.yorku.ca * author: oz@nexus.yorku.ca
* status: public domain. * status: public domain.
*/ */
#ifndef _SDBM_H_ #ifndef _SDBM_H_
#define _SDBM_H_ #define _SDBM_H_

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project nor the names of its contributors * 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -65,7 +65,7 @@ ip_cmsg_type_to_sym(int level, int cmsg_type)
* p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "") * p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "")
* #=> #<Socket::AncillaryData: INET TCP NODELAY ""> * #=> #<Socket::AncillaryData: INET TCP NODELAY "">
* *
* p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "")
* #=> #<Socket::AncillaryData: INET6 IPV6 PKTINFO ""> * #=> #<Socket::AncillaryData: INET6 IPV6 PKTINFO "">
* *
*/ */
@ -228,7 +228,7 @@ ancillary_s_unix_rights(int argc, VALUE *argv, VALUE klass)
* *
* returns the array of IO objects for SCM_RIGHTS control message in UNIX domain socket. * returns the array of IO objects for SCM_RIGHTS control message in UNIX domain socket.
* *
* The class of the IO objects in the array is IO or Socket. * The class of the IO objects in the array is IO or Socket.
* *
* The array is attached to _ancillarydata_ when it is instantiated. * The array is attached to _ancillarydata_ when it is instantiated.
* For example, BasicSocket#recvmsg attach the array when * For example, BasicSocket#recvmsg attach the array when
@ -356,7 +356,7 @@ ancillary_timestamp(VALUE self)
* *
* Creates a new Socket::AncillaryData object which contains a int as data. * Creates a new Socket::AncillaryData object which contains a int as data.
* *
* The size and endian is dependent on the host. * The size and endian is dependent on the host.
* *
* p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) * p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno)
* #=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 2> * #=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 2>
@ -377,7 +377,7 @@ ancillary_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE int
* *
* Returns the data in _ancillarydata_ as an int. * Returns the data in _ancillarydata_ as an int.
* *
* The size and endian is dependent on the host. * The size and endian is dependent on the host.
* *
* ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno) * ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno)
* p ancdata.int #=> 2 * p ancdata.int #=> 2
@ -592,7 +592,7 @@ extract_ipv6_pktinfo(VALUE self, struct in6_pktinfo *pktinfo_ptr, struct sockadd
* *
* IPV6_PKTINFO is defined by RFC 3542. * IPV6_PKTINFO is defined by RFC 3542.
* *
* addr = Addrinfo.ip("::1") * addr = Addrinfo.ip("::1")
* ifindex = 0 * ifindex = 0
* ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) * ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex)
* p ancdata.ipv6_pktinfo #=> [#<Addrinfo: ::1>, 0] * p ancdata.ipv6_pktinfo #=> [#<Addrinfo: ::1>, 0]
@ -778,7 +778,7 @@ anc_inspect_ip_recvdstaddr(int level, int type, VALUE data, VALUE ret)
{ {
if (level == IPPROTO_IP && type == IP_RECVDSTADDR && if (level == IPPROTO_IP && type == IP_RECVDSTADDR &&
RSTRING_LEN(data) == sizeof(struct in_addr)) { RSTRING_LEN(data) == sizeof(struct in_addr)) {
struct in_addr addr; struct in_addr addr;
char addrbuf[INET_ADDRSTRLEN]; char addrbuf[INET_ADDRSTRLEN];
memcpy(&addr, RSTRING_PTR(data), sizeof(addr)); memcpy(&addr, RSTRING_PTR(data), sizeof(addr));
if (inet_ntop(AF_INET, &addr, addrbuf, sizeof(addrbuf)) == NULL) if (inet_ntop(AF_INET, &addr, addrbuf, sizeof(addrbuf)) == NULL)
@ -829,7 +829,7 @@ anc_inspect_ipv6_pktinfo(int level, int type, VALUE data, VALUE ret)
if (level == IPPROTO_IPV6 && type == IPV6_PKTINFO && if (level == IPPROTO_IPV6 && type == IPV6_PKTINFO &&
RSTRING_LEN(data) == sizeof(struct in6_pktinfo)) { RSTRING_LEN(data) == sizeof(struct in6_pktinfo)) {
struct in6_pktinfo *pktinfo = (struct in6_pktinfo *)RSTRING_PTR(data); struct in6_pktinfo *pktinfo = (struct in6_pktinfo *)RSTRING_PTR(data);
struct in6_addr addr; struct in6_addr addr;
unsigned int ifindex; unsigned int ifindex;
char addrbuf[INET6_ADDRSTRLEN], ifbuf[IFNAMSIZ]; char addrbuf[INET6_ADDRSTRLEN], ifbuf[IFNAMSIZ];
memcpy(&addr, &pktinfo->ipi6_addr, sizeof(addr)); memcpy(&addr, &pktinfo->ipi6_addr, sizeof(addr));
@ -1033,7 +1033,7 @@ ancillary_inspect(VALUE self)
# endif # endif
} }
break; break;
case AF_INET: case AF_INET:
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
@ -1211,18 +1211,18 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
if (last_pad) { if (last_pad) {
/* /*
* This code removes the last padding from msg_controllen. * This code removes the last padding from msg_controllen.
* *
* 4.3BSD-Reno reject the padding for SCM_RIGHTS. (There was no 64bit environments in those days?) * 4.3BSD-Reno reject the padding for SCM_RIGHTS. (There was no 64bit environments in those days?)
* RFC 2292 require the padding. * RFC 2292 require the padding.
* RFC 3542 relaxes the condition - implementation must accept both as valid. * RFC 3542 relaxes the condition - implementation must accept both as valid.
* *
* Actual problems: * Actual problems:
* *
* - NetBSD 4.0.1 * - NetBSD 4.0.1
* SCM_RIGHTS with padding causes EINVAL * SCM_RIGHTS with padding causes EINVAL
* IPV6_PKTINFO without padding causes "page fault trap" * IPV6_PKTINFO without padding causes "page fault trap"
* http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=40661 * http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=40661
* *
* - OpenBSD 4.4 * - OpenBSD 4.4
* IPV6_PKTINFO without padding causes EINVAL * IPV6_PKTINFO without padding causes EINVAL
* *
@ -1317,7 +1317,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
* sendmsg can be used to implement send_io as follows: * sendmsg can be used to implement send_io as follows:
* *
* # use Socket::AncillaryData. * # use Socket::AncillaryData.
* ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, io.fileno) * ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, io.fileno)
* sock.sendmsg("a", 0, nil, ancdata) * sock.sendmsg("a", 0, nil, ancdata)
* *
* # use 3-element array. * # use 3-element array.

View file

@ -57,7 +57,7 @@ bsock_s_for_fd(VALUE klass, VALUE fd)
* s2.close * s2.close
* p s1.read #=> "pong\n" * p s1.read #=> "pong\n"
* } * }
* *
*/ */
static VALUE static VALUE
bsock_shutdown(int argc, VALUE *argv, VALUE sock) bsock_shutdown(int argc, VALUE *argv, VALUE sock)
@ -179,15 +179,15 @@ bsock_close_write(VALUE sock)
* *
* Some socket options are integers with boolean values, in this case * Some socket options are integers with boolean values, in this case
* #setsockopt could be called like this: * #setsockopt could be called like this:
* sock.setsockopt(:SOCKET, :REUSEADDR, true) * sock.setsockopt(:SOCKET, :REUSEADDR, true)
* sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true) * sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
* sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true)) * sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true))
* *
* Some socket options are integers with numeric values, in this case * Some socket options are integers with numeric values, in this case
* #setsockopt could be called like this: * #setsockopt could be called like this:
* sock.setsockopt(:IP, :TTL, 255) * sock.setsockopt(:IP, :TTL, 255)
* sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255) * sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255)
* sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255)) * sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255))
* *
* Option values may be structs. Passing them can be complex as it involves * Option values may be structs. Passing them can be complex as it involves
* examining your system headers to determine the correct definition. An * examining your system headers to determine the correct definition. An
@ -196,7 +196,7 @@ bsock_close_write(VALUE sock)
* struct in_addr imr_multiaddr; * struct in_addr imr_multiaddr;
* struct in_addr imr_interface; * struct in_addr imr_interface;
* }; * };
* *
* In this case #setsockopt could be called like this: * In this case #setsockopt could be called like this:
* optval = IPAddr.new("224.0.0.251").hton + * optval = IPAddr.new("224.0.0.251").hton +
* IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton * IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton
@ -303,7 +303,7 @@ bsock_setsockopt(int argc, VALUE *argv, VALUE sock)
* int l_onoff; * int l_onoff;
* int l_linger; * int l_linger;
* }; * };
* *
* In this case #getsockopt could be called like this: * In this case #getsockopt could be called like this:
* *
* # Socket::Option knows linger structure. * # Socket::Option knows linger structure.
@ -647,7 +647,7 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
* call-seq: * call-seq:
* basicsocket.recv_nonblock(maxlen) => mesg * basicsocket.recv_nonblock(maxlen) => mesg
* basicsocket.recv_nonblock(maxlen, flags) => mesg * basicsocket.recv_nonblock(maxlen, flags) => mesg
* *
* Receives up to _maxlen_ bytes from +socket+ using recvfrom(2) after * Receives up to _maxlen_ bytes from +socket+ using recvfrom(2) after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* _flags_ is zero or more of the +MSG_+ options. * _flags_ is zero or more of the +MSG_+ options.
@ -656,11 +656,11 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
* When recvfrom(2) returns 0, Socket#recv_nonblock returns * When recvfrom(2) returns 0, Socket#recv_nonblock returns
* an empty string as data. * an empty string as data.
* The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc. * The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
* *
* === Parameters * === Parameters
* * +maxlen+ - the number of bytes to receive from the socket * * +maxlen+ - the number of bytes to receive from the socket
* * +flags+ - zero or more of the +MSG_+ options * * +flags+ - zero or more of the +MSG_+ options
* *
* === Example * === Example
* serv = TCPServer.new("127.0.0.1", 0) * serv = TCPServer.new("127.0.0.1", 0)
* af, port, host, addr = serv.addr * af, port, host, addr = serv.addr
@ -675,7 +675,7 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
* end * end
* *
* Refer to Socket#recvfrom for the exceptions that may be thrown if the call * Refer to Socket#recvfrom for the exceptions that may be thrown if the call
* to _recv_nonblock_ fails. * to _recv_nonblock_ fails.
* *
* BasicSocket#recv_nonblock may raise any error corresponding to recvfrom(2) failure, * BasicSocket#recv_nonblock may raise any error corresponding to recvfrom(2) failure,
* including Errno::EWOULDBLOCK. * including Errno::EWOULDBLOCK.

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project nor the names of its contributors * 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -45,7 +45,7 @@
#include <sys/types.h> #include <sys/types.h>
#ifndef _WIN32 #ifndef _WIN32
#include <sys/param.h> #include <sys/param.h>
#if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE) #if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
# include <net/socket.h> # include <net/socket.h>
#else #else
# include <sys/socket.h> # include <sys/socket.h>
@ -97,7 +97,7 @@ static const char in_addrany[] = { 0, 0, 0, 0 };
static const char in6_addrany[] = { static const char in6_addrany[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
static const char in_loopback[] = { 127, 0, 0, 1 }; static const char in_loopback[] = { 127, 0, 0, 1 };
static const char in6_loopback[] = { static const char in6_loopback[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
}; };
@ -502,7 +502,7 @@ getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *h
*/ */
get_name(pton, &afdl[i], &top, pton, pai, port); get_name(pton, &afdl[i], &top, pton, pai, port);
goto good; goto good;
} else } else
ERR(EAI_FAMILY); /*xxx*/ ERR(EAI_FAMILY); /*xxx*/
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project nor the names of its contributors * 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -159,10 +159,10 @@ rsock_revlookup_flag(VALUE revlookup, int *norevlookup)
/* /*
* call-seq: * call-seq:
* ipsocket.addr([reverse_lookup]) => [address_family, port, hostname, numeric_address] * ipsocket.addr([reverse_lookup]) => [address_family, port, hostname, numeric_address]
* *
* Returns the local address as an array which contains * Returns the local address as an array which contains
* address_family, port, hostname and numeric_address. * address_family, port, hostname and numeric_address.
* *
* If +reverse_lookup+ is +true+ or +:hostname+, * If +reverse_lookup+ is +true+ or +:hostname+,
* hostname is obtained from numeric_address using reverse lookup. * hostname is obtained from numeric_address using reverse lookup.
@ -199,10 +199,10 @@ ip_addr(int argc, VALUE *argv, VALUE sock)
/* /*
* call-seq: * call-seq:
* ipsocket.peeraddr([reverse_lookup]) => [address_family, port, hostname, numeric_address] * ipsocket.peeraddr([reverse_lookup]) => [address_family, port, hostname, numeric_address]
* *
* Returns the remote address as an array which contains * Returns the remote address as an array which contains
* address_family, port, hostname and numeric_address. * address_family, port, hostname and numeric_address.
* It is defined for connection oriented socket such as TCPSocket. * It is defined for connection oriented socket such as TCPSocket.
* *
* If +reverse_lookup+ is +true+ or +:hostname+, * If +reverse_lookup+ is +true+ or +:hostname+,
@ -257,7 +257,7 @@ ip_peeraddr(int argc, VALUE *argv, VALUE sock)
* u2 = UDPSocket.new * u2 = UDPSocket.new
* u2.send "uuuu", 0, "127.0.0.1", 4913 * u2.send "uuuu", 0, "127.0.0.1", 4913
* p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]] * p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]]
* *
*/ */
static VALUE static VALUE
ip_recvfrom(int argc, VALUE *argv, VALUE sock) ip_recvfrom(int argc, VALUE *argv, VALUE sock)

View file

@ -148,7 +148,7 @@ sockopt_data(VALUE self)
* *
* Creates a new Socket::Option object which contains an int as data. * Creates a new Socket::Option object which contains an int as data.
* *
* The size and endian is dependent on the platform. * The size and endian is dependent on the platform.
* *
* p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) * p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
* #=> #<Socket::Option: INET SOCKET KEEPALIVE 1> * #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
@ -169,7 +169,7 @@ sockopt_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vi
* *
* Returns the data in _sockopt_ as an int. * Returns the data in _sockopt_ as an int.
* *
* The size and endian is dependent on the platform. * The size and endian is dependent on the platform.
* *
* sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1) * sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
* p sockopt.int => 1 * p sockopt.int => 1
@ -280,7 +280,7 @@ sockopt_linger(VALUE self)
VALUE vonoff, vsecs; VALUE vonoff, vsecs;
if (level != SOL_SOCKET || optname != SO_LINGER) if (level != SOL_SOCKET || optname != SO_LINGER)
rb_raise(rb_eTypeError, "linger socket option expected"); rb_raise(rb_eTypeError, "linger socket option expected");
if (RSTRING_LEN(data) != sizeof(l)) if (RSTRING_LEN(data) != sizeof(l))
rb_raise(rb_eTypeError, "size differ. expected as sizeof(struct linger)=%d but %ld", rb_raise(rb_eTypeError, "size differ. expected as sizeof(struct linger)=%d but %ld",
(int)sizeof(struct linger), (long)RSTRING_LEN(data)); (int)sizeof(struct linger), (long)RSTRING_LEN(data));

View file

@ -743,7 +743,7 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
un.sun_family = AF_UNIX; un.sun_family = AF_UNIX;
memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path)); memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
init_addrinfo(rai, (struct sockaddr *)&un, sizeof(un), PF_UNIX, socktype, 0, Qnil, Qnil); init_addrinfo(rai, (struct sockaddr *)&un, sizeof(un), PF_UNIX, socktype, 0, Qnil, Qnil);
} }
#endif #endif
@ -766,9 +766,9 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
* Socket.sockaddr_in or Socket.unpack_sockaddr_un. * Socket.sockaddr_in or Socket.unpack_sockaddr_un.
* *
* sockaddr examples: * sockaddr examples:
* - ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] * - ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"]
* - ["AF_INET6", 42304, "ip6-localhost", "::1"] * - ["AF_INET6", 42304, "ip6-localhost", "::1"]
* - ["AF_UNIX", "/tmp/sock"] * - ["AF_UNIX", "/tmp/sock"]
* - Socket.sockaddr_in("smtp", "2001:DB8::1") * - Socket.sockaddr_in("smtp", "2001:DB8::1")
* - Socket.sockaddr_in(80, "172.18.22.42") * - Socket.sockaddr_in(80, "172.18.22.42")
* - Socket.sockaddr_in(80, "www.ruby-lang.org") * - Socket.sockaddr_in(80, "www.ruby-lang.org")
@ -1374,7 +1374,7 @@ addrinfo_protocol(VALUE self)
* *
* returns the socket address as packed struct sockaddr string. * returns the socket address as packed struct sockaddr string.
* *
* Addrinfo.tcp("localhost", 80).to_sockaddr * Addrinfo.tcp("localhost", 80).to_sockaddr
* #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" * #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
* *
*/ */
@ -1928,11 +1928,11 @@ addrinfo_unix_path(VALUE self)
* nodename or service can be nil if no conversion intended. * nodename or service can be nil if no conversion intended.
* *
* family, socktype and protocol are hint for preferred protocol. * family, socktype and protocol are hint for preferred protocol.
* If the result will be used for a socket with SOCK_STREAM, * If the result will be used for a socket with SOCK_STREAM,
* SOCK_STREAM should be specified as socktype. * SOCK_STREAM should be specified as socktype.
* If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM. * If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM.
* If they are omitted or nil is given, the result is not restricted. * If they are omitted or nil is given, the result is not restricted.
* *
* Similarly, PF_INET6 as family restricts for IPv6. * Similarly, PF_INET6 as family restricts for IPv6.
* *
* flags should be bitwise OR of Socket::AI_??? constants. * flags should be bitwise OR of Socket::AI_??? constants.

View file

@ -135,13 +135,13 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* socket.connect(remote_sockaddr) => 0 * socket.connect(remote_sockaddr) => 0
* *
* Requests a connection to be made on the given +remote_sockaddr+. Returns 0 if * Requests a connection to be made on the given +remote_sockaddr+. Returns 0 if
* successful, otherwise an exception is raised. * successful, otherwise an exception is raised.
* *
* === Parameter * === Parameter
* * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object * * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
* *
* === Example: * === Example:
* # Pull down Google's web page * # Pull down Google's web page
* require 'socket' * require 'socket'
@ -150,17 +150,17 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
* sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' ) * sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' )
* socket.connect( sockaddr ) * socket.connect( sockaddr )
* socket.write( "GET / HTTP/1.0\r\n\r\n" ) * socket.write( "GET / HTTP/1.0\r\n\r\n" )
* results = socket.read * results = socket.read
* *
* === Unix-based Exceptions * === Unix-based Exceptions
* On unix-based systems the following system exceptions may be raised if * On unix-based systems the following system exceptions may be raised if
* the call to _connect_ fails: * the call to _connect_ fails:
* * Errno::EACCES - search permission is denied for a component of the prefix * * Errno::EACCES - search permission is denied for a component of the prefix
* path or write access to the +socket+ is denied * path or write access to the +socket+ is denied
* * Errno::EADDRINUSE - the _sockaddr_ is already in use * * Errno::EADDRINUSE - the _sockaddr_ is already in use
* * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the * * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the
* local machine * local machine
* * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for * * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for
* the address family of the specified +socket+ * the address family of the specified +socket+
* * Errno::EALREADY - a connection is already in progress for the specified * * Errno::EALREADY - a connection is already in progress for the specified
* socket * socket
@ -169,7 +169,7 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
* refused the connection request * refused the connection request
* * Errno::ECONNRESET - the remote host reset the connection request * * Errno::ECONNRESET - the remote host reset the connection request
* * Errno::EFAULT - the _sockaddr_ cannot be accessed * * Errno::EFAULT - the _sockaddr_ cannot be accessed
* * Errno::EHOSTUNREACH - the destination host cannot be reached (probably * * Errno::EHOSTUNREACH - the destination host cannot be reached (probably
* because the host is down or a remote router cannot reach it) * because the host is down or a remote router cannot reach it)
* * Errno::EINPROGRESS - the O_NONBLOCK is set for the +socket+ and the * * Errno::EINPROGRESS - the O_NONBLOCK is set for the +socket+ and the
* connection cannot be immediately established; the connection will be * connection cannot be immediately established; the connection will be
@ -179,46 +179,46 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
* asynchronously * asynchronously
* * Errno::EISCONN - the specified +socket+ is already connected * * Errno::EISCONN - the specified +socket+ is already connected
* * Errno::EINVAL - the address length used for the _sockaddr_ is not a valid * * Errno::EINVAL - the address length used for the _sockaddr_ is not a valid
* length for the address family or there is an invalid family in _sockaddr_ * length for the address family or there is an invalid family in _sockaddr_
* * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded * * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded
* PATH_MAX * PATH_MAX
* * Errno::ENETDOWN - the local interface used to reach the destination is down * * Errno::ENETDOWN - the local interface used to reach the destination is down
* * Errno::ENETUNREACH - no route to the network is present * * Errno::ENETUNREACH - no route to the network is present
* * Errno::ENOBUFS - no buffer space is available * * Errno::ENOBUFS - no buffer space is available
* * Errno::ENOSR - there were insufficient STREAMS resources available to * * Errno::ENOSR - there were insufficient STREAMS resources available to
* complete the operation * complete the operation
* * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket
* * Errno::EOPNOTSUPP - the calling +socket+ is listening and cannot be connected * * Errno::EOPNOTSUPP - the calling +socket+ is listening and cannot be connected
* * Errno::EPROTOTYPE - the _sockaddr_ has a different type than the socket * * Errno::EPROTOTYPE - the _sockaddr_ has a different type than the socket
* bound to the specified peer address * bound to the specified peer address
* * Errno::ETIMEDOUT - the attempt to connect time out before a connection * * Errno::ETIMEDOUT - the attempt to connect time out before a connection
* was made. * was made.
* *
* On unix-based systems if the address family of the calling +socket+ is * On unix-based systems if the address family of the calling +socket+ is
* AF_UNIX the follow exceptions may be raised if the call to _connect_ * AF_UNIX the follow exceptions may be raised if the call to _connect_
* fails: * fails:
* * Errno::EIO - an i/o error occurred while reading from or writing to the * * Errno::EIO - an i/o error occurred while reading from or writing to the
* file system * file system
* * Errno::ELOOP - too many symbolic links were encountered in translating * * Errno::ELOOP - too many symbolic links were encountered in translating
* the pathname in _sockaddr_ * the pathname in _sockaddr_
* * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX * * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX
* characters, or an entire pathname exceeded PATH_MAX characters * characters, or an entire pathname exceeded PATH_MAX characters
* * Errno::ENOENT - a component of the pathname does not name an existing file * * Errno::ENOENT - a component of the pathname does not name an existing file
* or the pathname is an empty string * or the pathname is an empty string
* * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ * * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_
* is not a directory * is not a directory
* *
* === Windows Exceptions * === Windows Exceptions
* On Windows systems the following system exceptions may be raised if * On Windows systems the following system exceptions may be raised if
* the call to _connect_ fails: * the call to _connect_ fails:
* * Errno::ENETDOWN - the network is down * * Errno::ENETDOWN - the network is down
* * Errno::EADDRINUSE - the socket's local address is already in use * * Errno::EADDRINUSE - the socket's local address is already in use
* * Errno::EINTR - the socket was cancelled * * Errno::EINTR - the socket was cancelled
* * Errno::EINPROGRESS - a blocking socket is in progress or the service provider * * Errno::EINPROGRESS - a blocking socket is in progress or the service provider
* is still processing a callback function. Or a nonblocking connect call is * is still processing a callback function. Or a nonblocking connect call is
* in progress on the +socket+. * in progress on the +socket+.
* * Errno::EALREADY - see Errno::EINVAL * * Errno::EALREADY - see Errno::EINVAL
* * Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as * * Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as
* ADDR_ANY TODO check ADDRANY TO INADDR_ANY * ADDR_ANY TODO check ADDRANY TO INADDR_ANY
* * Errno::EAFNOSUPPORT - addresses in the specified family cannot be used with * * Errno::EAFNOSUPPORT - addresses in the specified family cannot be used with
* with this +socket+ * with this +socket+
@ -234,11 +234,11 @@ rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
* * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket
* * Errno::ETIMEDOUT - the attempt to connect time out before a connection * * Errno::ETIMEDOUT - the attempt to connect time out before a connection
* was made. * was made.
* * Errno::EWOULDBLOCK - the socket is marked as nonblocking and the * * Errno::EWOULDBLOCK - the socket is marked as nonblocking and the
* connection cannot be completed immediately * connection cannot be completed immediately
* * Errno::EACCES - the attempt to connect the datagram socket to the * * Errno::EACCES - the attempt to connect the datagram socket to the
* broadcast address failed * broadcast address failed
* *
* === See * === See
* * connect manual pages on unix-based systems * * connect manual pages on unix-based systems
* * connect function in Microsoft's Winsock functions reference * * connect function in Microsoft's Winsock functions reference
@ -264,14 +264,14 @@ sock_connect(VALUE sock, VALUE addr)
/* /*
* call-seq: * call-seq:
* socket.connect_nonblock(remote_sockaddr) => 0 * socket.connect_nonblock(remote_sockaddr) => 0
* *
* Requests a connection to be made on the given +remote_sockaddr+ after * Requests a connection to be made on the given +remote_sockaddr+ after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* Returns 0 if successful, otherwise an exception is raised. * Returns 0 if successful, otherwise an exception is raised.
* *
* === Parameter * === Parameter
* * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object * * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
* *
* === Example: * === Example:
* # Pull down Google's web page * # Pull down Google's web page
* require 'socket' * require 'socket'
@ -283,15 +283,15 @@ sock_connect(VALUE sock, VALUE addr)
* rescue IO::WaitWritable * rescue IO::WaitWritable
* IO.select(nil, [socket]) # wait 3-way handshake completion * IO.select(nil, [socket]) # wait 3-way handshake completion
* begin * begin
* socket.connect_nonblock(sockaddr) # check connection failure * socket.connect_nonblock(sockaddr) # check connection failure
* rescue Errno::EISCONN * rescue Errno::EISCONN
* end * end
* end * end
* socket.write("GET / HTTP/1.0\r\n\r\n") * socket.write("GET / HTTP/1.0\r\n\r\n")
* results = socket.read * results = socket.read
* *
* Refer to Socket#connect for the exceptions that may be thrown if the call * Refer to Socket#connect for the exceptions that may be thrown if the call
* to _connect_nonblock_ fails. * to _connect_nonblock_ fails.
* *
* Socket#connect_nonblock may raise any error corresponding to connect(2) failure, * Socket#connect_nonblock may raise any error corresponding to connect(2) failure,
* including Errno::EINPROGRESS. * including Errno::EINPROGRESS.
@ -326,9 +326,9 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
/* /*
* call-seq: * call-seq:
* socket.bind(local_sockaddr) => 0 * socket.bind(local_sockaddr) => 0
* *
* Binds to the given local address. * Binds to the given local address.
* *
* === Parameter * === Parameter
* * +local_sockaddr+ - the +struct+ sockaddr contained in a string or an Addrinfo object * * +local_sockaddr+ - the +struct+ sockaddr contained in a string or an Addrinfo object
* *
@ -345,9 +345,9 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
* socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
* sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
* socket.bind( sockaddr ) * socket.bind( sockaddr )
* *
* === Unix-based Exceptions * === Unix-based Exceptions
* On unix-based based systems the following system exceptions may be raised if * On unix-based based systems the following system exceptions may be raised if
* the call to _bind_ fails: * the call to _bind_ fails:
* * Errno::EACCES - the specified _sockaddr_ is protected and the current * * Errno::EACCES - the specified _sockaddr_ is protected and the current
* user does not have permission to bind to it * user does not have permission to bind to it
@ -358,7 +358,7 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
* the family of the calling +socket+ * the family of the calling +socket+
* * Errno::EBADF - the _sockaddr_ specified is not a valid file descriptor * * Errno::EBADF - the _sockaddr_ specified is not a valid file descriptor
* * Errno::EFAULT - the _sockaddr_ argument cannot be accessed * * Errno::EFAULT - the _sockaddr_ argument cannot be accessed
* * Errno::EINVAL - the +socket+ is already bound to an address, and the * * Errno::EINVAL - the +socket+ is already bound to an address, and the
* protocol does not support binding to the new _sockaddr_ or the +socket+ * protocol does not support binding to the new _sockaddr_ or the +socket+
* has been shut down. * has been shut down.
* * Errno::EINVAL - the address length is not a valid length for the address * * Errno::EINVAL - the address length is not a valid length for the address
@ -366,12 +366,12 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
* * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded * * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded
* PATH_MAX * PATH_MAX
* * Errno::ENOBUFS - no buffer space is available * * Errno::ENOBUFS - no buffer space is available
* * Errno::ENOSR - there were insufficient STREAMS resources available to * * Errno::ENOSR - there were insufficient STREAMS resources available to
* complete the operation * complete the operation
* * Errno::ENOTSOCK - the +socket+ does not refer to a socket * * Errno::ENOTSOCK - the +socket+ does not refer to a socket
* * Errno::EOPNOTSUPP - the socket type of the +socket+ does not support * * Errno::EOPNOTSUPP - the socket type of the +socket+ does not support
* binding to an address * binding to an address
* *
* On unix-based based systems if the address family of the calling +socket+ is * On unix-based based systems if the address family of the calling +socket+ is
* Socket::AF_UNIX the follow exceptions may be raised if the call to _bind_ * Socket::AF_UNIX the follow exceptions may be raised if the call to _bind_
* fails: * fails:
@ -382,19 +382,19 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
* * Errno::EIO - an i/o error occurred * * Errno::EIO - an i/o error occurred
* * Errno::ELOOP - too many symbolic links were encountered in translating * * Errno::ELOOP - too many symbolic links were encountered in translating
* the pathname in _sockaddr_ * the pathname in _sockaddr_
* * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX * * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX
* characters, or an entire pathname exceeded PATH_MAX characters * characters, or an entire pathname exceeded PATH_MAX characters
* * Errno::ENOENT - a component of the pathname does not name an existing file * * Errno::ENOENT - a component of the pathname does not name an existing file
* or the pathname is an empty string * or the pathname is an empty string
* * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ * * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_
* is not a directory * is not a directory
* * Errno::EROFS - the name would reside on a read only filesystem * * Errno::EROFS - the name would reside on a read only filesystem
* *
* === Windows Exceptions * === Windows Exceptions
* On Windows systems the following system exceptions may be raised if * On Windows systems the following system exceptions may be raised if
* the call to _bind_ fails: * the call to _bind_ fails:
* * Errno::ENETDOWN-- the network is down * * Errno::ENETDOWN-- the network is down
* * Errno::EACCES - the attempt to connect the datagram socket to the * * Errno::EACCES - the attempt to connect the datagram socket to the
* broadcast address failed * broadcast address failed
* * Errno::EADDRINUSE - the socket's local address is already in use * * Errno::EADDRINUSE - the socket's local address is already in use
* * Errno::EADDRNOTAVAIL - the specified address is not a valid address for this * * Errno::EADDRNOTAVAIL - the specified address is not a valid address for this
@ -404,11 +404,11 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
* * Errno::EINVAL - the +socket+ is already bound to an address * * Errno::EINVAL - the +socket+ is already bound to an address
* * Errno::ENOBUFS - no buffer space is available * * Errno::ENOBUFS - no buffer space is available
* * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket * * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket
* *
* === See * === See
* * bind manual pages on unix-based systems * * bind manual pages on unix-based systems
* * bind function in Microsoft's Winsock functions reference * * bind function in Microsoft's Winsock functions reference
*/ */
static VALUE static VALUE
sock_bind(VALUE sock, VALUE addr) sock_bind(VALUE sock, VALUE addr)
{ {
@ -425,14 +425,14 @@ sock_bind(VALUE sock, VALUE addr)
/* /*
* call-seq: * call-seq:
* socket.listen( int ) => 0 * socket.listen( int ) => 0
* *
* Listens for connections, using the specified +int+ as the backlog. A call * Listens for connections, using the specified +int+ as the backlog. A call
* to _listen_ only applies if the +socket+ is of type SOCK_STREAM or * to _listen_ only applies if the +socket+ is of type SOCK_STREAM or
* SOCK_SEQPACKET. * SOCK_SEQPACKET.
* *
* === Parameter * === Parameter
* * +backlog+ - the maximum length of the queue for pending connections. * * +backlog+ - the maximum length of the queue for pending connections.
* *
* === Example 1 * === Example 1
* require 'socket' * require 'socket'
* include Socket::Constants * include Socket::Constants
@ -440,43 +440,43 @@ sock_bind(VALUE sock, VALUE addr)
* sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
* socket.bind( sockaddr ) * socket.bind( sockaddr )
* socket.listen( 5 ) * socket.listen( 5 )
* *
* === Example 2 (listening on an arbitrary port, unix-based systems only): * === Example 2 (listening on an arbitrary port, unix-based systems only):
* require 'socket' * require 'socket'
* include Socket::Constants * include Socket::Constants
* socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
* socket.listen( 1 ) * socket.listen( 1 )
* *
* === Unix-based Exceptions * === Unix-based Exceptions
* On unix based systems the above will work because a new +sockaddr+ struct * On unix based systems the above will work because a new +sockaddr+ struct
* is created on the address ADDR_ANY, for an arbitrary port number as handed * is created on the address ADDR_ANY, for an arbitrary port number as handed
* off by the kernel. It will not work on Windows, because Windows requires that * off by the kernel. It will not work on Windows, because Windows requires that
* the +socket+ is bound by calling _bind_ before it can _listen_. * the +socket+ is bound by calling _bind_ before it can _listen_.
* *
* If the _backlog_ amount exceeds the implementation-dependent maximum * If the _backlog_ amount exceeds the implementation-dependent maximum
* queue length, the implementation's maximum queue length will be used. * queue length, the implementation's maximum queue length will be used.
* *
* On unix-based based systems the following system exceptions may be raised if the * On unix-based based systems the following system exceptions may be raised if the
* call to _listen_ fails: * call to _listen_ fails:
* * Errno::EBADF - the _socket_ argument is not a valid file descriptor * * Errno::EBADF - the _socket_ argument is not a valid file descriptor
* * Errno::EDESTADDRREQ - the _socket_ is not bound to a local address, and * * Errno::EDESTADDRREQ - the _socket_ is not bound to a local address, and
* the protocol does not support listening on an unbound socket * the protocol does not support listening on an unbound socket
* * Errno::EINVAL - the _socket_ is already connected * * Errno::EINVAL - the _socket_ is already connected
* * Errno::ENOTSOCK - the _socket_ argument does not refer to a socket * * Errno::ENOTSOCK - the _socket_ argument does not refer to a socket
* * Errno::EOPNOTSUPP - the _socket_ protocol does not support listen * * Errno::EOPNOTSUPP - the _socket_ protocol does not support listen
* * Errno::EACCES - the calling process does not have appropriate privileges * * Errno::EACCES - the calling process does not have appropriate privileges
* * Errno::EINVAL - the _socket_ has been shut down * * Errno::EINVAL - the _socket_ has been shut down
* * Errno::ENOBUFS - insufficient resources are available in the system to * * Errno::ENOBUFS - insufficient resources are available in the system to
* complete the call * complete the call
* *
* === Windows Exceptions * === Windows Exceptions
* On Windows systems the following system exceptions may be raised if * On Windows systems the following system exceptions may be raised if
* the call to _listen_ fails: * the call to _listen_ fails:
* * Errno::ENETDOWN - the network is down * * Errno::ENETDOWN - the network is down
* * Errno::EADDRINUSE - the socket's local address is already in use. This * * Errno::EADDRINUSE - the socket's local address is already in use. This
* usually occurs during the execution of _bind_ but could be delayed * usually occurs during the execution of _bind_ but could be delayed
* if the call to _bind_ was to a partially wildcard address (involving * if the call to _bind_ was to a partially wildcard address (involving
* ADDR_ANY) and if a specific address needs to be committed at the * ADDR_ANY) and if a specific address needs to be committed at the
* time of the call to _listen_ * time of the call to _listen_
* * Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the * * Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the
* service provider is still processing a callback function * service provider is still processing a callback function
@ -487,7 +487,7 @@ sock_bind(VALUE sock, VALUE addr)
* * Errno::ENOTSOC - +socket+ is not a socket * * Errno::ENOTSOC - +socket+ is not a socket
* * Errno::EOPNOTSUPP - the referenced +socket+ is not a type that supports * * Errno::EOPNOTSUPP - the referenced +socket+ is not a type that supports
* the _listen_ method * the _listen_ method
* *
* === See * === See
* * listen manual pages on unix-based systems * * listen manual pages on unix-based systems
* * listen function in Microsoft's Winsock functions reference * * listen function in Microsoft's Winsock functions reference
@ -511,16 +511,16 @@ rsock_sock_listen(VALUE sock, VALUE log)
* call-seq: * call-seq:
* socket.recvfrom(maxlen) => [mesg, sender_addrinfo] * socket.recvfrom(maxlen) => [mesg, sender_addrinfo]
* socket.recvfrom(maxlen, flags) => [mesg, sender_addrinfo] * socket.recvfrom(maxlen, flags) => [mesg, sender_addrinfo]
* *
* Receives up to _maxlen_ bytes from +socket+. _flags_ is zero or more * Receives up to _maxlen_ bytes from +socket+. _flags_ is zero or more
* of the +MSG_+ options. The first element of the results, _mesg_, is the data * of the +MSG_+ options. The first element of the results, _mesg_, is the data
* received. The second element, _sender_addrinfo_, contains protocol-specific * received. The second element, _sender_addrinfo_, contains protocol-specific
* address information of the sender. * address information of the sender.
* *
* === Parameters * === Parameters
* * +maxlen+ - the maximum number of bytes to receive from the socket * * +maxlen+ - the maximum number of bytes to receive from the socket
* * +flags+ - zero or more of the +MSG_+ options * * +flags+ - zero or more of the +MSG_+ options
* *
* === Example * === Example
* # In one file, start this first * # In one file, start this first
* require 'socket' * require 'socket'
@ -534,7 +534,7 @@ rsock_sock_listen(VALUE sock, VALUE log)
* puts "I only received 20 bytes '#{data}'" * puts "I only received 20 bytes '#{data}'"
* sleep 1 * sleep 1
* socket.close * socket.close
* *
* # In another file, start this second * # In another file, start this second
* require 'socket' * require 'socket'
* include Socket::Constants * include Socket::Constants
@ -542,29 +542,29 @@ rsock_sock_listen(VALUE sock, VALUE log)
* sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
* socket.connect( sockaddr ) * socket.connect( sockaddr )
* socket.puts "Watch this get cut short!" * socket.puts "Watch this get cut short!"
* socket.close * socket.close
* *
* === Unix-based Exceptions * === Unix-based Exceptions
* On unix-based based systems the following system exceptions may be raised if the * On unix-based based systems the following system exceptions may be raised if the
* call to _recvfrom_ fails: * call to _recvfrom_ fails:
* * Errno::EAGAIN - the +socket+ file descriptor is marked as O_NONBLOCK and no * * Errno::EAGAIN - the +socket+ file descriptor is marked as O_NONBLOCK and no
* data is waiting to be received; or MSG_OOB is set and no out-of-band data * data is waiting to be received; or MSG_OOB is set and no out-of-band data
* is available and either the +socket+ file descriptor is marked as * is available and either the +socket+ file descriptor is marked as
* O_NONBLOCK or the +socket+ does not support blocking to wait for * O_NONBLOCK or the +socket+ does not support blocking to wait for
* out-of-band-data * out-of-band-data
* * Errno::EWOULDBLOCK - see Errno::EAGAIN * * Errno::EWOULDBLOCK - see Errno::EAGAIN
* * Errno::EBADF - the +socket+ is not a valid file descriptor * * Errno::EBADF - the +socket+ is not a valid file descriptor
* * Errno::ECONNRESET - a connection was forcibly closed by a peer * * Errno::ECONNRESET - a connection was forcibly closed by a peer
* * Errno::EFAULT - the socket's internal buffer, address or address length * * Errno::EFAULT - the socket's internal buffer, address or address length
* cannot be accessed or written * cannot be accessed or written
* * Errno::EINTR - a signal interrupted _recvfrom_ before any data was available * * Errno::EINTR - a signal interrupted _recvfrom_ before any data was available
* * Errno::EINVAL - the MSG_OOB flag is set and no out-of-band data is available * * Errno::EINVAL - the MSG_OOB flag is set and no out-of-band data is available
* * Errno::EIO - an i/o error occurred while reading from or writing to the * * Errno::EIO - an i/o error occurred while reading from or writing to the
* filesystem * filesystem
* * Errno::ENOBUFS - insufficient resources were available in the system to * * Errno::ENOBUFS - insufficient resources were available in the system to
* perform the operation * perform the operation
* * Errno::ENOMEM - insufficient memory was available to fulfill the request * * Errno::ENOMEM - insufficient memory was available to fulfill the request
* * Errno::ENOSR - there were insufficient STREAMS resources available to * * Errno::ENOSR - there were insufficient STREAMS resources available to
* complete the operation * complete the operation
* * Errno::ENOTCONN - a receive is attempted on a connection-mode socket that * * Errno::ENOTCONN - a receive is attempted on a connection-mode socket that
* is not connected * is not connected
@ -572,9 +572,9 @@ rsock_sock_listen(VALUE sock, VALUE log)
* * Errno::EOPNOTSUPP - the specified flags are not supported for this socket type * * Errno::EOPNOTSUPP - the specified flags are not supported for this socket type
* * Errno::ETIMEDOUT - the connection timed out during connection establishment * * Errno::ETIMEDOUT - the connection timed out during connection establishment
* or due to a transmission timeout on an active connection * or due to a transmission timeout on an active connection
* *
* === Windows Exceptions * === Windows Exceptions
* On Windows systems the following system exceptions may be raised if * On Windows systems the following system exceptions may be raised if
* the call to _recvfrom_ fails: * the call to _recvfrom_ fails:
* * Errno::ENETDOWN - the network is down * * Errno::ENETDOWN - the network is down
* * Errno::EFAULT - the internal buffer and from parameters on +socket+ are not * * Errno::EFAULT - the internal buffer and from parameters on +socket+ are not
@ -582,31 +582,31 @@ rsock_sock_listen(VALUE sock, VALUE log)
* too small to accommodate the peer address * too small to accommodate the peer address
* * Errno::EINTR - the (blocking) call was cancelled by an internal call to * * Errno::EINTR - the (blocking) call was cancelled by an internal call to
* the WinSock function WSACancelBlockingCall * the WinSock function WSACancelBlockingCall
* * Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or * * Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or
* the service provider is still processing a callback function * the service provider is still processing a callback function
* * Errno::EINVAL - +socket+ has not been bound with a call to _bind_, or an * * Errno::EINVAL - +socket+ has not been bound with a call to _bind_, or an
* unknown flag was specified, or MSG_OOB was specified for a socket with * unknown flag was specified, or MSG_OOB was specified for a socket with
* SO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal * SO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal
* len parameter on +socket+ was zero or negative * len parameter on +socket+ was zero or negative
* * Errno::EISCONN - +socket+ is already connected. The call to _recvfrom_ is * * Errno::EISCONN - +socket+ is already connected. The call to _recvfrom_ is
* not permitted with a connected socket on a socket that is connection * not permitted with a connected socket on a socket that is connection
* oriented or connectionless. * oriented or connectionless.
* * Errno::ENETRESET - the connection has been broken due to the keep-alive * * Errno::ENETRESET - the connection has been broken due to the keep-alive
* activity detecting a failure while the operation was in progress. * activity detecting a failure while the operation was in progress.
* * Errno::EOPNOTSUPP - MSG_OOB was specified, but +socket+ is not stream-style * * Errno::EOPNOTSUPP - MSG_OOB was specified, but +socket+ is not stream-style
* such as type SOCK_STREAM. OOB data is not supported in the communication * such as type SOCK_STREAM. OOB data is not supported in the communication
* domain associated with +socket+, or +socket+ is unidirectional and * domain associated with +socket+, or +socket+ is unidirectional and
* supports only send operations * supports only send operations
* * Errno::ESHUTDOWN - +socket+ has been shutdown. It is not possible to * * Errno::ESHUTDOWN - +socket+ has been shutdown. It is not possible to
* call _recvfrom_ on a socket after _shutdown_ has been invoked. * call _recvfrom_ on a socket after _shutdown_ has been invoked.
* * Errno::EWOULDBLOCK - +socket+ is marked as nonblocking and a call to * * Errno::EWOULDBLOCK - +socket+ is marked as nonblocking and a call to
* _recvfrom_ would block. * _recvfrom_ would block.
* * Errno::EMSGSIZE - the message was too large to fit into the specified buffer * * Errno::EMSGSIZE - the message was too large to fit into the specified buffer
* and was truncated. * and was truncated.
* * Errno::ETIMEDOUT - the connection has been dropped, because of a network * * Errno::ETIMEDOUT - the connection has been dropped, because of a network
* failure or because the system on the other end went down without * failure or because the system on the other end went down without
* notice * notice
* * Errno::ECONNRESET - the virtual circuit was reset by the remote side * * Errno::ECONNRESET - the virtual circuit was reset by the remote side
* executing a hard or abortive close. The application should close the * executing a hard or abortive close. The application should close the
* socket; it is no longer usable. On a UDP-datagram socket this error * socket; it is no longer usable. On a UDP-datagram socket this error
* indicates a previous send operation resulted in an ICMP Port Unreachable * indicates a previous send operation resulted in an ICMP Port Unreachable
@ -622,7 +622,7 @@ sock_recvfrom(int argc, VALUE *argv, VALUE sock)
* call-seq: * call-seq:
* socket.recvfrom_nonblock(maxlen) => [mesg, sender_addrinfo] * socket.recvfrom_nonblock(maxlen) => [mesg, sender_addrinfo]
* socket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_addrinfo] * socket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_addrinfo]
* *
* Receives up to _maxlen_ bytes from +socket+ using recvfrom(2) after * Receives up to _maxlen_ bytes from +socket+ using recvfrom(2) after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* _flags_ is zero or more of the +MSG_+ options. * _flags_ is zero or more of the +MSG_+ options.
@ -633,11 +633,11 @@ sock_recvfrom(int argc, VALUE *argv, VALUE sock)
* When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns * When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns
* an empty string as data. * an empty string as data.
* The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc. * The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
* *
* === Parameters * === Parameters
* * +maxlen+ - the maximum number of bytes to receive from the socket * * +maxlen+ - the maximum number of bytes to receive from the socket
* * +flags+ - zero or more of the +MSG_+ options * * +flags+ - zero or more of the +MSG_+ options
* *
* === Example * === Example
* # In one file, start this first * # In one file, start this first
* require 'socket' * require 'socket'
@ -657,7 +657,7 @@ sock_recvfrom(int argc, VALUE *argv, VALUE sock)
* puts "I only received 20 bytes '#{data}'" * puts "I only received 20 bytes '#{data}'"
* sleep 1 * sleep 1
* socket.close * socket.close
* *
* # In another file, start this second * # In another file, start this second
* require 'socket' * require 'socket'
* include Socket::Constants * include Socket::Constants
@ -665,10 +665,10 @@ sock_recvfrom(int argc, VALUE *argv, VALUE sock)
* sockaddr = Socket.sockaddr_in(2200, 'localhost') * sockaddr = Socket.sockaddr_in(2200, 'localhost')
* socket.connect(sockaddr) * socket.connect(sockaddr)
* socket.puts "Watch this get cut short!" * socket.puts "Watch this get cut short!"
* socket.close * socket.close
* *
* Refer to Socket#recvfrom for the exceptions that may be thrown if the call * Refer to Socket#recvfrom for the exceptions that may be thrown if the call
* to _recvfrom_nonblock_ fails. * to _recvfrom_nonblock_ fails.
* *
* Socket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure, * Socket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure,
* including Errno::EWOULDBLOCK. * including Errno::EWOULDBLOCK.
@ -717,13 +717,13 @@ sock_accept(VALUE sock)
/* /*
* call-seq: * call-seq:
* socket.accept_nonblock => [client_socket, client_addrinfo] * socket.accept_nonblock => [client_socket, client_addrinfo]
* *
* Accepts an incoming connection using accept(2) after * Accepts an incoming connection using accept(2) after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* It returns an array containing the accepted socket * It returns an array containing the accepted socket
* for the incoming connection, _client_socket_, * for the incoming connection, _client_socket_,
* and an Addrinfo, _client_addrinfo_. * and an Addrinfo, _client_addrinfo_.
* *
* === Example * === Example
* # In one script, start this first * # In one script, start this first
* require 'socket' * require 'socket'
@ -741,19 +741,19 @@ sock_accept(VALUE sock)
* puts "The client said, '#{client_socket.readline.chomp}'" * puts "The client said, '#{client_socket.readline.chomp}'"
* client_socket.puts "Hello from script one!" * client_socket.puts "Hello from script one!"
* socket.close * socket.close
* *
* # In another script, start this second * # In another script, start this second
* require 'socket' * require 'socket'
* include Socket::Constants * include Socket::Constants
* socket = Socket.new(AF_INET, SOCK_STREAM, 0) * socket = Socket.new(AF_INET, SOCK_STREAM, 0)
* sockaddr = Socket.sockaddr_in(2200, 'localhost') * sockaddr = Socket.sockaddr_in(2200, 'localhost')
* socket.connect(sockaddr) * socket.connect(sockaddr)
* socket.puts "Hello from script 2." * socket.puts "Hello from script 2."
* puts "The server said, '#{socket.readline.chomp}'" * puts "The server said, '#{socket.readline.chomp}'"
* socket.close * socket.close
* *
* Refer to Socket#accept for the exceptions that may be thrown if the call * Refer to Socket#accept for the exceptions that may be thrown if the call
* to _accept_nonblock_ fails. * to _accept_nonblock_ fails.
* *
* Socket#accept_nonblock may raise any error corresponding to accept(2) failure, * Socket#accept_nonblock may raise any error corresponding to accept(2) failure,
* including Errno::EWOULDBLOCK. * including Errno::EWOULDBLOCK.
@ -761,7 +761,7 @@ sock_accept(VALUE sock)
* If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO, * If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO,
* it is extended by IO::WaitReadable. * it is extended by IO::WaitReadable.
* So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock. * So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
* *
* === See * === See
* * Socket#accept * * Socket#accept
*/ */
@ -781,11 +781,11 @@ sock_accept_nonblock(VALUE sock)
/* /*
* call-seq: * call-seq:
* socket.sysaccept => [client_socket_fd, client_addrinfo] * socket.sysaccept => [client_socket_fd, client_addrinfo]
* *
* Accepts an incoming connection returning an array containing the (integer) * Accepts an incoming connection returning an array containing the (integer)
* file descriptor for the incoming connection, _client_socket_fd_, * file descriptor for the incoming connection, _client_socket_fd_,
* and an Addrinfo, _client_addrinfo_. * and an Addrinfo, _client_addrinfo_.
* *
* === Example * === Example
* # In one script, start this first * # In one script, start this first
* require 'socket' * require 'socket'
@ -799,20 +799,20 @@ sock_accept_nonblock(VALUE sock)
* puts "The client said, '#{client_socket.readline.chomp}'" * puts "The client said, '#{client_socket.readline.chomp}'"
* client_socket.puts "Hello from script one!" * client_socket.puts "Hello from script one!"
* socket.close * socket.close
* *
* # In another script, start this second * # In another script, start this second
* require 'socket' * require 'socket'
* include Socket::Constants * include Socket::Constants
* socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
* sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' ) * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
* socket.connect( sockaddr ) * socket.connect( sockaddr )
* socket.puts "Hello from script 2." * socket.puts "Hello from script 2."
* puts "The server said, '#{socket.readline.chomp}'" * puts "The server said, '#{socket.readline.chomp}'"
* socket.close * socket.close
* *
* Refer to Socket#accept for the exceptions that may be thrown if the call * Refer to Socket#accept for the exceptions that may be thrown if the call
* to _sysaccept_ fails. * to _sysaccept_ fails.
* *
* === See * === See
* * Socket#accept * * Socket#accept
*/ */
@ -944,7 +944,7 @@ sock_s_gethostbyname(VALUE obj, VALUE host)
* *
* Obtains the host information for _address_. * Obtains the host information for _address_.
* *
* p Socket.gethostbyaddr([221,186,184,68].pack("CCCC")) * p Socket.gethostbyaddr([221,186,184,68].pack("CCCC"))
* #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"] * #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"]
*/ */
static VALUE static VALUE
@ -1009,7 +1009,7 @@ sock_s_gethostbyaddr(int argc, VALUE *argv)
* Socket.getservbyname("smtp") #=> 25 * Socket.getservbyname("smtp") #=> 25
* Socket.getservbyname("shell") #=> 514 * Socket.getservbyname("shell") #=> 514
* Socket.getservbyname("syslog", "udp") #=> 514 * Socket.getservbyname("syslog", "udp") #=> 514
*/ */
static VALUE static VALUE
sock_s_getservbyname(int argc, VALUE *argv) sock_s_getservbyname(int argc, VALUE *argv)
{ {
@ -1394,7 +1394,7 @@ sock_s_pack_sockaddr_un(VALUE self, VALUE path)
* *
* _sockaddr_ should be a string or an addrinfo for AF_UNIX. * _sockaddr_ should be a string or an addrinfo for AF_UNIX.
* *
* sockaddr = Socket.sockaddr_un("/tmp/sock") * sockaddr = Socket.sockaddr_un("/tmp/sock")
* p Socket.unpack_sockaddr_un(sockaddr) #=> "/tmp/sock" * p Socket.unpack_sockaddr_un(sockaddr) #=> "/tmp/sock"
* *
*/ */
@ -1800,15 +1800,15 @@ socket_s_ip_address_list(VALUE self)
* The constants defined under Socket::Constants are also defined under Socket. * The constants defined under Socket::Constants are also defined under Socket.
* For example, Socket::AF_INET is usable as well as Socket::Constants::AF_INET. * For example, Socket::AF_INET is usable as well as Socket::Constants::AF_INET.
* See Socket::Constants for the list of constants. * See Socket::Constants for the list of constants.
* *
* === Exception Handling * === Exception Handling
* Ruby's implementation of +Socket+ causes an exception to be raised * Ruby's implementation of +Socket+ causes an exception to be raised
* based on the error generated by the system dependent implementation. * based on the error generated by the system dependent implementation.
* This is why the methods are documented in a way that isolate * This is why the methods are documented in a way that isolate
* Unix-based system exceptions from Windows based exceptions. If more * Unix-based system exceptions from Windows based exceptions. If more
* information on particular exception is needed please refer to the * information on particular exception is needed please refer to the
* Unix manual pages or the Windows WinSock reference. * Unix manual pages or the Windows WinSock reference.
* *
* === Convenient methods * === Convenient methods
* *
* Although the general way to create socket is Socket.new, * Although the general way to create socket is Socket.new,
@ -1818,14 +1818,14 @@ socket_s_ip_address_list(VALUE self)
* * TCP server socket: Socket.tcp_server_loop, TCPServer.open * * TCP server socket: Socket.tcp_server_loop, TCPServer.open
* * UNIX client socket: Socket.unix, UNIXSocket.open * * UNIX client socket: Socket.unix, UNIXSocket.open
* * UNIX server socket: Socket.unix_server_loop, UNIXServer.open * * UNIX server socket: Socket.unix_server_loop, UNIXServer.open
* *
* === Documentation by * === Documentation by
* * Zach Dennis * * Zach Dennis
* * Sam Roberts * * Sam Roberts
* * <em>Programming Ruby</em> from The Pragmatic Bookshelf. * * <em>Programming Ruby</em> from The Pragmatic Bookshelf.
* *
* Much material in this documentation is taken with permission from * Much material in this documentation is taken with permission from
* <em>Programming Ruby</em> from The Pragmatic Bookshelf. * <em>Programming Ruby</em> from The Pragmatic Bookshelf.
*/ */
void void
Init_socket() Init_socket()

View file

@ -41,7 +41,7 @@ tcp_svr_init(int argc, VALUE *argv, VALUE sock)
* s.puts Time.now * s.puts Time.now
* s.close * s.close
* } * }
* *
*/ */
static VALUE static VALUE
tcp_accept(VALUE sock) tcp_accept(VALUE sock)
@ -49,7 +49,7 @@ tcp_accept(VALUE sock)
rb_io_t *fptr; rb_io_t *fptr;
struct sockaddr_storage from; struct sockaddr_storage from;
socklen_t fromlen; socklen_t fromlen;
GetOpenFile(sock, fptr); GetOpenFile(sock, fptr);
fromlen = sizeof(from); fromlen = sizeof(from);
return rsock_s_accept(rb_cTCPSocket, fptr->fd, return rsock_s_accept(rb_cTCPSocket, fptr->fd,
@ -59,11 +59,11 @@ tcp_accept(VALUE sock)
/* /*
* call-seq: * call-seq:
* tcpserver.accept_nonblock => tcpsocket * tcpserver.accept_nonblock => tcpsocket
* *
* Accepts an incoming connection using accept(2) after * Accepts an incoming connection using accept(2) after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* It returns an accepted TCPSocket for the incoming connection. * It returns an accepted TCPSocket for the incoming connection.
* *
* === Example * === Example
* require 'socket' * require 'socket'
* serv = TCPServer.new(2202) * serv = TCPServer.new(2202)
@ -74,9 +74,9 @@ tcp_accept(VALUE sock)
* retry * retry
* end * end
* # sock is an accepted socket. * # sock is an accepted socket.
* *
* Refer to Socket#accept for the exceptions that may be thrown if the call * Refer to Socket#accept for the exceptions that may be thrown if the call
* to TCPServer#accept_nonblock fails. * to TCPServer#accept_nonblock fails.
* *
* TCPServer#accept_nonblock may raise any error corresponding to accept(2) failure, * TCPServer#accept_nonblock may raise any error corresponding to accept(2) failure,
* including Errno::EWOULDBLOCK. * including Errno::EWOULDBLOCK.
@ -84,7 +84,7 @@ tcp_accept(VALUE sock)
* If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED, Errno::EPROTO, * If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED, Errno::EPROTO,
* it is extended by IO::WaitReadable. * it is extended by IO::WaitReadable.
* So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock. * So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
* *
* === See * === See
* * TCPServer#accept * * TCPServer#accept
* * Socket#accept * * Socket#accept
@ -110,7 +110,7 @@ tcp_accept_nonblock(VALUE sock)
* *
* TCPServer.open("127.0.0.1", 28561) {|serv| * TCPServer.open("127.0.0.1", 28561) {|serv|
* fd = serv.sysaccept * fd = serv.sysaccept
* s = IO.for_fd(fd) * s = IO.for_fd(fd)
* s.puts Time.now * s.puts Time.now
* s.close * s.close
* } * }

View file

@ -137,7 +137,7 @@ udp_bind(VALUE sock, VALUE host, VALUE port)
* udpsocket.send(mesg, flags) => numbytes_sent * udpsocket.send(mesg, flags) => numbytes_sent
* *
* Sends _mesg_ via _udpsocket_. * Sends _mesg_ via _udpsocket_.
* *
* _flags_ should be a bitwise OR of Socket::MSG_* constants. * _flags_ should be a bitwise OR of Socket::MSG_* constants.
* *
* u1 = UDPSocket.new * u1 = UDPSocket.new
@ -195,7 +195,7 @@ udp_send(int argc, VALUE *argv, VALUE sock)
* call-seq: * call-seq:
* udpsocket.recvfrom_nonblock(maxlen) => [mesg, sender_inet_addr] * udpsocket.recvfrom_nonblock(maxlen) => [mesg, sender_inet_addr]
* udpsocket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_inet_addr] * udpsocket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_inet_addr]
* *
* Receives up to _maxlen_ bytes from +udpsocket+ using recvfrom(2) after * Receives up to _maxlen_ bytes from +udpsocket+ using recvfrom(2) after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* If _maxlen_ is omitted, its default value is 65536. * If _maxlen_ is omitted, its default value is 65536.
@ -206,11 +206,11 @@ udp_send(int argc, VALUE *argv, VALUE sock)
* When recvfrom(2) returns 0, * When recvfrom(2) returns 0,
* Socket#recvfrom_nonblock returns an empty string as data. * Socket#recvfrom_nonblock returns an empty string as data.
* It means an empty packet. * It means an empty packet.
* *
* === Parameters * === Parameters
* * +maxlen+ - the number of bytes to receive from the socket * * +maxlen+ - the number of bytes to receive from the socket
* * +flags+ - zero or more of the +MSG_+ options * * +flags+ - zero or more of the +MSG_+ options
* *
* === Example * === Example
* require 'socket' * require 'socket'
* s1 = UDPSocket.new * s1 = UDPSocket.new
@ -228,7 +228,7 @@ udp_send(int argc, VALUE *argv, VALUE sock)
* end * end
* *
* Refer to Socket#recvfrom for the exceptions that may be thrown if the call * Refer to Socket#recvfrom for the exceptions that may be thrown if the call
* to _recvfrom_nonblock_ fails. * to _recvfrom_nonblock_ fails.
* *
* UDPSocket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure, * UDPSocket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure,
* including Errno::EWOULDBLOCK. * including Errno::EWOULDBLOCK.

View file

@ -60,11 +60,11 @@ unix_accept(VALUE sock)
/* /*
* call-seq: * call-seq:
* unixserver.accept_nonblock => unixsocket * unixserver.accept_nonblock => unixsocket
* *
* Accepts an incoming connection using accept(2) after * Accepts an incoming connection using accept(2) after
* O_NONBLOCK is set for the underlying file descriptor. * O_NONBLOCK is set for the underlying file descriptor.
* It returns an accepted UNIXSocket for the incoming connection. * It returns an accepted UNIXSocket for the incoming connection.
* *
* === Example * === Example
* require 'socket' * require 'socket'
* serv = UNIXServer.new("/tmp/sock") * serv = UNIXServer.new("/tmp/sock")
@ -75,9 +75,9 @@ unix_accept(VALUE sock)
* retry * retry
* end * end
* # sock is an accepted socket. * # sock is an accepted socket.
* *
* Refer to Socket#accept for the exceptions that may be thrown if the call * Refer to Socket#accept for the exceptions that may be thrown if the call
* to UNIXServer#accept_nonblock fails. * to UNIXServer#accept_nonblock fails.
* *
* UNIXServer#accept_nonblock may raise any error corresponding to accept(2) failure, * UNIXServer#accept_nonblock may raise any error corresponding to accept(2) failure,
* including Errno::EWOULDBLOCK. * including Errno::EWOULDBLOCK.
@ -85,7 +85,7 @@ unix_accept(VALUE sock)
* If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO, * If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO,
* it is extended by IO::WaitReadable. * it is extended by IO::WaitReadable.
* So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock. * So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
* *
* === See * === See
* * UNIXServer#accept * * UNIXServer#accept
* * Socket#accept * * Socket#accept
@ -115,7 +115,7 @@ unix_accept_nonblock(VALUE sock)
* fd = serv.sysaccept * fd = serv.sysaccept
* s = IO.new(fd) * s = IO.new(fd)
* s.puts "hi" * s.puts "hi"
* s.close * s.close
* p c.read #=> "hi\n" * p c.read #=> "hi\n"
* } * }
* } * }

View file

@ -89,7 +89,7 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server)
* *
* s = UNIXSocket.new("/tmp/sock") * s = UNIXSocket.new("/tmp/sock")
* s.send "hello", 0 * s.send "hello", 0
* *
*/ */
static VALUE static VALUE
unix_init(VALUE sock, VALUE path) unix_init(VALUE sock, VALUE path)
@ -271,11 +271,11 @@ recvmsg_blocking(void *data)
* unixsocket.recv_io([klass [, mode]]) => io * unixsocket.recv_io([klass [, mode]]) => io
* *
* UNIXServer.open("/tmp/sock") {|serv| * UNIXServer.open("/tmp/sock") {|serv|
* UNIXSocket.open("/tmp/sock") {|c| * UNIXSocket.open("/tmp/sock") {|c|
* s = serv.accept * s = serv.accept
* *
* c.send_io STDOUT * c.send_io STDOUT
* stdout = s.recv_io * stdout = s.recv_io
* *
* p STDOUT.fileno #=> 1 * p STDOUT.fileno #=> 1
* p stdout.fileno #=> 7 * p stdout.fileno #=> 7

View file

@ -323,7 +323,7 @@ strio_set_string(VALUE self, VALUE string)
* call-seq: * call-seq:
* strio.close -> nil * strio.close -> nil
* *
* Closes strio. The *strio* is unavailable for any further data * Closes strio. The *strio* is unavailable for any further data
* operations; an +IOError+ is raised if such an attempt is made. * operations; an +IOError+ is raised if such an attempt is made.
*/ */
static VALUE static VALUE
@ -420,7 +420,7 @@ strio_closed_write(VALUE self)
* strio.eof -> true or false * strio.eof -> true or false
* strio.eof? -> true or false * strio.eof? -> true or false
* *
* Returns true if *strio* is at end of file. The stringio must be * Returns true if *strio* is at end of file. The stringio must be
* opened for reading or an +IOError+ will be raised. * opened for reading or an +IOError+ will be raised.
*/ */
static VALUE static VALUE
@ -496,7 +496,7 @@ strio_set_lineno(VALUE self, VALUE lineno)
* strio.reopen(other_StrIO) -> strio * strio.reopen(other_StrIO) -> strio
* strio.reopen(string, mode) -> strio * strio.reopen(string, mode) -> strio
* *
* Reinitializes *strio* with the given <i>other_StrIO</i> or _string_ * Reinitializes *strio* with the given <i>other_StrIO</i> or _string_
* and _mode_ (see StringIO#new). * and _mode_ (see StringIO#new).
*/ */
static VALUE static VALUE
@ -971,7 +971,7 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
break; break;
} }
} }
str = strio_substr(ptr, s - RSTRING_PTR(ptr->string), e - s); str = strio_substr(ptr, s - RSTRING_PTR(ptr->string), e - s);
} }
else if (n == 1) { else if (n == 1) {
if ((p = memchr(s, RSTRING_PTR(str)[0], e - s)) != 0) { if ((p = memchr(s, RSTRING_PTR(str)[0], e - s)) != 0) {

View file

@ -29,7 +29,7 @@ struct strscanner
/* the string to scan */ /* the string to scan */
VALUE str; VALUE str;
/* scan pointers */ /* scan pointers */
long prev; /* legal only when MATCHED_P(s) */ long prev; /* legal only when MATCHED_P(s) */
long curr; /* always legal */ long curr; /* always legal */
@ -173,7 +173,7 @@ static VALUE
strscan_s_allocate(VALUE klass) strscan_s_allocate(VALUE klass)
{ {
struct strscanner *p; struct strscanner *p;
p = ALLOC(struct strscanner); p = ALLOC(struct strscanner);
MEMZERO(p, struct strscanner, 1); MEMZERO(p, struct strscanner, 1);
CLEAR_MATCH_STATUS(p); CLEAR_MATCH_STATUS(p);
@ -609,7 +609,7 @@ strscan_exist_p(VALUE self, VALUE re)
* *
* s = StringScanner.new("Fri Dec 12 1975 14:39") * s = StringScanner.new("Fri Dec 12 1975 14:39")
* s.skip_until /12/ # -> 10 * s.skip_until /12/ # -> 10
* s # * s #
*/ */
static VALUE static VALUE
strscan_skip_until(VALUE self, VALUE re) strscan_skip_until(VALUE self, VALUE re)
@ -893,7 +893,7 @@ strscan_matched_p(VALUE self)
/* /*
* Returns the last matched string. * Returns the last matched string.
* *
* s = StringScanner.new('test string') * s = StringScanner.new('test string')
* s.match?(/\w+/) # -> 4 * s.match?(/\w+/) # -> 4
* s.matched # -> "test" * s.matched # -> "test"
@ -951,7 +951,7 @@ strscan_aref(VALUE self, VALUE idx)
GET_SCANNER(self, p); GET_SCANNER(self, p);
if (! MATCHED_P(p)) return Qnil; if (! MATCHED_P(p)) return Qnil;
i = NUM2LONG(idx); i = NUM2LONG(idx);
if (i < 0) if (i < 0)
i += p->regs.num_regs; i += p->regs.num_regs;
@ -1141,20 +1141,20 @@ inspect2(struct strscanner *p)
/* /*
* Document-class: StringScanner * Document-class: StringScanner
* *
* StringScanner provides for lexical scanning operations on a String. Here is * StringScanner provides for lexical scanning operations on a String. Here is
* an example of its usage: * an example of its usage:
* *
* s = StringScanner.new('This is an example string') * s = StringScanner.new('This is an example string')
* s.eos? # -> false * s.eos? # -> false
* *
* p s.scan(/\w+/) # -> "This" * p s.scan(/\w+/) # -> "This"
* p s.scan(/\w+/) # -> nil * p s.scan(/\w+/) # -> nil
* p s.scan(/\s+/) # -> " " * p s.scan(/\s+/) # -> " "
* p s.scan(/\s+/) # -> nil * p s.scan(/\s+/) # -> nil
* p s.scan(/\w+/) # -> "is" * p s.scan(/\w+/) # -> "is"
* s.eos? # -> false * s.eos? # -> false
* *
* p s.scan(/\s+/) # -> " " * p s.scan(/\s+/) # -> " "
* p s.scan(/\w+/) # -> "an" * p s.scan(/\w+/) # -> "an"
* p s.scan(/\s+/) # -> " " * p s.scan(/\s+/) # -> " "
@ -1162,7 +1162,7 @@ inspect2(struct strscanner *p)
* p s.scan(/\s+/) # -> " " * p s.scan(/\s+/) # -> " "
* p s.scan(/\w+/) # -> "string" * p s.scan(/\w+/) # -> "string"
* s.eos? # -> true * s.eos? # -> true
* *
* p s.scan(/\s+/) # -> nil * p s.scan(/\s+/) # -> nil
* p s.scan(/\w+/) # -> nil * p s.scan(/\w+/) # -> nil
* *
@ -1191,7 +1191,7 @@ inspect2(struct strscanner *p)
* the string without actually scanning. You can access the most recent match. * the string without actually scanning. You can access the most recent match.
* You can modify the string being scanned, reset or terminate the scanner, * You can modify the string being scanned, reset or terminate the scanner,
* find out or change the position of the scan pointer, skip ahead, and so on. * find out or change the position of the scan pointer, skip ahead, and so on.
* *
* === Advancing the Scan Pointer * === Advancing the Scan Pointer
* *
* - #getch * - #getch
@ -1222,7 +1222,7 @@ inspect2(struct strscanner *p)
* - #reset * - #reset
* - #terminate * - #terminate
* - #pos= * - #pos=
* *
* === Match Data * === Match Data
* *
* - #matched * - #matched
@ -1259,7 +1259,7 @@ Init_strscan()
tmp = rb_str_new2("$Id$"); tmp = rb_str_new2("$Id$");
rb_obj_freeze(tmp); rb_obj_freeze(tmp);
rb_const_set(StringScanner, rb_intern("Id"), tmp); rb_const_set(StringScanner, rb_intern("Id"), tmp);
rb_define_alloc_func(StringScanner, strscan_s_allocate); rb_define_alloc_func(StringScanner, strscan_s_allocate);
rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1); rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1);
rb_define_private_method(StringScanner, "initialize_copy", strscan_init_copy, 1); rb_define_private_method(StringScanner, "initialize_copy", strscan_init_copy, 1);

View file

@ -98,7 +98,7 @@ char *get_inline( SyckParser *parser );
if ( reset == 1 ) YYPOS(0); \ if ( reset == 1 ) YYPOS(0); \
return YAML_IOPEN; \ return YAML_IOPEN; \
} \ } \
} }
/* /*
* Nice little macro to ensure closure of levels. * Nice little macro to ensure closure of levels.
@ -135,7 +135,7 @@ sycklex_bytecode_utf8( YYSTYPE *sycklval, SyckParser *parser )
{ {
SyckLevel *lvl; SyckLevel *lvl;
syck_parser_ptr = parser; syck_parser_ptr = parser;
if ( YYCURSOR == NULL ) if ( YYCURSOR == NULL )
{ {
syck_parser_read( parser ); syck_parser_read( parser );
} }
@ -289,7 +289,7 @@ yy17: ++YYCURSOR;
goto yy18; goto yy18;
yy18: yy18:
#line 288 "bytecode.re" #line 288 "bytecode.re"
{ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str); { ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str);
goto Scalar; goto Scalar;
} }
#line 296 "<stdout>" #line 296 "<stdout>"
@ -392,7 +392,7 @@ yy28:
{ CHK_NL(YYCURSOR); { CHK_NL(YYCURSOR);
if ( lvl->status == syck_lvl_seq ) if ( lvl->status == syck_lvl_seq )
{ {
return YAML_INDENT; return YAML_INDENT;
} }
else if ( lvl->status == syck_lvl_map ) else if ( lvl->status == syck_lvl_map )
{ {
@ -434,12 +434,12 @@ yy33:
FORCE_NEXT_TOKEN( '}' ); FORCE_NEXT_TOKEN( '}' );
return '{'; return '{';
} }
POP_LEVEL(); POP_LEVEL();
lvl = CURRENT_LEVEL(); lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_seq ) if ( lvl->status == syck_lvl_seq )
{ {
FORCE_NEXT_TOKEN(YAML_INDENT); FORCE_NEXT_TOKEN(YAML_INDENT);
} }
else if ( lvl->status == syck_lvl_map ) else if ( lvl->status == syck_lvl_map )
{ {
@ -494,7 +494,7 @@ yy39:
{ {
complex = 1; complex = 1;
} }
ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_map); ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_map);
CHK_NL(YYCURSOR); CHK_NL(YYCURSOR);
if ( complex ) if ( complex )
{ {
@ -990,7 +990,7 @@ yy70: ++YYCURSOR;
yy71: yy71:
#line 461 "bytecode.re" #line 461 "bytecode.re"
{ YYCURSOR = tok; { YYCURSOR = tok;
goto ScalarEnd; goto ScalarEnd;
} }
#line 996 "<stdout>" #line 996 "<stdout>"
yy72: ++YYCURSOR; yy72: ++YYCURSOR;
@ -1001,7 +1001,7 @@ yy72: ++YYCURSOR;
yy73: yy73:
#line 469 "bytecode.re" #line 469 "bytecode.re"
{ CAT(str, cap, idx, tok[0]); { CAT(str, cap, idx, tok[0]);
goto Scalar2; goto Scalar2;
} }
#line 1007 "<stdout>" #line 1007 "<stdout>"
yy74: ++YYCURSOR; yy74: ++YYCURSOR;
@ -1071,7 +1071,7 @@ yy84:
#line 456 "bytecode.re" #line 456 "bytecode.re"
{ CHK_NL(tok+1); { CHK_NL(tok+1);
CAT(str, cap, idx, '\0'); CAT(str, cap, idx, '\0');
goto Scalar2; goto Scalar2;
} }
#line 1077 "<stdout>" #line 1077 "<stdout>"
} }
@ -1139,7 +1139,7 @@ yy89: ++YYCURSOR;
yy90: yy90:
#line 515 "bytecode.re" #line 515 "bytecode.re"
{ CAT(str, cap, idx, tok[0]); { CAT(str, cap, idx, tok[0]);
goto Inline; goto Inline;
} }
#line 1145 "<stdout>" #line 1145 "<stdout>"
yy91: ++YYCURSOR; yy91: ++YYCURSOR;

View file

@ -4,9 +4,9 @@
* $Author$ * $Author$
* *
* Copyright (C) 2003 why the lucky stiff * Copyright (C) 2003 why the lucky stiff
* *
* All Base64 code from Ruby's pack.c. * All Base64 code from Ruby's pack.c.
* Ruby is Copyright (C) 1993-2007 Yukihiro Matsumoto * Ruby is Copyright (C) 1993-2007 Yukihiro Matsumoto
*/ */
#include "ruby/ruby.h" #include "ruby/ruby.h"
@ -17,7 +17,7 @@
#define DEFAULT_ANCHOR_FORMAT "id%03d" #define DEFAULT_ANCHOR_FORMAT "id%03d"
const char hex_table[] = const char hex_table[] =
"0123456789ABCDEF"; "0123456789ABCDEF";
static char b64_table[] = static char b64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@ -131,7 +131,7 @@ syck_new_emitter(void)
e->output_handler = NULL; e->output_handler = NULL;
e->lvl_idx = 0; e->lvl_idx = 0;
e->lvl_capa = ALLOC_CT; e->lvl_capa = ALLOC_CT;
e->levels = S_ALLOC_N( SyckLevel, e->lvl_capa ); e->levels = S_ALLOC_N( SyckLevel, e->lvl_capa );
syck_emitter_reset_levels( e ); syck_emitter_reset_levels( e );
e->bonus = NULL; e->bonus = NULL;
return e; return e;
@ -197,7 +197,7 @@ syck_emitter_pop_level( SyckEmitter *e )
free( e->levels[e->lvl_idx].domain ); free( e->levels[e->lvl_idx].domain );
} }
void void
syck_emitter_add_level( SyckEmitter *e, int len, enum syck_level_status status ) syck_emitter_add_level( SyckEmitter *e, int len, enum syck_level_status status )
{ {
ASSERT( e != NULL ); ASSERT( e != NULL );
@ -289,7 +289,7 @@ syck_emitter_write( SyckEmitter *e, const char *str, long len )
{ {
syck_emitter_clear( e ); syck_emitter_clear( e );
} }
/* /*
* Flush if at end of buffer * Flush if at end of buffer
*/ */
@ -360,7 +360,7 @@ syck_emit( SyckEmitter *e, st_data_t n )
int indent = 0; int indent = 0;
long x = 0; long x = 0;
SyckLevel *lvl = syck_emitter_current_level( e ); SyckLevel *lvl = syck_emitter_current_level( e );
/* /*
* Determine headers. * Determine headers.
*/ */
@ -485,7 +485,7 @@ void syck_emit_tag( SyckEmitter *e, const char *tag, const char *ignore )
lvl->anctag = 1; lvl->anctag = 1;
} }
/* /*
* Emit a newline and an appropriately spaced indent. * Emit a newline and an appropriately spaced indent.
*/ */
void syck_emit_indent( SyckEmitter *e ) void syck_emit_indent( SyckEmitter *e )
@ -569,7 +569,7 @@ syck_scan_scalar( int req_width, const char *cursor, long len )
} else if ( len > 1 && cursor[len-2] == '\n' ) { } else if ( len > 1 && cursor[len-2] == '\n' ) {
flags |= SCAN_MANYNL_E; flags |= SCAN_MANYNL_E;
} }
if ( if (
( len > 0 && ( cursor[0] == ' ' || cursor[0] == '\t' ) ) || ( len > 0 && ( cursor[0] == ' ' || cursor[0] == '\t' ) ) ||
( len > 1 && ( cursor[len-1] == ' ' || cursor[len-1] == '\t' ) ) ( len > 1 && ( cursor[len-1] == ' ' || cursor[len-1] == '\t' ) )
) { ) {
@ -594,7 +594,7 @@ syck_scan_scalar( int req_width, const char *cursor, long len )
flags |= SCAN_NEWLINE; flags |= SCAN_NEWLINE;
if ( len - i >= 3 && strncmp( &cursor[i+1], "---", 3 ) == 0 ) if ( len - i >= 3 && strncmp( &cursor[i+1], "---", 3 ) == 0 )
flags |= SCAN_DOCSEP; flags |= SCAN_DOCSEP;
if ( cursor[i+1] == ' ' || cursor[i+1] == '\t' ) if ( cursor[i+1] == ' ' || cursor[i+1] == '\t' )
flags |= SCAN_INDENTED; flags |= SCAN_INDENTED;
if ( req_width > 0 && i - start > req_width ) if ( req_width > 0 && i - start > req_width )
flags |= SCAN_WIDE; flags |= SCAN_WIDE;
@ -618,12 +618,12 @@ syck_scan_scalar( int req_width, const char *cursor, long len )
} }
/* remember, if plain collections get implemented, to add nb-plain-flow-char */ /* remember, if plain collections get implemented, to add nb-plain-flow-char */
else if ( ( cursor[i] == ' ' && cursor[i+1] == '#' ) || else if ( ( cursor[i] == ' ' && cursor[i+1] == '#' ) ||
( cursor[i] == ':' && ( cursor[i] == ':' &&
( cursor[i+1] == ' ' || cursor[i+1] == '\n' || i == len - 1 ) ) ) ( cursor[i+1] == ' ' || cursor[i+1] == '\n' || i == len - 1 ) ) )
{ {
flags |= SCAN_INDIC_C; flags |= SCAN_INDIC_C;
} }
else if ( cursor[i] == ',' && else if ( cursor[i] == ',' &&
( cursor[i+1] == ' ' || cursor[i+1] == '\n' || i == len - 1 ) ) ( cursor[i+1] == ' ' || cursor[i+1] == '\n' || i == len - 1 ) )
{ {
flags |= SCAN_FLOWMAP; flags |= SCAN_FLOWMAP;
@ -647,12 +647,12 @@ void syck_emit_scalar( SyckEmitter *e, const char *tag, enum scalar_style force_
int scan = 0; int scan = 0;
const char *match_implicit; const char *match_implicit;
char *implicit; char *implicit;
if ( str == NULL ) str = ""; if ( str == NULL ) str = "";
/* No empty nulls as map keys */ /* No empty nulls as map keys */
if ( len == 0 && ( parent->status == syck_lvl_map || parent->status == syck_lvl_imap ) && if ( len == 0 && ( parent->status == syck_lvl_map || parent->status == syck_lvl_imap ) &&
parent->ncount % 2 == 1 && syck_tagcmp( tag, "tag:yaml.org,2002:null" ) == 0 ) parent->ncount % 2 == 1 && syck_tagcmp( tag, "tag:yaml.org,2002:null" ) == 0 )
{ {
str = "~"; str = "~";
len = 1; len = 1;
@ -668,8 +668,8 @@ void syck_emit_scalar( SyckEmitter *e, const char *tag, enum scalar_style force_
} else { } else {
/* complex key */ /* complex key */
if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 && if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 &&
( !( tag == NULL || ( !( tag == NULL ||
( implicit != NULL && syck_tagcmp( tag, implicit ) == 0 && e->explicit_typing == 0 ) ) ) ) ( implicit != NULL && syck_tagcmp( tag, implicit ) == 0 && e->explicit_typing == 0 ) ) ) )
{ {
syck_emitter_write( e, "? ", 2 ); syck_emitter_write( e, "? ", 2 );
parent->status = syck_lvl_mapx; parent->status = syck_lvl_mapx;

View file

@ -1216,7 +1216,7 @@ yyreduce:
case 8: case 8:
#line 76 "gram.y" #line 76 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1232,7 +1232,7 @@ yyreduce:
case 10: case 10:
#line 86 "gram.y" #line 86 "gram.y"
{ {
/* /*
* _Anchors_: The language binding must keep a separate symbol table * _Anchors_: The language binding must keep a separate symbol table
* for anchors. The actual ID in the symbol table is returned to the * for anchors. The actual ID in the symbol table is returned to the
@ -1266,7 +1266,7 @@ yyreduce:
case 16: case 16:
#line 114 "gram.y" #line 114 "gram.y"
{ {
if ( ((SyckParser *)parser)->implicit_typing == 1 ) if ( ((SyckParser *)parser)->implicit_typing == 1 )
{ {
try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
@ -1277,7 +1277,7 @@ yyreduce:
case 17: case 17:
#line 122 "gram.y" #line 122 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1293,7 +1293,7 @@ yyreduce:
case 19: case 19:
#line 132 "gram.y" #line 132 "gram.y"
{ {
/* /*
* _Anchors_: The language binding must keep a separate symbol table * _Anchors_: The language binding must keep a separate symbol table
* for anchors. The actual ID in the symbol table is returned to the * for anchors. The actual ID in the symbol table is returned to the
@ -1305,7 +1305,7 @@ yyreduce:
case 26: case 26:
#line 165 "gram.y" #line 165 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1313,7 +1313,7 @@ yyreduce:
case 27: case 27:
#line 170 "gram.y" #line 170 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1321,7 +1321,7 @@ yyreduce:
case 28: case 28:
#line 175 "gram.y" #line 175 "gram.y"
{ {
if ( ((SyckParser *)parser)->implicit_typing == 1 ) if ( ((SyckParser *)parser)->implicit_typing == 1 )
{ {
try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
@ -1332,7 +1332,7 @@ yyreduce:
case 29: case 29:
#line 183 "gram.y" #line 183 "gram.y"
{ {
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
} }
break; break;
@ -1350,7 +1350,7 @@ yyreduce:
case 31: case 31:
#line 195 "gram.y" #line 195 "gram.y"
{ {
SyckNode *n = yyvsp[0].nodeData; SyckNode *n = yyvsp[0].nodeData;
if ( ((SyckParser *)parser)->taguri_expansion == 1 ) if ( ((SyckParser *)parser)->taguri_expansion == 1 )
{ {
@ -1373,28 +1373,28 @@ yyreduce:
case 39: case 39:
#line 229 "gram.y" #line 229 "gram.y"
{ {
yyval.nodeData = yyvsp[-1].nodeData; yyval.nodeData = yyvsp[-1].nodeData;
} }
break; break;
case 40: case 40:
#line 233 "gram.y" #line 233 "gram.y"
{ {
yyval.nodeData = yyvsp[-1].nodeData; yyval.nodeData = yyvsp[-1].nodeData;
} }
break; break;
case 41: case 41:
#line 239 "gram.y" #line 239 "gram.y"
{ {
yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ); yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
} }
break; break;
case 42: case 42:
#line 245 "gram.y" #line 245 "gram.y"
{ {
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1402,7 +1402,7 @@ yyreduce:
case 43: case 43:
#line 250 "gram.y" #line 250 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1410,7 +1410,7 @@ yyreduce:
case 44: case 44:
#line 255 "gram.y" #line 255 "gram.y"
{ {
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 ); syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1418,7 +1418,7 @@ yyreduce:
case 45: case 45:
#line 260 "gram.y" #line 260 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1426,14 +1426,14 @@ yyreduce:
case 46: case 46:
#line 265 "gram.y" #line 265 "gram.y"
{ {
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData );
} }
break; break;
case 47: case 47:
#line 269 "gram.y" #line 269 "gram.y"
{ {
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
} }
break; break;
@ -1447,7 +1447,7 @@ yyreduce:
case 49: case 49:
#line 279 "gram.y" #line 279 "gram.y"
{ {
syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId ); syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId );
yyval.nodeData = yyvsp[-2].nodeData; yyval.nodeData = yyvsp[-2].nodeData;
} }
@ -1455,21 +1455,21 @@ yyreduce:
case 50: case 50:
#line 284 "gram.y" #line 284 "gram.y"
{ {
yyval.nodeData = yyvsp[-1].nodeData; yyval.nodeData = yyvsp[-1].nodeData;
} }
break; break;
case 51: case 51:
#line 293 "gram.y" #line 293 "gram.y"
{ {
yyval.nodeData = yyvsp[-1].nodeData; yyval.nodeData = yyvsp[-1].nodeData;
} }
break; break;
case 52: case 52:
#line 297 "gram.y" #line 297 "gram.y"
{ {
yyval.nodeData = syck_alloc_seq(); yyval.nodeData = syck_alloc_seq();
} }
break; break;
@ -1483,7 +1483,7 @@ yyreduce:
case 54: case 54:
#line 307 "gram.y" #line 307 "gram.y"
{ {
syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
yyval.nodeData = yyvsp[-2].nodeData; yyval.nodeData = yyvsp[-2].nodeData;
} }
@ -1491,7 +1491,7 @@ yyreduce:
case 57: case 57:
#line 321 "gram.y" #line 321 "gram.y"
{ {
apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData );
yyval.nodeData = yyvsp[-1].nodeData; yyval.nodeData = yyvsp[-1].nodeData;
} }
@ -1499,7 +1499,7 @@ yyreduce:
case 58: case 58:
#line 326 "gram.y" #line 326 "gram.y"
{ {
apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData );
yyval.nodeData = yyvsp[-1].nodeData; yyval.nodeData = yyvsp[-1].nodeData;
} }
@ -1507,7 +1507,7 @@ yyreduce:
case 59: case 59:
#line 333 "gram.y" #line 333 "gram.y"
{ {
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1515,7 +1515,7 @@ yyreduce:
case 60: case 60:
#line 338 "gram.y" #line 338 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1523,7 +1523,7 @@ yyreduce:
case 61: case 61:
#line 343 "gram.y" #line 343 "gram.y"
{ {
syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 ); syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1531,7 +1531,7 @@ yyreduce:
case 62: case 62:
#line 348 "gram.y" #line 348 "gram.y"
{ {
syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 ); syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
yyval.nodeData = yyvsp[0].nodeData; yyval.nodeData = yyvsp[0].nodeData;
} }
@ -1539,14 +1539,14 @@ yyreduce:
case 63: case 63:
#line 353 "gram.y" #line 353 "gram.y"
{ {
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData ); yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData );
} }
break; break;
case 64: case 64:
#line 357 "gram.y" #line 357 "gram.y"
{ {
yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData ); yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
} }
break; break;
@ -1561,8 +1561,8 @@ yyreduce:
case 68: case 68:
#line 380 "gram.y" #line 380 "gram.y"
{ {
yyval.nodeData = syck_new_map( yyval.nodeData = syck_new_map(
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
} }
break; break;
@ -1603,8 +1603,8 @@ yyreduce:
case 73: case 73:
#line 427 "gram.y" #line 427 "gram.y"
{ {
yyval.nodeData = syck_new_map( yyval.nodeData = syck_new_map(
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) ); syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
} }
break; break;
@ -1637,8 +1637,8 @@ yyreduce:
#line 455 "gram.y" #line 455 "gram.y"
{ {
NULL_NODE( parser, n ); NULL_NODE( parser, n );
yyval.nodeData = syck_new_map( yyval.nodeData = syck_new_map(
syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ), syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ),
syck_hdlr_add_node( (SyckParser *)parser, n ) ); syck_hdlr_add_node( (SyckParser *)parser, n ) );
} }
break; break;

View file

@ -9,12 +9,12 @@
#include "ruby/ruby.h" #include "ruby/ruby.h"
#include "syck.h" #include "syck.h"
SYMID SYMID
syck_hdlr_add_node( SyckParser *p, SyckNode *n ) syck_hdlr_add_node( SyckParser *p, SyckNode *n )
{ {
SYMID id; SYMID id;
if ( ! n->id ) if ( ! n->id )
{ {
n->id = (p->handler)( p, n ); n->id = (p->handler)( p, n );
} }
@ -89,7 +89,7 @@ syck_hdlr_get_anchor( SyckParser *p, char *a )
if ( st_lookup( p->anchors, (st_data_t)a, (void *)&n ) ) if ( st_lookup( p->anchors, (st_data_t)a, (void *)&n ) )
{ {
if ( n != (void *)1 ) if ( n != (void *)1 )
{ {
S_FREE( a ); S_FREE( a );
return n; return n;
} }
@ -116,7 +116,7 @@ syck_hdlr_get_anchor( SyckParser *p, char *a )
if ( n->anchor ) if ( n->anchor )
{ {
S_FREE( a ); S_FREE( a );
} }
else else
{ {
n->anchor = a; n->anchor = a;
@ -165,7 +165,7 @@ syck_taguri( const char *domain, const char *type_id, int type_len )
return uri; return uri;
} }
int int
syck_try_implicit( SyckNode *n ) syck_try_implicit( SyckNode *n )
{ {
return 1; return 1;

View file

@ -59,7 +59,7 @@ syck_alloc_map(void)
n = syck_alloc_node( syck_map_kind ); n = syck_alloc_node( syck_map_kind );
n->data.pairs = m; n->data.pairs = m;
return n; return n;
} }
@ -94,7 +94,7 @@ syck_alloc_str(void)
n = syck_alloc_node( syck_str_kind ); n = syck_alloc_node( syck_str_kind );
n->data.str = s; n->data.str = s;
return n; return n;
} }
@ -128,7 +128,7 @@ syck_replace_str( SyckNode *n, char *str, enum scalar_style style )
void void
syck_replace_str2( SyckNode *n, char *str, long len, enum scalar_style style ) syck_replace_str2( SyckNode *n, char *str, long len, enum scalar_style style )
{ {
if ( n->data.str->ptr != NULL ) if ( n->data.str->ptr != NULL )
{ {
S_FREE( n->data.str->ptr ); S_FREE( n->data.str->ptr );
n->data.str->ptr = NULL; n->data.str->ptr = NULL;
@ -201,7 +201,7 @@ syck_map_add( SyckNode *map, SYMID key, SYMID value )
ASSERT( map != NULL ); ASSERT( map != NULL );
ASSERT( map->data.pairs != NULL ); ASSERT( map->data.pairs != NULL );
m = map->data.pairs; m = map->data.pairs;
idx = m->idx; idx = m->idx;
m->idx += 1; m->idx += 1;
@ -226,7 +226,7 @@ syck_map_update( SyckNode *map1, SyckNode *map2 )
m1 = map1->data.pairs; m1 = map1->data.pairs;
m2 = map2->data.pairs; m2 = map2->data.pairs;
if ( m2->idx < 1 ) return; if ( m2->idx < 1 ) return;
new_idx = m1->idx; new_idx = m1->idx;
new_idx += m2->idx; new_idx += m2->idx;
new_capa = m1->capa; new_capa = m1->capa;
@ -242,8 +242,8 @@ syck_map_update( SyckNode *map1, SyckNode *map2 )
} }
for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ ) for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
{ {
m1->keys[m1->idx] = m2->keys[new_idx]; m1->keys[m1->idx] = m2->keys[new_idx];
m1->values[m1->idx] = m2->values[new_idx]; m1->values[m1->idx] = m2->values[new_idx];
} }
} }
@ -324,7 +324,7 @@ syck_seq_add( SyckNode *arr, SYMID value )
ASSERT( arr != NULL ); ASSERT( arr != NULL );
ASSERT( arr->data.list != NULL ); ASSERT( arr->data.list != NULL );
s = arr->data.list; s = arr->data.list;
idx = s->idx; idx = s->idx;
s->idx += 1; s->idx += 1;
@ -374,7 +374,7 @@ syck_free_members( SyckNode *n )
switch ( n->kind ) switch ( n->kind )
{ {
case syck_str_kind: case syck_str_kind:
if ( n->data.str != NULL ) if ( n->data.str != NULL )
{ {
S_FREE( n->data.str->ptr ); S_FREE( n->data.str->ptr );
n->data.str->ptr = NULL; n->data.str->ptr = NULL;

View file

@ -196,7 +196,7 @@ VALUE
syck_get_hash_aref(VALUE hsh, VALUE key) syck_get_hash_aref(VALUE hsh, VALUE key)
{ {
VALUE val = rb_hash_aref( hsh, key ); VALUE val = rb_hash_aref( hsh, key );
if ( NIL_P( val ) ) if ( NIL_P( val ) )
{ {
val = rb_hash_new(); val = rb_hash_new();
rb_hash_aset(hsh, key, val); rb_hash_aset(hsh, key, val);
@ -537,11 +537,11 @@ yaml_org_handler( SyckNode *n, VALUE *ref )
obj = rb_funcall( cDefaultKey, s_new, 0 ); obj = rb_funcall( cDefaultKey, s_new, 0 );
} }
else if ( n->data.str->style == scalar_plain && else if ( n->data.str->style == scalar_plain &&
n->data.str->len > 1 && n->data.str->len > 1 &&
strncmp( n->data.str->ptr, ":", 1 ) == 0 ) strncmp( n->data.str->ptr, ":", 1 ) == 0 )
{ {
obj = rb_funcall( oDefaultResolver, s_transfer, 2, obj = rb_funcall( oDefaultResolver, s_transfer, 2,
rb_str_new2( "tag:ruby.yaml.org,2002:sym" ), rb_str_new2( "tag:ruby.yaml.org,2002:sym" ),
rb_str_new( n->data.str->ptr + 1, n->data.str->len - 1 ) ); rb_str_new( n->data.str->ptr + 1, n->data.str->len - 1 ) );
} }
else if ( strcmp( type_id, "str" ) == 0 ) else if ( strcmp( type_id, "str" ) == 0 )
@ -644,7 +644,7 @@ rb_syck_load_handler(SyckParser *p, SyckNode *n)
} }
/* /*
* Create node, * Create node,
*/ */
obj = rb_funcall( resolver, s_node_import, 1, Data_Wrap_Struct( cNode, NULL, NULL, n ) ); obj = rb_funcall( resolver, s_node_import, 1, Data_Wrap_Struct( cNode, NULL, NULL, n ) );
@ -680,8 +680,8 @@ rb_syck_err_handler(SyckParser *p, const char *msg)
rb_raise(rb_eArgError, "%s on line %d, col %"PRIdPTRDIFF": `%s'", rb_raise(rb_eArgError, "%s on line %d, col %"PRIdPTRDIFF": `%s'",
msg, msg,
p->linect, p->linect,
p->cursor - p->lineptr, p->cursor - p->lineptr,
p->lineptr); p->lineptr);
} }
/* /*
@ -715,7 +715,7 @@ syck_set_model(VALUE p, VALUE input, VALUE model)
if ( NIL_P( input ) ) if ( NIL_P( input ) )
{ {
input = rb_ivar_get( p, s_input ); input = rb_ivar_get( p, s_input );
} }
if ( input == sym_bytecode ) if ( input == sym_bytecode )
{ {
@ -773,7 +773,7 @@ rb_syck_free_parser(SyckParser *p)
* YAML::Syck::Parser.allocate * YAML::Syck::Parser.allocate
*/ */
VALUE syck_parser_s_alloc _((VALUE)); VALUE syck_parser_s_alloc _((VALUE));
VALUE VALUE
syck_parser_s_alloc(VALUE class) syck_parser_s_alloc(VALUE class)
{ {
VALUE pobj; VALUE pobj;
@ -880,7 +880,7 @@ syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model ); model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
Data_Get_Struct(self, SyckParser, parser); Data_Get_Struct(self, SyckParser, parser);
syck_set_model( self, input, model ); syck_set_model( self, input, model );
bonus = (struct parser_xtra *)parser->bonus; bonus = (struct parser_xtra *)parser->bonus;
bonus->taint = syck_parser_assign_io(parser, &port); bonus->taint = syck_parser_assign_io(parser, &port);
bonus->resolver = rb_attr_get( self, s_resolver ); bonus->resolver = rb_attr_get( self, s_resolver );
@ -947,7 +947,7 @@ syck_resolver_use_types_at(VALUE self, VALUE hsh)
} }
/* /*
* YAML::Syck::Resolver#detect_implicit * YAML::Syck::Resolver#detect_implicit
*/ */
VALUE VALUE
syck_resolver_detect_implicit(VALUE self, VALUE val) syck_resolver_detect_implicit(VALUE self, VALUE val)
@ -1075,7 +1075,7 @@ syck_const_find(VALUE const_name)
VALUE VALUE
syck_resolver_transfer(VALUE self, VALUE type, VALUE val) syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
{ {
if (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) if (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0)
{ {
type = rb_funcall( self, s_detect_implicit, 1, val ); type = rb_funcall( self, s_detect_implicit, 1, val );
} }
@ -1123,7 +1123,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
subclass = rb_funcall( target_class, s_tag_read_class, 1, subclass ); subclass = rb_funcall( target_class, s_tag_read_class, 1, subclass );
subclass_v = syck_const_find( subclass ); subclass_v = syck_const_find( subclass );
if ( subclass_v != Qnil ) if ( subclass_v != Qnil )
{ {
subclass = subclass_v; subclass = subclass_v;
} }
@ -1177,7 +1177,7 @@ syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
rb_block_call( val, s_each, 0, 0, syck_set_ivars, obj ); rb_block_call( val, s_each, 0, 0, syck_set_ivars, obj );
} }
} }
else else
{ {
VALUE parts = rb_str_split( type, ":" ); VALUE parts = rb_str_split( type, ":" );
VALUE scheme = rb_ary_shift( parts ); VALUE scheme = rb_ary_shift( parts );
@ -1219,7 +1219,7 @@ syck_resolver_tagurize(VALUE self, VALUE val)
} }
/* /*
* YAML::Syck::DefaultResolver#detect_implicit * YAML::Syck::DefaultResolver#detect_implicit
*/ */
VALUE VALUE
syck_defaultresolver_detect_implicit(VALUE self, VALUE val) syck_defaultresolver_detect_implicit(VALUE self, VALUE val)
@ -1278,19 +1278,19 @@ syck_genericresolver_node_import(VALUE self, VALUE node)
if ( n->data.str->style == scalar_1quote ) if ( n->data.str->style == scalar_1quote )
{ {
style = sym_1quote; style = sym_1quote;
} }
else if ( n->data.str->style == scalar_2quote ) else if ( n->data.str->style == scalar_2quote )
{ {
style = sym_2quote; style = sym_2quote;
} }
else if ( n->data.str->style == scalar_fold ) else if ( n->data.str->style == scalar_fold )
{ {
style = sym_fold; style = sym_fold;
} }
else if ( n->data.str->style == scalar_literal ) else if ( n->data.str->style == scalar_literal )
{ {
style = sym_literal; style = sym_literal;
} }
else if ( n->data.str->style == scalar_plain ) else if ( n->data.str->style == scalar_plain )
{ {
style = sym_plain; style = sym_plain;
@ -1308,7 +1308,7 @@ syck_genericresolver_node_import(VALUE self, VALUE node)
if ( n->data.list->style == seq_inline ) if ( n->data.list->style == seq_inline )
{ {
style = sym_inline; style = sym_inline;
} }
obj = rb_funcall( cSeq, s_new, 3, t, v, style ); obj = rb_funcall( cSeq, s_new, 3, t, v, style );
rb_iv_set(obj, "@kind", sym_seq); rb_iv_set(obj, "@kind", sym_seq);
break; break;
@ -1322,7 +1322,7 @@ syck_genericresolver_node_import(VALUE self, VALUE node)
if ( n->data.pairs->style == map_inline ) if ( n->data.pairs->style == map_inline )
{ {
style = sym_inline; style = sym_inline;
} }
obj = rb_funcall( cMap, s_new, 3, t, v, style ); obj = rb_funcall( cMap, s_new, 3, t, v, style );
rb_iv_set(obj, "@kind", sym_map); rb_iv_set(obj, "@kind", sym_map);
break; break;
@ -1347,8 +1347,8 @@ syck_badalias_initialize(VALUE self, VALUE val)
VALUE VALUE
syck_badalias_cmp(VALUE alias1, VALUE alias2) syck_badalias_cmp(VALUE alias1, VALUE alias2)
{ {
VALUE str1 = rb_ivar_get( alias1, s_name ); VALUE str1 = rb_ivar_get( alias1, s_name );
VALUE str2 = rb_ivar_get( alias2, s_name ); VALUE str2 = rb_ivar_get( alias2, s_name );
VALUE val = rb_funcall( str1, s_cmp, 1, str2 ); VALUE val = rb_funcall( str1, s_cmp, 1, str2 );
return val; return val;
} }
@ -1459,23 +1459,23 @@ syck_scalar_style_set(VALUE self, VALUE style)
if ( NIL_P( style ) ) if ( NIL_P( style ) )
{ {
node->data.str->style = scalar_none; node->data.str->style = scalar_none;
} }
else if ( style == sym_1quote ) else if ( style == sym_1quote )
{ {
node->data.str->style = scalar_1quote; node->data.str->style = scalar_1quote;
} }
else if ( style == sym_2quote ) else if ( style == sym_2quote )
{ {
node->data.str->style = scalar_2quote; node->data.str->style = scalar_2quote;
} }
else if ( style == sym_fold ) else if ( style == sym_fold )
{ {
node->data.str->style = scalar_fold; node->data.str->style = scalar_fold;
} }
else if ( style == sym_literal ) else if ( style == sym_literal )
{ {
node->data.str->style = scalar_literal; node->data.str->style = scalar_literal;
} }
else if ( style == sym_plain ) else if ( style == sym_plain )
{ {
node->data.str->style = scalar_plain; node->data.str->style = scalar_plain;
@ -1587,7 +1587,7 @@ syck_seq_style_set(VALUE self, VALUE style)
if ( style == sym_inline ) if ( style == sym_inline )
{ {
node->data.list->style = seq_inline; node->data.list->style = seq_inline;
} }
else else
{ {
node->data.list->style = seq_none; node->data.list->style = seq_none;
@ -1709,7 +1709,7 @@ syck_map_style_set(VALUE self, VALUE style)
if ( style == sym_inline ) if ( style == sym_inline )
{ {
node->data.pairs->style = map_inline; node->data.pairs->style = map_inline;
} }
else else
{ {
node->data.pairs->style = map_none; node->data.pairs->style = map_none;
@ -1865,7 +1865,7 @@ rb_syck_emitter_handler(SyckEmitter *e, st_data_t data)
/* /*
* Handle output from the emitter * Handle output from the emitter
*/ */
void void
rb_syck_output_handler(SyckEmitter * emitter, char *str, long len) rb_syck_output_handler(SyckEmitter * emitter, char *str, long len)
{ {
struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus; struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus;
@ -1921,7 +1921,7 @@ rb_syck_free_emitter(SyckEmitter *e)
* YAML::Syck::Emitter.allocate * YAML::Syck::Emitter.allocate
*/ */
VALUE syck_emitter_s_alloc _((VALUE)); VALUE syck_emitter_s_alloc _((VALUE));
VALUE VALUE
syck_emitter_s_alloc(VALUE class) syck_emitter_s_alloc(VALUE class)
{ {
VALUE pobj; VALUE pobj;
@ -1982,7 +1982,7 @@ syck_emitter_reset(int argc, VALUE *argv, VALUE self)
Check_Type(options, T_HASH); Check_Type(options, T_HASH);
rb_ivar_set(self, s_options, options); rb_ivar_set(self, s_options, options);
} }
emitter->headless = 0; emitter->headless = 0;
rb_ivar_set(self, s_level, INT2FIX(0)); rb_ivar_set(self, s_level, INT2FIX(0));
rb_ivar_set(self, s_resolver, Qnil); rb_ivar_set(self, s_resolver, Qnil);
@ -2018,14 +2018,14 @@ syck_emitter_emit(int argc, VALUE *argv, VALUE self)
/* Second pass, build emitted string */ /* Second pass, build emitted string */
level -= 1; level -= 1;
rb_ivar_set(self, s_level, INT2FIX(level)); rb_ivar_set(self, s_level, INT2FIX(level));
if ( level == 0 ) if ( level == 0 )
{ {
syck_emit(emitter, (st_data_t)symple); syck_emit(emitter, (st_data_t)symple);
syck_emitter_flush(emitter, 0); syck_emitter_flush(emitter, 0);
return bonus->port; return bonus->port;
} }
return symple; return symple;
} }

View file

@ -17,7 +17,7 @@ void syck_parser_pop_level( SyckParser * );
/* /*
* Custom assert * Custom assert
*/ */
void void
syck_assert( const char *file_name, unsigned line_num, const char *expr ) syck_assert( const char *file_name, unsigned line_num, const char *expr )
{ {
fflush( NULL ); fflush( NULL );
@ -160,7 +160,7 @@ syck_new_parser(void)
p = S_ALLOC( SyckParser ); p = S_ALLOC( SyckParser );
S_MEMZERO( p, SyckParser, 1 ); S_MEMZERO( p, SyckParser, 1 );
p->lvl_capa = ALLOC_CT; p->lvl_capa = ALLOC_CT;
p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa ); p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa );
p->input_type = syck_yaml_utf8; p->input_type = syck_yaml_utf8;
p->io_type = syck_io_str; p->io_type = syck_io_str;
p->io.str = NULL; p->io.str = NULL;
@ -378,7 +378,7 @@ syck_parser_pop_level( SyckParser *p )
free( p->levels[p->lvl_idx].domain ); free( p->levels[p->lvl_idx].domain );
} }
void void
syck_parser_add_level( SyckParser *p, int len, enum syck_level_status status ) syck_parser_add_level( SyckParser *p, int len, enum syck_level_status status )
{ {
ASSERT( p != NULL ); ASSERT( p != NULL );
@ -403,7 +403,7 @@ free_any_io( SyckParser *p )
switch ( p->io_type ) switch ( p->io_type )
{ {
case syck_io_str: case syck_io_str:
if ( p->io.str != NULL ) if ( p->io.str != NULL )
{ {
S_FREE( p->io.str ); S_FREE( p->io.str );
p->io.str = NULL; p->io.str = NULL;
@ -411,7 +411,7 @@ free_any_io( SyckParser *p )
break; break;
case syck_io_file: case syck_io_file:
if ( p->io.file != NULL ) if ( p->io.file != NULL )
{ {
S_FREE( p->io.file ); S_FREE( p->io.file );
p->io.file = NULL; p->io.file = NULL;
@ -516,7 +516,7 @@ syck_parse( SyckParser *p )
void void
syck_default_error_handler( SyckParser *p, const char *msg ) syck_default_error_handler( SyckParser *p, const char *msg )
{ {
printf( "Error at [Line %d, Col %"PRIdPTRDIFF"]: %s\n", printf( "Error at [Line %d, Col %"PRIdPTRDIFF"]: %s\n",
p->linect, p->linect,
p->cursor - p->lineptr, p->cursor - p->lineptr,
msg ); msg );

View file

@ -153,7 +153,7 @@ typedef struct _syck_level SyckLevel;
typedef SYMID (*SyckNodeHandler)(SyckParser *, SyckNode *); typedef SYMID (*SyckNodeHandler)(SyckParser *, SyckNode *);
typedef void (*SyckErrorHandler)(SyckParser *, const char *); typedef void (*SyckErrorHandler)(SyckParser *, const char *);
typedef SyckNode * (*SyckBadAnchorHandler)(SyckParser *, char *); typedef SyckNode * (*SyckBadAnchorHandler)(SyckParser *, char *);
typedef long (*SyckIoFileRead)(char *, SyckIoFile *, long, long); typedef long (*SyckIoFileRead)(char *, SyckIoFile *, long, long);
typedef long (*SyckIoStrRead)(char *, SyckIoStr *, long, long); typedef long (*SyckIoStrRead)(char *, SyckIoStr *, long, long);
enum syck_io_type { enum syck_io_type {
@ -205,7 +205,7 @@ struct _syck_str {
struct _syck_level { struct _syck_level {
/* Indent */ /* Indent */
int spaces; int spaces;
/* Counts nodes emitted at this level, useful for parsing /* Counts nodes emitted at this level, useful for parsing
* keys and pairs in bytecode */ * keys and pairs in bytecode */
int ncount; int ncount;
/* Does node have anchors or tags? */ /* Does node have anchors or tags? */
@ -265,8 +265,8 @@ struct _syck_parser {
typedef struct _syck_emitter SyckEmitter; typedef struct _syck_emitter SyckEmitter;
typedef struct _syck_emitter_node SyckEmitterNode; typedef struct _syck_emitter_node SyckEmitterNode;
typedef void (*SyckOutputHandler)(SyckEmitter *, char *, long); typedef void (*SyckOutputHandler)(SyckEmitter *, char *, long);
typedef void (*SyckEmitterHandler)(SyckEmitter *, st_data_t); typedef void (*SyckEmitterHandler)(SyckEmitter *, st_data_t);
enum doc_stage { enum doc_stage {
doc_open, doc_open,

View file

@ -70,7 +70,7 @@
if ( reset == 1 ) YYPOS(0); \ if ( reset == 1 ) YYPOS(0); \
return YAML_IOPEN; \ return YAML_IOPEN; \
} \ } \
} }
/* /*
* Nice little macro to ensure closure of levels. * Nice little macro to ensure closure of levels.
@ -278,7 +278,7 @@ sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser )
{ {
int doc_level = 0; int doc_level = 0;
syck_parser_ptr = parser; syck_parser_ptr = parser;
if ( YYCURSOR == NULL ) if ( YYCURSOR == NULL )
{ {
syck_parser_read( parser ); syck_parser_read( parser );
} }
@ -331,7 +331,7 @@ yy2: yyaccept = 0;
yy3: yy3:
#line 374 "token.re" #line 374 "token.re"
{ YYPOS(0); { YYPOS(0);
goto Document; goto Document;
} }
#line 337 "<stdout>" #line 337 "<stdout>"
yy4: yyaccept = 0; yy4: yyaccept = 0;
@ -344,7 +344,7 @@ yy5: ++YYCURSOR;
goto yy6; goto yy6;
yy6: yy6:
#line 356 "token.re" #line 356 "token.re"
{ eat_comments( parser ); { eat_comments( parser );
goto Header; goto Header;
} }
#line 351 "<stdout>" #line 351 "<stdout>"
@ -355,7 +355,7 @@ yy8:
{ SyckLevel *lvl = CURRENT_LEVEL(); { SyckLevel *lvl = CURRENT_LEVEL();
ENSURE_YAML_IEND(lvl, -1); ENSURE_YAML_IEND(lvl, -1);
YYPOS(0); YYPOS(0);
return 0; return 0;
} }
#line 361 "<stdout>" #line 361 "<stdout>"
yy9: yyaccept = 1; yy9: yyaccept = 1;
@ -364,7 +364,7 @@ yy9: yyaccept = 1;
yy10: yy10:
#line 366 "token.re" #line 366 "token.re"
{ GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN ); { GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN );
goto Header; goto Header;
} }
#line 370 "<stdout>" #line 370 "<stdout>"
yy11: yych = *++YYCURSOR; yy11: yych = *++YYCURSOR;
@ -432,15 +432,15 @@ yy24:
{ SyckLevel *lvl = CURRENT_LEVEL(); { SyckLevel *lvl = CURRENT_LEVEL();
if ( lvl->status == syck_lvl_header ) if ( lvl->status == syck_lvl_header )
{ {
goto Header; goto Header;
} }
else else
{ {
ENSURE_YAML_IEND(lvl, -1); ENSURE_YAML_IEND(lvl, -1);
YYPOS(0); YYPOS(0);
return 0; return 0;
} }
return 0; return 0;
} }
#line 446 "<stdout>" #line 446 "<stdout>"
yy25: ++YYCURSOR; yy25: ++YYCURSOR;
@ -476,13 +476,13 @@ yy31:
if ( lvl->status == syck_lvl_header ) if ( lvl->status == syck_lvl_header )
{ {
YYPOS(3); YYPOS(3);
goto Directive; goto Directive;
} }
else else
{ {
ENSURE_YAML_IEND(lvl, -1); ENSURE_YAML_IEND(lvl, -1);
YYPOS(0); YYPOS(0);
return 0; return 0;
} }
} }
#line 489 "<stdout>" #line 489 "<stdout>"
@ -583,7 +583,7 @@ yy39: ++YYCURSOR;
yy40: yy40:
#line 497 "token.re" #line 497 "token.re"
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1); { ENSURE_YAML_IOPEN(lvl, doc_level, 1);
goto Plain; goto Plain;
} }
#line 589 "<stdout>" #line 589 "<stdout>"
yy41: ++YYCURSOR; yy41: ++YYCURSOR;
@ -593,7 +593,7 @@ yy42:
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1); { ENSURE_YAML_IOPEN(lvl, doc_level, 1);
lvl = CURRENT_LEVEL(); lvl = CURRENT_LEVEL();
ADD_LEVEL(lvl->spaces + 1, syck_lvl_iseq); ADD_LEVEL(lvl->spaces + 1, syck_lvl_iseq);
return YYTOKEN[0]; return YYTOKEN[0];
} }
#line 599 "<stdout>" #line 599 "<stdout>"
yy43: ++YYCURSOR; yy43: ++YYCURSOR;
@ -603,7 +603,7 @@ yy44:
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1); { ENSURE_YAML_IOPEN(lvl, doc_level, 1);
lvl = CURRENT_LEVEL(); lvl = CURRENT_LEVEL();
ADD_LEVEL(lvl->spaces + 1, syck_lvl_imap); ADD_LEVEL(lvl->spaces + 1, syck_lvl_imap);
return YYTOKEN[0]; return YYTOKEN[0];
} }
#line 609 "<stdout>" #line 609 "<stdout>"
yy45: ++YYCURSOR; yy45: ++YYCURSOR;
@ -611,7 +611,7 @@ yy45: ++YYCURSOR;
yy46: yy46:
#line 432 "token.re" #line 432 "token.re"
{ POP_LEVEL(); { POP_LEVEL();
return YYTOKEN[0]; return YYTOKEN[0];
} }
#line 617 "<stdout>" #line 617 "<stdout>"
yy47: yyaccept = 1; yy47: yyaccept = 1;
@ -800,7 +800,7 @@ yy58: ++YYCURSOR;
goto yy59; goto yy59;
yy59: yy59:
#line 486 "token.re" #line 486 "token.re"
{ eat_comments( parser ); { eat_comments( parser );
goto Document; goto Document;
} }
#line 807 "<stdout>" #line 807 "<stdout>"
@ -817,7 +817,7 @@ yy63:
#line 492 "token.re" #line 492 "token.re"
{ ENSURE_YAML_IEND(lvl, -1); { ENSURE_YAML_IEND(lvl, -1);
YYPOS(0); YYPOS(0);
return 0; return 0;
} }
#line 823 "<stdout>" #line 823 "<stdout>"
yy64: yych = *++YYCURSOR; yy64: yych = *++YYCURSOR;
@ -859,11 +859,11 @@ yy70: ++YYCURSOR;
goto yy71; goto yy71;
yy71: yy71:
#line 479 "token.re" #line 479 "token.re"
{ if ( is_newline( YYCURSOR - 1 ) ) { if ( is_newline( YYCURSOR - 1 ) )
{ {
YYCURSOR--; YYCURSOR--;
} }
goto ScalarBlock; goto ScalarBlock;
} }
#line 869 "<stdout>" #line 869 "<stdout>"
yy72: ++YYCURSOR; yy72: ++YYCURSOR;
@ -1041,14 +1041,14 @@ yy82:
FORCE_NEXT_TOKEN(YAML_IOPEN); FORCE_NEXT_TOKEN(YAML_IOPEN);
if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) ) if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) )
{ {
YYCURSOR--; YYCURSOR--;
ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_seq); ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_seq);
} }
else /* spaces followed by content uses the space as indentation */ else /* spaces followed by content uses the space as indentation */
{ {
ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_seq); ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_seq);
} }
return YYTOKEN[0]; return YYTOKEN[0];
} }
#line 1054 "<stdout>" #line 1054 "<stdout>"
yy83: ++YYCURSOR; yy83: ++YYCURSOR;
@ -1069,8 +1069,8 @@ yy86: ++YYCURSOR;
yy87: yy87:
#line 436 "token.re" #line 436 "token.re"
{ if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap ) lvl->status = syck_lvl_map; { if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap ) lvl->status = syck_lvl_map;
YYPOS(1); YYPOS(1);
return YYTOKEN[0]; return YYTOKEN[0];
} }
#line 1076 "<stdout>" #line 1076 "<stdout>"
yy88: ++YYCURSOR; yy88: ++YYCURSOR;
@ -1499,7 +1499,7 @@ Plain:
plvl = CURRENT_LEVEL(); plvl = CURRENT_LEVEL();
GET_TRUE_YAML_INDENT(parentIndent); GET_TRUE_YAML_INDENT(parentIndent);
Plain2: Plain2:
YYTOKEN = YYCURSOR; YYTOKEN = YYCURSOR;
Plain3: Plain3:
@ -1564,7 +1564,7 @@ yy113:
} }
} }
goto Plain2; goto Plain2;
} }
#line 1570 "<stdout>" #line 1570 "<stdout>"
yy114: ++YYCURSOR; yy114: ++YYCURSOR;
@ -1631,13 +1631,13 @@ yy122: ++YYCURSOR;
} }
yy123: yy123:
#line 617 "token.re" #line 617 "token.re"
{ if ( qidx == 0 ) { if ( qidx == 0 )
{ {
goto Plain2; goto Plain2;
} }
else else
{ {
goto Plain3; goto Plain3;
} }
} }
#line 1644 "<stdout>" #line 1644 "<stdout>"
@ -1655,7 +1655,7 @@ yy128: ++YYCURSOR;
goto yy129; goto yy129;
yy129: yy129:
#line 611 "token.re" #line 611 "token.re"
{ eat_comments( parser ); { eat_comments( parser );
RETURN_IMPLICIT(); RETURN_IMPLICIT();
} }
#line 1662 "<stdout>" #line 1662 "<stdout>"
@ -1801,7 +1801,7 @@ yy147:
} }
} }
goto SingleQuote2; goto SingleQuote2;
} }
#line 1807 "<stdout>" #line 1807 "<stdout>"
yy148: ++YYCURSOR; yy148: ++YYCURSOR;
@ -1811,8 +1811,8 @@ yy148: ++YYCURSOR;
} }
yy149: yy149:
#line 712 "token.re" #line 712 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto SingleQuote2; goto SingleQuote2;
} }
#line 1818 "<stdout>" #line 1818 "<stdout>"
yy150: ++YYCURSOR; yy150: ++YYCURSOR;
@ -1842,7 +1842,7 @@ yy151:
n->data.str->len = qidx; n->data.str->len = qidx;
n->data.str->style = scalar_1quote; n->data.str->style = scalar_1quote;
sycklval->nodeData = n; sycklval->nodeData = n;
return YAML_PLAIN; return YAML_PLAIN;
} }
#line 1848 "<stdout>" #line 1848 "<stdout>"
yy152: yych = *++YYCURSOR; yy152: yych = *++YYCURSOR;
@ -1854,7 +1854,7 @@ yy154: ++YYCURSOR;
yy155: yy155:
#line 685 "token.re" #line 685 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, '\''); { QUOTECAT(qstr, qcapa, qidx, '\'');
goto SingleQuote2; goto SingleQuote2;
} }
#line 1860 "<stdout>" #line 1860 "<stdout>"
yy156: yyaccept = 0; yy156: yyaccept = 0;
@ -1960,7 +1960,7 @@ yy163:
} }
keep_nl = 1; keep_nl = 1;
goto DoubleQuote2; goto DoubleQuote2;
} }
#line 1966 "<stdout>" #line 1966 "<stdout>"
yy164: ++YYCURSOR; yy164: ++YYCURSOR;
@ -1970,8 +1970,8 @@ yy164: ++YYCURSOR;
} }
yy165: yy165:
#line 820 "token.re" #line 820 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto DoubleQuote2; goto DoubleQuote2;
} }
#line 1977 "<stdout>" #line 1977 "<stdout>"
yy166: yyaccept = 1; yy166: yyaccept = 1;
@ -2010,7 +2010,7 @@ yy168:
n->data.str->len = qidx; n->data.str->len = qidx;
n->data.str->style = scalar_2quote; n->data.str->style = scalar_2quote;
sycklval->nodeData = n; sycklval->nodeData = n;
return YAML_PLAIN; return YAML_PLAIN;
} }
#line 2016 "<stdout>" #line 2016 "<stdout>"
yy169: yych = *++YYCURSOR; yy169: yych = *++YYCURSOR;
@ -2038,7 +2038,7 @@ yy175:
#line 792 "token.re" #line 792 "token.re"
{ keep_nl = 0; { keep_nl = 0;
YYCURSOR--; YYCURSOR--;
goto DoubleQuote2; goto DoubleQuote2;
} }
#line 2044 "<stdout>" #line 2044 "<stdout>"
yy176: yych = *++YYCURSOR; yy176: yych = *++YYCURSOR;
@ -2076,7 +2076,7 @@ yy179:
#line 778 "token.re" #line 778 "token.re"
{ char ch = *( YYCURSOR - 1 ); { char ch = *( YYCURSOR - 1 );
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
goto DoubleQuote2; goto DoubleQuote2;
} }
#line 2082 "<stdout>" #line 2082 "<stdout>"
yy180: yych = *++YYCURSOR; yy180: yych = *++YYCURSOR;
@ -2113,7 +2113,7 @@ yy182:
ch = strtol( chr_text, NULL, 16 ); ch = strtol( chr_text, NULL, 16 );
free( chr_text ); free( chr_text );
QUOTECAT(qstr, qcapa, qidx, ch); QUOTECAT(qstr, qcapa, qidx, ch);
goto DoubleQuote2; goto DoubleQuote2;
} }
#line 2119 "<stdout>" #line 2119 "<stdout>"
yy183: yyaccept = 0; yy183: yyaccept = 0;
@ -2216,7 +2216,7 @@ yy189:
} }
} }
return YAML_TRANSFER; return YAML_TRANSFER;
} }
#line 2222 "<stdout>" #line 2222 "<stdout>"
yy190: yych = *++YYCURSOR; yy190: yych = *++YYCURSOR;
@ -2230,7 +2230,7 @@ yy192: ++YYCURSOR;
} }
yy193: yy193:
#line 905 "token.re" #line 905 "token.re"
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
goto TransferMethod2; goto TransferMethod2;
} }
#line 2237 "<stdout>" #line 2237 "<stdout>"
@ -2505,7 +2505,7 @@ yy214:
#line 1046 "token.re" #line 1046 "token.re"
{ YYCURSOR--; { YYCURSOR--;
POP_LEVEL(); POP_LEVEL();
RETURN_YAML_BLOCK(); RETURN_YAML_BLOCK();
} }
#line 2511 "<stdout>" #line 2511 "<stdout>"
yy215: yyaccept = 1; yy215: yyaccept = 1;
@ -2636,7 +2636,7 @@ yy233: ++YYCURSOR;
} }
yy234: yy234:
#line 1095 "token.re" #line 1095 "token.re"
{ goto Comment; { goto Comment;
} }
#line 2642 "<stdout>" #line 2642 "<stdout>"
yy235: yych = *++YYCURSOR; yy235: yych = *++YYCURSOR;
@ -2699,20 +2699,20 @@ newline_len( char *ptr )
{ {
if ( *ptr == '\n' ) if ( *ptr == '\n' )
return 1; return 1;
if ( *ptr == '\r' && *( ptr + 1 ) == '\n' ) if ( *ptr == '\r' && *( ptr + 1 ) == '\n' )
return 2; return 2;
return 0; return 0;
} }
int int
syckwrap() syckwrap()
{ {
return 1; return 1;
} }
void void
syckerror( const char *msg ) syckerror( const char *msg )
{ {
if ( syck_parser_ptr->error_handler == NULL ) if ( syck_parser_ptr->error_handler == NULL )

View file

@ -7,7 +7,7 @@
* *
* WARNING WARNING WARNING --- THIS IS *NOT JUST* PLAYING * WARNING WARNING WARNING --- THIS IS *NOT JUST* PLAYING
* ANYMORE! -- WHY HAS EMBRACED THIS AS THE REAL THING! * ANYMORE! -- WHY HAS EMBRACED THIS AS THE REAL THING!
*/ */
#include "ruby/ruby.h" #include "ruby/ruby.h"
#include <syck.h> #include <syck.h>
#include <assert.h> #include <assert.h>
@ -35,7 +35,7 @@ typedef struct {
int printed; int printed;
} bytestring_t; } bytestring_t;
bytestring_t *bytestring_alloc(void) { bytestring_t *bytestring_alloc(void) {
bytestring_t *ret; bytestring_t *ret;
/*TRACE0("bytestring_alloc()");*/ /*TRACE0("bytestring_alloc()");*/
ret = S_ALLOC(bytestring_t); ret = S_ALLOC(bytestring_t);
ret->hash = HASH; ret->hash = HASH;
@ -46,8 +46,8 @@ bytestring_t *bytestring_alloc(void) {
ret->printed = 0; ret->printed = 0;
return ret; return ret;
} }
void bytestring_append(bytestring_t *str, char code, void bytestring_append(bytestring_t *str, char code,
char *start, char *finish) char *start, char *finish)
{ {
long grow; long grow;
long length = 2; /* CODE + LF */ long length = 2; /* CODE + LF */
@ -62,14 +62,14 @@ void bytestring_append(bytestring_t *str, char code,
if(length > str->remaining) { if(length > str->remaining) {
grow = (length - str->remaining) + CHUNKSIZE; grow = (length - str->remaining) + CHUNKSIZE;
str->remaining += grow; str->remaining += grow;
str->length += grow; str->length += grow;
str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 ); str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 );
assert(str->buffer); assert(str->buffer);
} }
curr = str->buffer + (str->length - str->remaining); curr = str->buffer + (str->length - str->remaining);
*curr = code; *curr = code;
curr += 1; curr += 1;
if(start) if(start)
while(start < finish) while(start < finish)
*curr ++ = *start ++; *curr ++ = *start ++;
*curr = '\n'; *curr = '\n';
@ -99,7 +99,7 @@ void bytestring_extend(bytestring_t *str, bytestring_t *ext)
if(length > str->remaining) { if(length > str->remaining) {
grow = (length - str->remaining) + CHUNKSIZE; grow = (length - str->remaining) + CHUNKSIZE;
str->remaining += grow; str->remaining += grow;
str->length += grow; str->length += grow;
str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 ); str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 );
} }
curr = str->buffer + (str->length - str->remaining); curr = str->buffer + (str->length - str->remaining);
@ -176,7 +176,7 @@ syck_yaml2byte_handler(p, n)
{ {
bytestring_append(val,YAMLBYTE_NULLCHAR,NULL,NULL); bytestring_append(val,YAMLBYTE_NULLCHAR,NULL,NULL);
} }
else else
{ {
assert("oops"); assert("oops");
} }

View file

@ -83,11 +83,11 @@ typedef enum {
YAMLBYTE_E_OTHER = '?', /* some other error condition */ YAMLBYTE_E_OTHER = '?', /* some other error condition */
YAMLBYTE_E_PARSE = 'P', /* parse error, check bytecodes */ YAMLBYTE_E_PARSE = 'P', /* parse error, check bytecodes */
} yamlbyte_result_t; } yamlbyte_result_t;
typedef const yamlbyte_char_t *yamlbyte_buff_t;
/* typedef const yamlbyte_char_t *yamlbyte_buff_t;
* The "Instruction" API
/*
* The "Instruction" API
*/ */
typedef struct yaml_instruction { typedef struct yaml_instruction {
@ -96,7 +96,7 @@ typedef struct yaml_instruction {
yamlbyte_buff_t finish; /* open range, *finish is _not_ part */ yamlbyte_buff_t finish; /* open range, *finish is _not_ part */
} *yamlbyte_inst_t; } *yamlbyte_inst_t;
/* producer pushes the instruction with one bytecode event to the /* producer pushes the instruction with one bytecode event to the
* consumer; if the consumer's result is not YAMLBYTE_OK, then * consumer; if the consumer's result is not YAMLBYTE_OK, then
* the producer should stop */ * the producer should stop */
typedef typedef
@ -110,14 +110,14 @@ typedef
* case the instruction (and is buffer) are owned by the producer and * case the instruction (and is buffer) are owned by the producer and
* will remain valid till the pull function is called once again; * will remain valid till the pull function is called once again;
* if the instruction is NULL, then there are no more results; and * if the instruction is NULL, then there are no more results; and
* it is important to call the pull function till it returns NULL so * it is important to call the pull function till it returns NULL so
* that the producer can clean up its memory allocations */ * that the producer can clean up its memory allocations */
typedef typedef
yamlbyte_result_t yamlbyte_result_t
(*yamlbyte_pull_t)( (*yamlbyte_pull_t)(
yamlbyte_producer_t self, yamlbyte_producer_t self,
yamlbyte_inst_t *inst /* to be filled in by the producer */ yamlbyte_inst_t *inst /* to be filled in by the producer */
); );
/* /*
* Buffer based API * Buffer based API
@ -139,12 +139,12 @@ typedef
* is set to NULL, then there are no more results; it is important * is set to NULL, then there are no more results; it is important
* to call the pull function till it returns NULL so that the * to call the pull function till it returns NULL so that the
* producer can clean up its memory allocations */ * producer can clean up its memory allocations */
typedef typedef
yamlbyte_result_t yamlbyte_result_t
(*yamlbyte_pullbuff_t)( (*yamlbyte_pullbuff_t)(
yamlbyte_producer_t self, yamlbyte_producer_t self,
yamlbyte_buff_t *buff /* to be filled in by the producer */ yamlbyte_buff_t *buff /* to be filled in by the producer */
); );
/* convert a pull interface to a push interface; the reverse process /* convert a pull interface to a push interface; the reverse process
* requires threads and thus is language dependent */ * requires threads and thus is language dependent */

View file

@ -1,4 +1,4 @@
/* /*
* UNIX Syslog extension for Ruby * UNIX Syslog extension for Ruby
* Amos Gouaux, University of Texas at Dallas * Amos Gouaux, University of Texas at Dallas
* <amos+ruby@utdallas.edu> * <amos+ruby@utdallas.edu>
@ -65,7 +65,7 @@ static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "03", &ident, &opt, &fac); rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
if (NIL_P(ident)) { if (NIL_P(ident)) {
ident = rb_gv_get("$0"); ident = rb_gv_get("$0");
} }
SafeStringValue(ident); SafeStringValue(ident);
syslog_ident = strdup(RSTRING_PTR(ident)); syslog_ident = strdup(RSTRING_PTR(ident));
@ -232,7 +232,7 @@ static VALUE mSyslogConstants_LOG_UPTO(VALUE klass, VALUE pri)
void Init_syslog() void Init_syslog()
{ {
mSyslog = rb_define_module("Syslog"); mSyslog = rb_define_module("Syslog");
mSyslogConstants = rb_define_module_under(mSyslog, "Constants"); mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
rb_include_module(mSyslog, mSyslogConstants); rb_include_module(mSyslog, mSyslogConstants);

View file

@ -46,7 +46,7 @@ _nativethread_consistency_check(ip)
return; return;
} }
/* If the variable "tcl_platform(threaded)" exists, /* If the variable "tcl_platform(threaded)" exists,
then the Tcl interpreter was compiled with threads enabled. */ then the Tcl interpreter was compiled with threads enabled. */
if (Tcl_GetVar2(ip, "tcl_platform", "threaded", TCL_GLOBAL_ONLY) != (char*)NULL) { if (Tcl_GetVar2(ip, "tcl_platform", "threaded", TCL_GLOBAL_ONLY) != (char*)NULL) {
#ifdef HAVE_NATIVETHREAD #ifdef HAVE_NATIVETHREAD
@ -195,13 +195,13 @@ ruby_open_tcltk_dll(appname)
return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() ); return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() );
} }
int int
tcl_stubs_init_p() tcl_stubs_init_p()
{ {
return(tclStubsPtr != (TclStubs*)NULL); return(tclStubsPtr != (TclStubs*)NULL);
} }
int int
tk_stubs_init_p() tk_stubs_init_p()
{ {
return(tkStubsPtr != (TkStubs*)NULL); return(tkStubsPtr != (TkStubs*)NULL);
@ -246,14 +246,14 @@ ruby_tcl_create_ip_and_stubs_init(st)
} }
} }
p_Tcl_CreateInterp p_Tcl_CreateInterp
= (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_CreateInterp"); = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_CreateInterp");
if (!p_Tcl_CreateInterp) { if (!p_Tcl_CreateInterp) {
if (st) *st = NO_CreateInterp; if (st) *st = NO_CreateInterp;
return (Tcl_Interp*)NULL; return (Tcl_Interp*)NULL;
} }
p_Tcl_DeleteInterp p_Tcl_DeleteInterp
= (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_DeleteInterp"); = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_DeleteInterp");
if (!p_Tcl_DeleteInterp) { if (!p_Tcl_DeleteInterp) {
if (st) *st = NO_DeleteInterp; if (st) *st = NO_DeleteInterp;
@ -444,7 +444,7 @@ ruby_open_tcl_dll(appname)
return TCLTK_STUBS_OK; return TCLTK_STUBS_OK;
} }
int int
ruby_open_tk_dll() ruby_open_tk_dll()
{ {
if (!open_tcl_dll) { if (!open_tcl_dll) {
@ -455,7 +455,7 @@ ruby_open_tk_dll()
return TCLTK_STUBS_OK; return TCLTK_STUBS_OK;
} }
int int
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
ruby_open_tcltk_dll(char *appname) ruby_open_tcltk_dll(char *appname)
#else #else
@ -466,13 +466,13 @@ ruby_open_tcltk_dll(appname)
return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() ); return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() );
} }
int int
tcl_stubs_init_p() tcl_stubs_init_p()
{ {
return 1; return 1;
} }
int int
tk_stubs_init_p() tk_stubs_init_p()
{ {
return call_tk_stubs_init; return call_tk_stubs_init;
@ -505,13 +505,13 @@ ruby_tcl_create_ip_and_stubs_init(st)
return tcl_ip; return tcl_ip;
} }
int int
ruby_tcl_stubs_init() ruby_tcl_stubs_init()
{ {
return TCLTK_STUBS_OK; return TCLTK_STUBS_OK;
} }
int int
#ifdef HAVE_PROTOTYPES #ifdef HAVE_PROTOTYPES
ruby_tk_stubs_init(Tcl_Interp *tcl_ip) ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
#else #else
@ -559,7 +559,7 @@ ruby_tk_stubs_safeinit(tcl_ip)
#endif #endif
} }
int int
ruby_tcltk_stubs() ruby_tcltk_stubs()
{ {
/* Tcl_FindExecutable(RSTRING_PTR(rb_argv0)); */ /* Tcl_FindExecutable(RSTRING_PTR(rb_argv0)); */

File diff suppressed because it is too large Load diff

View file

@ -155,7 +155,7 @@ tk_do_callback(argc, argv, self)
rb_scan_args(argc, argv, "1*", &id, &rest); rb_scan_args(argc, argv, "1*", &id, &rest);
return rb_apply(rb_hash_aref(CALLBACK_TABLE, id), ID_call, rest); return rb_apply(rb_hash_aref(CALLBACK_TABLE, id), ID_call, rest);
#endif #endif
return rb_funcall2(rb_hash_aref(CALLBACK_TABLE, argv[0]), return rb_funcall2(rb_hash_aref(CALLBACK_TABLE, argv[0]),
ID_call, argc - 1, argv + 1); ID_call, argc - 1, argv + 1);
} }
@ -209,12 +209,12 @@ tk_uninstall_cmd(self, cmd_id)
if (strncmp(cmd_id_head, RSTRING_PTR(cmd_id), head_len) != 0) { if (strncmp(cmd_id_head, RSTRING_PTR(cmd_id), head_len) != 0) {
return Qnil; return Qnil;
} }
if (strncmp(cmd_id_prefix, if (strncmp(cmd_id_prefix,
RSTRING_PTR(cmd_id) + head_len, prefix_len) != 0) { RSTRING_PTR(cmd_id) + head_len, prefix_len) != 0) {
return Qnil; return Qnil;
} }
return rb_hash_delete(CALLBACK_TABLE, return rb_hash_delete(CALLBACK_TABLE,
rb_str_new2(RSTRING_PTR(cmd_id) + head_len)); rb_str_new2(RSTRING_PTR(cmd_id) + head_len));
} }
@ -697,7 +697,7 @@ push_kv_enc(key, val, args)
#if 0 #if 0
rb_ary_push(ary, key2keyname(key)); rb_ary_push(ary, key2keyname(key));
if (val != TK_None) { if (val != TK_None) {
rb_ary_push(ary, get_eval_string_core(val, Qtrue, rb_ary_push(ary, get_eval_string_core(val, Qtrue,
RARRAY_PTR(args)[1])); RARRAY_PTR(args)[1]));
} }
#endif #endif
@ -829,7 +829,7 @@ get_eval_string_core(obj, enc_flag, self)
case T_SYMBOL: case T_SYMBOL:
if (RTEST(enc_flag)) { if (RTEST(enc_flag)) {
if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) { if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
return rb_funcall(self, ID_toUTF8, 1, return rb_funcall(self, ID_toUTF8, 1,
rb_str_new2(rb_id2name(SYM2ID(obj)))); rb_str_new2(rb_id2name(SYM2ID(obj))));
} else { } else {
return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self); return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self);
@ -867,7 +867,7 @@ get_eval_string_core(obj, enc_flag, self)
default: default:
if (rb_obj_is_kind_of(obj, cTkObject)) { if (rb_obj_is_kind_of(obj, cTkObject)) {
/* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */ /* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */
return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0),
enc_flag, self); enc_flag, self);
} }
@ -885,18 +885,18 @@ get_eval_string_core(obj, enc_flag, self)
if (rb_obj_respond_to(obj, ID_to_eval, Qtrue)) { if (rb_obj_respond_to(obj, ID_to_eval, Qtrue)) {
/* return rb_funcall(obj, ID_to_eval, 0, 0); */ /* return rb_funcall(obj, ID_to_eval, 0, 0); */
return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0), return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0),
enc_flag, self); enc_flag, self);
} else if (rb_obj_respond_to(obj, ID_path, Qtrue)) { } else if (rb_obj_respond_to(obj, ID_path, Qtrue)) {
/* return rb_funcall(obj, ID_path, 0, 0); */ /* return rb_funcall(obj, ID_path, 0, 0); */
return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0),
enc_flag, self); enc_flag, self);
} else if (rb_obj_respond_to(obj, ID_to_s, Qtrue)) { } else if (rb_obj_respond_to(obj, ID_to_s, Qtrue)) {
return rb_funcall(obj, ID_to_s, 0, 0); return rb_funcall(obj, ID_to_s, 0, 0);
} }
} }
rb_warning("fail to convert '%s' to string for Tk", rb_warning("fail to convert '%s' to string for Tk",
RSTRING_PTR(rb_funcall(obj, rb_intern("inspect"), 0, 0))); RSTRING_PTR(rb_funcall(obj, rb_intern("inspect"), 0, 0)));
return obj; return obj;
@ -1039,7 +1039,7 @@ static VALUE
tkstr_invalid_numstr(value) tkstr_invalid_numstr(value)
VALUE value; VALUE value;
{ {
rb_raise(rb_eArgError, rb_raise(rb_eArgError,
"invalid value for Number: '%s'", RSTRING_PTR(value)); "invalid value for Number: '%s'", RSTRING_PTR(value));
return Qnil; /*dummy*/ return Qnil; /*dummy*/
} }
@ -1048,8 +1048,8 @@ static VALUE
tkstr_rescue_float(value) tkstr_rescue_float(value)
VALUE value; VALUE value;
{ {
return rb_rescue2(tkstr_to_float, value, return rb_rescue2(tkstr_to_float, value,
tkstr_invalid_numstr, value, tkstr_invalid_numstr, value,
rb_eArgError, 0); rb_eArgError, 0);
} }
@ -1061,8 +1061,8 @@ tkstr_to_number(value)
if (RSTRING_PTR(value) == (char*)NULL) return INT2FIX(0); if (RSTRING_PTR(value) == (char*)NULL) return INT2FIX(0);
return rb_rescue2(tkstr_to_int, value, return rb_rescue2(tkstr_to_int, value,
tkstr_rescue_float, value, tkstr_rescue_float, value,
rb_eArgError, 0); rb_eArgError, 0);
} }
@ -1111,8 +1111,8 @@ tcl2rb_num_or_str(self, value)
if (RSTRING_PTR(value) == (char*)NULL) return rb_tainted_str_new2(""); if (RSTRING_PTR(value) == (char*)NULL) return rb_tainted_str_new2("");
return rb_rescue2(tkstr_to_number, value, return rb_rescue2(tkstr_to_number, value,
tkstr_to_str, value, tkstr_to_str, value,
rb_eArgError, 0); rb_eArgError, 0);
} }
@ -1199,7 +1199,7 @@ allocate_cbsubst_info(struct cbsubst_info **inf_ptr)
static void static void
cbsubst_init() cbsubst_init()
{ {
rb_const_set(cCB_SUBST, ID_SUBST_INFO, rb_const_set(cCB_SUBST, ID_SUBST_INFO,
allocate_cbsubst_info((struct cbsubst_info **)NULL)); allocate_cbsubst_info((struct cbsubst_info **)NULL));
} }
@ -1212,7 +1212,7 @@ cbsubst_initialize(argc, argv, self)
struct cbsubst_info *inf; struct cbsubst_info *inf;
int idx, iv_idx; int idx, iv_idx;
Data_Get_Struct(rb_const_get(rb_obj_class(self), ID_SUBST_INFO), Data_Get_Struct(rb_const_get(rb_obj_class(self), ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
idx = 0; idx = 0;
@ -1252,7 +1252,7 @@ each_attr_def(key, value, klass)
key_id = SYM2ID(key); key_id = SYM2ID(key);
break; break;
default: default:
rb_raise(rb_eArgError, rb_raise(rb_eArgError,
"includes invalid key(s). expected a String or a Symbol"); "includes invalid key(s). expected a String or a Symbol");
} }
@ -1264,7 +1264,7 @@ each_attr_def(key, value, klass)
value_id = SYM2ID(value); value_id = SYM2ID(value);
break; break;
default: default:
rb_raise(rb_eArgError, rb_raise(rb_eArgError,
"includes invalid value(s). expected a String or a Symbol"); "includes invalid value(s). expected a String or a Symbol");
} }
@ -1284,7 +1284,7 @@ cbsubst_def_attr_aliases(self, tbl)
rb_raise(rb_eArgError, "expected a Hash"); rb_raise(rb_eArgError, "expected a Hash");
} }
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
rb_hash_foreach(tbl, each_attr_def, self); rb_hash_foreach(tbl, each_attr_def, self);
@ -1306,7 +1306,7 @@ cbsubst_sym_to_subst(self, sym)
if (TYPE(sym) != T_SYMBOL) return sym; if (TYPE(sym) != T_SYMBOL) return sym;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
if (!NIL_P(ret = rb_hash_aref(inf->aliases, sym))) { if (!NIL_P(ret = rb_hash_aref(inf->aliases, sym))) {
@ -1358,7 +1358,7 @@ cbsubst_get_subst_arg(argc, argv, self)
ID id; ID id;
volatile VALUE arg_sym, ret; volatile VALUE arg_sym, ret;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
ptr = buf = ALLOC_N(char, inf->full_subst_length + 1); ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
@ -1428,7 +1428,7 @@ cbsubst_get_subst_key(self, str)
list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str); list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str);
len = RARRAY_LEN(list); len = RARRAY_LEN(list);
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
ptr = buf = ALLOC_N(char, inf->full_subst_length + len + 1); ptr = buf = ALLOC_N(char, inf->full_subst_length + len + 1);
@ -1476,7 +1476,7 @@ cbsubst_get_all_subst_keys(self)
int idx, len; int idx, len;
volatile VALUE ret; volatile VALUE ret;
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
ptr = buf = ALLOC_N(char, inf->full_subst_length + 1); ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
@ -1587,7 +1587,7 @@ cbsubst_table_setup(argc, argv, self)
chr = (unsigned char)(0x80 + idx); chr = (unsigned char)(0x80 + idx);
subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]); subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]);
#if HAVE_STRNDUP #if HAVE_STRNDUP
subst_inf->key[chr] = strndup(RSTRING_PTR(RARRAY_PTR(inf)[0]), subst_inf->key[chr] = strndup(RSTRING_PTR(RARRAY_PTR(inf)[0]),
RSTRING_LEN(RARRAY_PTR(inf)[0])); RSTRING_LEN(RARRAY_PTR(inf)[0]));
#else #else
subst_inf->key[chr] = malloc(RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1); subst_inf->key[chr] = malloc(RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1);
@ -1620,10 +1620,10 @@ cbsubst_table_setup(argc, argv, self)
for(idx = 0; idx < len; idx++) { for(idx = 0; idx < len; idx++) {
inf = RARRAY_PTR(proc_inf)[idx]; inf = RARRAY_PTR(proc_inf)[idx];
if (TYPE(inf) != T_ARRAY) continue; if (TYPE(inf) != T_ARRAY) continue;
rb_hash_aset(subst_inf->proc, rb_hash_aset(subst_inf->proc,
((TYPE(RARRAY_PTR(inf)[0]) == T_STRING)? ((TYPE(RARRAY_PTR(inf)[0]) == T_STRING)?
INT2FIX(*(RSTRING_PTR(RARRAY_PTR(inf)[0]))) : INT2FIX(*(RSTRING_PTR(RARRAY_PTR(inf)[0]))) :
RARRAY_PTR(inf)[0]), RARRAY_PTR(inf)[0]),
RARRAY_PTR(inf)[1]); RARRAY_PTR(inf)[1]);
} }
@ -1661,7 +1661,7 @@ cbsubst_scan_args(self, arg_key, val_ary)
old_gc = rb_gc_disable(); old_gc = rb_gc_disable();
Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
struct cbsubst_info, inf); struct cbsubst_info, inf);
for(idx = 0; idx < vallen; idx++) { for(idx = 0; idx < vallen; idx++) {
@ -1680,7 +1680,7 @@ cbsubst_scan_args(self, arg_key, val_ary)
if (NIL_P(proc)) { if (NIL_P(proc)) {
rb_ary_push(dst, RARRAY_PTR(val_ary)[idx]); rb_ary_push(dst, RARRAY_PTR(val_ary)[idx]);
} else { } else {
rb_ary_push(dst, rb_funcall(proc, ID_call, 1, rb_ary_push(dst, rb_funcall(proc, ID_call, 1,
RARRAY_PTR(val_ary)[idx])); RARRAY_PTR(val_ary)[idx]));
} }
} }
@ -1736,7 +1736,7 @@ Init_tkutil()
/* --------------------- */ /* --------------------- */
rb_define_const(mTK, "RELEASE_DATE", rb_define_const(mTK, "RELEASE_DATE",
rb_obj_freeze(rb_str_new2(tkutil_release_date))); rb_obj_freeze(rb_str_new2(tkutil_release_date)));
/* --------------------- */ /* --------------------- */
@ -1766,19 +1766,19 @@ Init_tkutil()
ID_SUBST_INFO = rb_intern("SUBST_INFO"); ID_SUBST_INFO = rb_intern("SUBST_INFO");
rb_define_singleton_method(cCB_SUBST, "ret_val", cbsubst_ret_val, 1); rb_define_singleton_method(cCB_SUBST, "ret_val", cbsubst_ret_val, 1);
rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2); rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2);
rb_define_singleton_method(cCB_SUBST, "_sym2subst", rb_define_singleton_method(cCB_SUBST, "_sym2subst",
cbsubst_sym_to_subst, 1); cbsubst_sym_to_subst, 1);
rb_define_singleton_method(cCB_SUBST, "subst_arg", rb_define_singleton_method(cCB_SUBST, "subst_arg",
cbsubst_get_subst_arg, -1); cbsubst_get_subst_arg, -1);
rb_define_singleton_method(cCB_SUBST, "_get_subst_key", rb_define_singleton_method(cCB_SUBST, "_get_subst_key",
cbsubst_get_subst_key, 1); cbsubst_get_subst_key, 1);
rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys", rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys",
cbsubst_get_all_subst_keys, 0); cbsubst_get_all_subst_keys, 0);
rb_define_singleton_method(cCB_SUBST, "_setup_subst_table", rb_define_singleton_method(cCB_SUBST, "_setup_subst_table",
cbsubst_table_setup, -1); cbsubst_table_setup, -1);
rb_define_singleton_method(cCB_SUBST, "_get_extra_args_tbl", rb_define_singleton_method(cCB_SUBST, "_get_extra_args_tbl",
cbsubst_get_extra_args_tbl, 0); cbsubst_get_extra_args_tbl, 0);
rb_define_singleton_method(cCB_SUBST, "_define_attribute_aliases", rb_define_singleton_method(cCB_SUBST, "_define_attribute_aliases",
cbsubst_def_attr_aliases, 1); cbsubst_def_attr_aliases, 1);
rb_define_method(cCB_SUBST, "initialize", cbsubst_initialize, -1); rb_define_method(cCB_SUBST, "initialize", cbsubst_initialize, -1);
@ -1827,9 +1827,9 @@ Init_tkutil()
rb_define_singleton_method(mTK, "uninstall_cmd", tk_uninstall_cmd, 1); rb_define_singleton_method(mTK, "uninstall_cmd", tk_uninstall_cmd, 1);
rb_define_singleton_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1); rb_define_singleton_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1);
rb_define_singleton_method(mTK, "hash_kv", tk_hash_kv, -1); rb_define_singleton_method(mTK, "hash_kv", tk_hash_kv, -1);
rb_define_singleton_method(mTK, "_get_eval_string", rb_define_singleton_method(mTK, "_get_eval_string",
tk_get_eval_string, -1); tk_get_eval_string, -1);
rb_define_singleton_method(mTK, "_get_eval_enc_str", rb_define_singleton_method(mTK, "_get_eval_enc_str",
tk_get_eval_enc_str, 1); tk_get_eval_enc_str, 1);
rb_define_singleton_method(mTK, "_conv_args", tk_conv_args, -1); rb_define_singleton_method(mTK, "_conv_args", tk_conv_args, -1);

File diff suppressed because it is too large Load diff

View file

@ -1052,7 +1052,7 @@ rb_zstream_avail_out(VALUE obj)
/* /*
* Allocates +size+ bytes of free space in the output buffer. If there are more * Allocates +size+ bytes of free space in the output buffer. If there are more
* than +size+ bytes already in the buffer, the buffer is truncated. Because * than +size+ bytes already in the buffer, the buffer is truncated. Because
* free space is allocated automatically, you usually don't need to use this * free space is allocated automatically, you usually don't need to use this
* method. * method.
*/ */
@ -1358,7 +1358,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
/* /*
* call-seq: params(level, strategy) * call-seq: params(level, strategy)
* *
* Changes the parameters of the deflate stream. See zlib.h for details. The * Changes the parameters of the deflate stream. See zlib.h for details. The
* output from the stream by changing the params is preserved in output * output from the stream by changing the params is preserved in output
* buffer. * buffer.
@ -2781,7 +2781,7 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
* Document-class: Zlib::GzipWriter * Document-class: Zlib::GzipWriter
* *
* Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
* be used with an instance of IO, or IO-like, object. * be used with an instance of IO, or IO-like, object.
* *
* For example: * For example:
* *
@ -2842,7 +2842,7 @@ rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash"); opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
if (!NIL_P(opt)) argc--; if (!NIL_P(opt)) argc--;
} }
rb_scan_args(argc, argv, "12", &io, &level, &strategy); rb_scan_args(argc, argv, "12", &io, &level, &strategy);
Data_Get_Struct(obj, struct gzfile, gz); Data_Get_Struct(obj, struct gzfile, gz);
@ -3739,21 +3739,21 @@ Init_zlib()
/* /*
* Document-class: Zlib::GzipFile::NoFooter * Document-class: Zlib::GzipFile::NoFooter
* *
* Raised when gzip file footer is not found. * Raised when gzip file footer is not found.
*/ */
/* /*
* Document-class: Zlib::GzipFile::CRCError * Document-class: Zlib::GzipFile::CRCError
* *
* Raised when the CRC checksum recorded in gzip file footer is not equivalent * Raised when the CRC checksum recorded in gzip file footer is not equivalent
* to the CRC checksum of the actual uncompressed data. * to the CRC checksum of the actual uncompressed data.
*/ */
/* /*
* Document-class: Zlib::GzipFile::LengthError * Document-class: Zlib::GzipFile::LengthError
* *
* Raised when the data length recorded in the gzip file footer is not equivalent * Raised when the data length recorded in the gzip file footer is not equivalent
* to the length of the actual uncompressed data. * to the length of the actual uncompressed data.
*/ */