summaryrefslogtreecommitdiff
path: root/ext/pty/pty.c
blob: a51393026c038afcbc0f03bd7f763d7911746328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
#include "ruby/config.h"

#ifdef RUBY_EXTCONF_H
# include RUBY_EXTCONF_H
#endif

#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>

#ifdef HAVE_PWD_H
# include <pwd.h>
#endif

#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif

#ifdef HAVE_LIBUTIL_H
# include <libutil.h>
#endif

#ifdef HAVE_UTIL_H
# include <util.h>
#endif

#ifdef HAVE_PTY_H
# include <pty.h>
#endif

#if defined(HAVE_SYS_PARAM_H)
 /* for __FreeBSD_version */
# include <sys/param.h>
#endif

#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#else
# define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
#endif

#ifdef HAVE_SYS_STROPTS_H
#include <sys/stropts.h>
#endif

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include "internal.h"
#include "internal/process.h"
#include "internal/signal.h"
#include "ruby/io.h"
#include "ruby/util.h"

#define	DEVICELEN	16

#ifndef HAVE_SETEUID
# ifdef HAVE_SETREUID
#  define seteuid(e)	setreuid(-1, (e))
# else /* NOT HAVE_SETREUID */
#  ifdef HAVE_SETRESUID
#   define seteuid(e)	setresuid(-1, (e), -1)
#  else /* NOT HAVE_SETRESUID */
    /* I can't set euid. (;_;) */
#  endif /* HAVE_SETRESUID */
# endif /* HAVE_SETREUID */
#endif /* NO_SETEUID */

static VALUE eChildExited;

/* Returns the exit status of the child for which PTY#check
 * raised this exception
 */
static VALUE
echild_status(VALUE self)
{
    return rb_ivar_get(self, rb_intern("status"));
}

struct pty_info {
    int fd;
    rb_pid_t child_pid;
};

static void getDevice(int*, int*, char [DEVICELEN], int);

struct child_info {
    int master, slave;
    char *slavename;
    VALUE execarg_obj;
    struct rb_execarg *eargp;
};

static int
chfunc(void *data, char *errbuf, size_t errbuf_len)
{
    struct child_info *carg = data;
    int master = carg->master;
    int slave = carg->slave;

#define ERROR_EXIT(str) do { \
	strlcpy(errbuf, (str), errbuf_len); \
	return -1; \
    } while (0)

    /*
     * Set free from process group and controlling terminal
     */
#ifdef HAVE_SETSID
    (void) setsid();
#else /* HAS_SETSID */
# ifdef HAVE_SETPGRP
#  ifdef SETGRP_VOID
    if (setpgrp() == -1)
        ERROR_EXIT("setpgrp()");
#  else /* SETGRP_VOID */
    if (setpgrp(0, getpid()) == -1)
        ERROR_EXIT("setpgrp()");
    {
        int i = rb_cloexec_open("/dev/tty", O_RDONLY, 0);
        if (i < 0) ERROR_EXIT("/dev/tty");
        rb_update_max_fd(i);
        if (ioctl(i, TIOCNOTTY, (char *)0))
            ERROR_EXIT("ioctl(TIOCNOTTY)");
        close(i);
    }
#  endif /* SETGRP_VOID */
# endif /* HAVE_SETPGRP */
#endif /* HAS_SETSID */

    /*
     * obtain new controlling terminal
     */
#if defined(TIOCSCTTY)
    close(master);
    (void) ioctl(slave, TIOCSCTTY, (char *)0);
    /* errors ignored for sun */
#else
    close(slave);
    slave = rb_cloexec_open(carg->slavename, O_RDWR, 0);
    if (slave < 0) {
        ERROR_EXIT("open: pty slave");
    }
    rb_update_max_fd(slave);
    close(master);
#endif
    dup2(slave,0);
    dup2(slave,1);
    dup2(slave,2);
    if (slave < 0 || slave > 2) (void)!close(slave);
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
    if (seteuid(getuid())) ERROR_EXIT("seteuid()");
#endif

    return rb_exec_async_signal_safe(carg->eargp, errbuf, sizeof(errbuf_len));
#undef ERROR_EXIT
}

static void
establishShell(int argc, VALUE *argv, struct pty_info *info,
	       char SlaveName[DEVICELEN])
{
    int 		master, slave, status = 0;
    rb_pid_t		pid;
    char		*p, *getenv();
    VALUE		v;
    struct child_info   carg;
    char		errbuf[32];

    if (argc == 0) {
	const char *shellname = "/bin/sh";

	if ((p = getenv("SHELL")) != NULL) {
	    shellname = p;
	}
	else {
#if defined HAVE_PWD_H
	    const char *username = getenv("USER");
	    struct passwd *pwent = getpwnam(username ? username : getlogin());
	    if (pwent && pwent->pw_shell)
		shellname = pwent->pw_shell;
#endif
	}
	v = rb_str_new2(shellname);
	argc = 1;
	argv = &v;
    }

    carg.execarg_obj = rb_execarg_new(argc, argv, 1, 0);
    carg.eargp = rb_execarg_get(carg.execarg_obj);
    rb_execarg_parent_start(carg.execarg_obj);

    getDevice(&master, &slave, SlaveName, 0);

    carg.master = master;
    carg.slave = slave;
    carg.slavename = SlaveName;
    errbuf[0] = '\0';
    pid = rb_fork_async_signal_safe(&status, chfunc, &carg, Qnil, errbuf, sizeof(errbuf));

    if (pid < 0) {
	int e = errno;
	close(master);
	close(slave);
        rb_execarg_parent_end(carg.execarg_obj);
	errno = e;
	if (status) rb_jump_tag(status);
	rb_sys_fail(errbuf[0] ? errbuf : "fork failed");
    }

    close(slave);
    rb_execarg_parent_end(carg.execarg_obj);

    info->child_pid = pid;
    info->fd = master;

    RB_GC_GUARD(carg.execarg_obj);
}

#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_OPENPTY) || defined(HAVE_PTSNAME)
static int
no_mesg(char *slavedevice, int nomesg)
{
    if (nomesg)
        return chmod(slavedevice, 0600);
    else
        return 0;
}
#endif

#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
static inline int
ioctl_I_PUSH(int fd, const char *const name)
{
    int ret = 0;
# if defined(I_FIND)
    ret = ioctl(fd, I_FIND, name);
# endif
    if (ret == 0) {
        ret = ioctl(fd, I_PUSH, name);
    }
    return ret;
}
#endif

static int
get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, int fail)
{
#if defined(HAVE_POSIX_OPENPT)
    /* Unix98 PTY */
    int masterfd = -1, slavefd = -1;
    char *slavedevice;

#if defined(__sun) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 902000)
    /* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set.  [ruby-dev:44688] */
    /* FreeBSD 9.2 or later supports O_CLOEXEC
     * http://www.freebsd.org/cgi/query-pr.cgi?pr=162374 */
    if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
    if (rb_grantpt(masterfd) == -1) goto error;
    rb_fd_fix_cloexec(masterfd);
#else
    {
	int flags = O_RDWR|O_NOCTTY;
# if defined(O_CLOEXEC)
	/* glibc posix_openpt() in GNU/Linux calls open("/dev/ptmx", flags) internally.
	 * So version dependency on GNU/Linux is same as O_CLOEXEC with open().
	 * O_CLOEXEC is available since Linux 2.6.23.  Linux 2.6.18 silently ignore it. */
	flags |= O_CLOEXEC;
# endif
	if ((masterfd = posix_openpt(flags)) == -1) goto error;
    }
    rb_fd_fix_cloexec(masterfd);
    if (rb_grantpt(masterfd) == -1) goto error;
#endif
    if (unlockpt(masterfd) == -1) goto error;
    if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
    if (no_mesg(slavedevice, nomesg) == -1) goto error;
    if ((slavefd = rb_cloexec_open(slavedevice, O_RDWR|O_NOCTTY, 0)) == -1) goto error;
    rb_update_max_fd(slavefd);

#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
    if (ioctl_I_PUSH(slavefd, "ptem") == -1) goto error;
    if (ioctl_I_PUSH(slavefd, "ldterm") == -1) goto error;
    if (ioctl_I_PUSH(slavefd, "ttcompat") == -1) goto error;
#endif

    *master = masterfd;
    *slave = slavefd;
    strlcpy(SlaveName, slavedevice, DEVICELEN);
    return 0;

  error:
    if (slavefd != -1) close(slavefd);
    if (masterfd != -1) close(masterfd);
    if (fail) {
        rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
    }
    return -1;
#elif defined HAVE_OPENPTY
/*
 * Use openpty(3) of 4.3BSD Reno and later,
 * or the same interface function.
 */
    if (openpty(master, slave, SlaveName,
		(struct termios *)0, (struct winsize *)0) == -1) {
	if (!fail) return -1;
	rb_raise(rb_eRuntimeError, "openpty() failed");
    }
    rb_fd_fix_cloexec(*master);
    rb_fd_fix_cloexec(*slave);
    if (no_mesg(SlaveName, nomesg) == -1) {
	if (!fail) return -1;
	rb_raise(rb_eRuntimeError, "can't chmod slave pty");
    }

    return 0;

#elif defined HAVE__GETPTY
    /* SGI IRIX */
    char *name;
    mode_t mode = nomesg ? 0600 : 0622;

    if (!(name = _getpty(master, O_RDWR, mode, 0))) {
	if (!fail) return -1;
	rb_raise(rb_eRuntimeError, "_getpty() failed");
    }
    rb_fd_fix_cloexec(*master);

    *slave = rb_cloexec_open(name, O_RDWR, 0);
    /* error check? */
    rb_update_max_fd(*slave);
    strlcpy(SlaveName, name, DEVICELEN);

    return 0;
#elif defined(HAVE_PTSNAME)
    /* System V */
    int	 masterfd = -1, slavefd = -1;
    char *slavedevice;
    void (*s)();

    extern char *ptsname(int);
    extern int unlockpt(int);

#if defined(__sun)
    /* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set.  [ruby-dev:44688] */
    if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
    if(rb_grantpt(masterfd) == -1) goto error;
    rb_fd_fix_cloexec(masterfd);
#else
    if((masterfd = rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
    rb_update_max_fd(masterfd);
    if(rb_grantpt(masterfd) == -1) goto error;
#endif
    if(unlockpt(masterfd) == -1) goto error;
    if((slavedevice = ptsname(masterfd)) == NULL) goto error;
    if (no_mesg(slavedevice, nomesg) == -1) goto error;
    if((slavefd = rb_cloexec_open(slavedevice, O_RDWR, 0)) == -1) goto error;
    rb_update_max_fd(slavefd);
#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
    if(ioctl_I_PUSH(slavefd, "ptem") == -1) goto error;
    if(ioctl_I_PUSH(slavefd, "ldterm") == -1) goto error;
    ioctl_I_PUSH(slavefd, "ttcompat");
#endif
    *master = masterfd;
    *slave = slavefd;
    strlcpy(SlaveName, slavedevice, DEVICELEN);
    return 0;

  error:
    if (slavefd != -1) close(slavefd);
    if (masterfd != -1) close(masterfd);
    if (fail) rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
    return -1;
#else
    /* BSD */
    int	 masterfd = -1, slavefd = -1;
    int  i;
    char MasterName[DEVICELEN];

#define HEX1(c) \
	c"0",c"1",c"2",c"3",c"4",c"5",c"6",c"7", \
	c"8",c"9",c"a",c"b",c"c",c"d",c"e",c"f"

#if defined(__hpux)
    static const char MasterDevice[] = "/dev/ptym/pty%s";
    static const char SlaveDevice[] =  "/dev/pty/tty%s";
    static const char deviceNo[][3] = {
	HEX1("p"), HEX1("q"), HEX1("r"), HEX1("s"),
	HEX1("t"), HEX1("u"), HEX1("v"), HEX1("w"),
    };
#elif defined(_IBMESA)  /* AIX/ESA */
    static const char MasterDevice[] = "/dev/ptyp%s";
    static const char SlaveDevice[] = "/dev/ttyp%s";
    static const char deviceNo[][3] = {
	HEX1("0"), HEX1("1"), HEX1("2"), HEX1("3"),
	HEX1("4"), HEX1("5"), HEX1("6"), HEX1("7"),
	HEX1("8"), HEX1("9"), HEX1("a"), HEX1("b"),
	HEX1("c"), HEX1("d"), HEX1("e"), HEX1("f"),
    };
#else /* 4.2BSD */
    static const char MasterDevice[] = "/dev/pty%s";
    static const char SlaveDevice[] = "/dev/tty%s";
    static const char deviceNo[][3] = {
	HEX1("p"), HEX1("q"), HEX1("r"), HEX1("s"),
    };
#endif
#undef HEX1
    for (i = 0; i < numberof(deviceNo); i++) {
	const char *const devno = deviceNo[i];
	snprintf(MasterName, sizeof MasterName, MasterDevice, devno);
	if ((masterfd = rb_cloexec_open(MasterName,O_RDWR,0)) >= 0) {
            rb_update_max_fd(masterfd);
	    *master = masterfd;
	    snprintf(SlaveName, DEVICELEN, SlaveDevice, devno);
	    if ((slavefd = rb_cloexec_open(SlaveName,O_RDWR,0)) >= 0) {
                rb_update_max_fd(slavefd);
		*slave = slavefd;
		if (chown(SlaveName, getuid(), getgid()) != 0) goto error;
		if (chmod(SlaveName, nomesg ? 0600 : 0622) != 0) goto error;
		return 0;
	    }
	    close(masterfd);
	}
    }
  error:
    if (slavefd != -1) close(slavefd);
    if (masterfd != -1) close(masterfd);
    if (fail) rb_raise(rb_eRuntimeError, "can't get %s", SlaveName);
    return -1;
#endif
}

static void
getDevice(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg)
{
    if (get_device_once(master, slave, SlaveName, nomesg, 0)) {
	rb_gc();
	get_device_once(master, slave, SlaveName, nomesg, 1);
    }
}

static VALUE
pty_close_pty(VALUE assoc)
{
    VALUE io;
    int i;

    for (i = 0; i < 2; i++) {
        io = rb_ary_entry(assoc, i);
        if (RB_TYPE_P(io, T_FILE) && 0 <= RFILE(io)->fptr->fd)
            rb_io_close(io);
    }
    return Qnil;
}

/*
 * call-seq:
 *   PTY.open => [master_io, slave_file]
 *   PTY.open {|master_io, slave_file| ... } => block value
 *
 * Allocates a pty (pseudo-terminal).
 *
 * In the block form, yields two arguments <tt>master_io, slave_file</tt>
 * and the value of the block is returned from +open+.
 *
 * The IO and File are both closed after the block completes if they haven't
 * been already closed.
 *
 *   PTY.open {|master, slave|
 *     p master      #=> #<IO:masterpty:/dev/pts/1>
 *     p slave      #=> #<File:/dev/pts/1>
 *     p slave.path #=> "/dev/pts/1"
 *   }
 *
 * In the non-block form, returns a two element array, <tt>[master_io,
 * slave_file]</tt>.
 *
 *   master, slave = PTY.open
 *   # do something with master for IO, or the slave file
 *
 * The arguments in both forms are:
 *
 * +master_io+::    the master of the pty, as an IO.
 * +slave_file+::   the slave of the pty, as a File.  The path to the
 *		    terminal device is available via +slave_file.path+
 *
 * IO#raw! is usable to disable newline conversions:
 *
 *   require 'io/console'
 *   PTY.open {|m, s|
 *     s.raw!
 *     ...
 *   }
 *
 */
static VALUE
pty_open(VALUE klass)
{
    int master_fd, slave_fd;
    char slavename[DEVICELEN];
    VALUE master_io, slave_file;
    rb_io_t *master_fptr, *slave_fptr;
    VALUE assoc;

    getDevice(&master_fd, &slave_fd, slavename, 1);

    master_io = rb_obj_alloc(rb_cIO);
    MakeOpenFile(master_io, master_fptr);
    master_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX;
    master_fptr->fd = master_fd;
    master_fptr->pathv = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename));

    slave_file = rb_obj_alloc(rb_cFile);
    MakeOpenFile(slave_file, slave_fptr);
    slave_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY;
    slave_fptr->fd = slave_fd;
    slave_fptr->pathv = rb_obj_freeze(rb_str_new_cstr(slavename));

    assoc = rb_assoc_new(master_io, slave_file);
    if (rb_block_given_p()) {
	return rb_ensure(rb_yield, assoc, pty_close_pty, assoc);
    }
    return assoc;
}

static VALUE
pty_detach_process(VALUE v)
{
    struct pty_info *info = (void *)v;
#ifdef WNOHANG
    int st;
    if (rb_waitpid(info->child_pid, &st, WNOHANG) <= 0)
	return Qnil;
#endif
    rb_detach_process(info->child_pid);
    return Qnil;
}

/*
 * call-seq:
 *   PTY.spawn(command_line)  { |r, w, pid| ... }
 *   PTY.spawn(command_line)  => [r, w, pid]
 *   PTY.spawn(command, arguments, ...)  { |r, w, pid| ... }
 *   PTY.spawn(command, arguments, ...)  => [r, w, pid]
 *
 * Spawns the specified command on a newly allocated pty. You can also use the
 * alias ::getpty.
 *
 * The command's controlling tty is set to the slave device of the pty
 * and its standard input/output/error is redirected to the slave device.
 *
 * +command+ and +command_line+ are the full commands to run, given a String.
 * Any additional +arguments+ will be passed to the command.
 *
 * === Return values
 *
 * In the non-block form this returns an array of size three,
 * <tt>[r, w, pid]</tt>.
 *
 * In the block form these same values will be yielded to the block:
 *
 * +r+:: A readable IO that contains the command's
 *       standard output and standard error
 * +w+:: A writable IO that is the command's standard input
 * +pid+:: The process identifier for the command.
 */
static VALUE
pty_getpty(int argc, VALUE *argv, VALUE self)
{
    VALUE res;
    struct pty_info info;
    rb_io_t *wfptr,*rfptr;
    VALUE rport = rb_obj_alloc(rb_cFile);
    VALUE wport = rb_obj_alloc(rb_cFile);
    char SlaveName[DEVICELEN];

    MakeOpenFile(rport, rfptr);
    MakeOpenFile(wport, wfptr);

    establishShell(argc, argv, &info, SlaveName);

    rfptr->mode = rb_io_modestr_fmode("r");
    rfptr->fd = info.fd;
    rfptr->pathv = rb_obj_freeze(rb_str_new_cstr(SlaveName));

    wfptr->mode = rb_io_modestr_fmode("w") | FMODE_SYNC;
    wfptr->fd = rb_cloexec_dup(info.fd);
    if (wfptr->fd == -1)
        rb_sys_fail("dup()");
    rb_update_max_fd(wfptr->fd);
    wfptr->pathv = rfptr->pathv;

    res = rb_ary_new2(3);
    rb_ary_store(res,0,(VALUE)rport);
    rb_ary_store(res,1,(VALUE)wport);
    rb_ary_store(res,2,PIDT2NUM(info.child_pid));

    if (rb_block_given_p()) {
	rb_ensure(rb_yield, res, pty_detach_process, (VALUE)&info);
	return Qnil;
    }
    return res;
}

NORETURN(static void raise_from_check(rb_pid_t pid, int status));
static void
raise_from_check(rb_pid_t pid, int status)
{
    const char *state;
    VALUE msg;
    VALUE exc;

#if defined(WIFSTOPPED)
#elif defined(IF_STOPPED)
#define WIFSTOPPED(status) IF_STOPPED(status)
#else
---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
#endif /* WIFSTOPPED | IF_STOPPED */
    if (WIFSTOPPED(status)) { /* suspend */
	state = "stopped";
    }
    else if (kill(pid, 0) == 0) {
	state = "changed";
    }
    else {
	state = "exited";
    }
    msg = rb_sprintf("pty - %s: %ld", state, (long)pid);
    exc = rb_exc_new_str(eChildExited, msg);
    rb_iv_set(exc, "status", rb_last_status_get());
    rb_exc_raise(exc);
}

/*
 * call-seq:
 *   PTY.check(pid, raise = false) => Process::Status or nil
 *   PTY.check(pid, true)          => nil or raises PTY::ChildExited
 *
 * Checks the status of the child process specified by +pid+.
 * Returns +nil+ if the process is still alive.
 *
 * If the process is not alive, and +raise+ was true, a PTY::ChildExited
 * exception will be raised. Otherwise it will return a Process::Status
 * instance.
 *
 * +pid+:: The process id of the process to check
 * +raise+:: If +true+ and the process identified by +pid+ is no longer
 *           alive a PTY::ChildExited is raised.
 *
 */
static VALUE
pty_check(int argc, VALUE *argv, VALUE self)
{
    VALUE pid, exc;
    rb_pid_t cpid;
    int status;
    const int flag =
#ifdef WNOHANG
	WNOHANG|
#endif
#ifdef WUNTRACED
	WUNTRACED|
#endif
	0;

    rb_scan_args(argc, argv, "11", &pid, &exc);
    cpid = rb_waitpid(NUM2PIDT(pid), &status, flag);
    if (cpid == -1 || cpid == 0) return Qnil;

    if (!RTEST(exc)) return rb_last_status_get();
    raise_from_check(cpid, status);

    UNREACHABLE_RETURN(Qnil);
}

static VALUE cPTY;

/*
 * Document-class: PTY::ChildExited
 *
 * Thrown when PTY::check is called for a pid that represents a process that
 * has exited.
 */

/*
 * Document-class: PTY
 *
 * Creates and manages pseudo terminals (PTYs).  See also
 * https://en.wikipedia.org/wiki/Pseudo_terminal
 *
 * PTY allows you to allocate new terminals using ::open or ::spawn a new
 * terminal with a specific command.
 *
 * == Example
 *
 * In this example we will change the buffering type in the +factor+ command,
 * assuming that factor uses stdio for stdout buffering.
 *
 * If IO.pipe is used instead of PTY.open, this code deadlocks because factor's
 * stdout is fully buffered.
 *
 *   # start by requiring the standard library PTY
 *   require 'pty'
 *
 *   master, slave = PTY.open
 *   read, write = IO.pipe
 *   pid = spawn("factor", :in=>read, :out=>slave)
 *   read.close	    # we dont need the read
 *   slave.close    # or the slave
 *
 *   # pipe "42" to the factor command
 *   write.puts "42"
 *   # output the response from factor
 *   p master.gets #=> "42: 2 3 7\n"
 *
 *   # pipe "144" to factor and print out the response
 *   write.puts "144"
 *   p master.gets #=> "144: 2 2 2 2 3 3\n"
 *   write.close # close the pipe
 *
 *   # The result of read operation when pty slave is closed is platform
 *   # dependent.
 *   ret = begin
 *           master.gets     # FreeBSD returns nil.
 *         rescue Errno::EIO # GNU/Linux raises EIO.
 *           nil
 *         end
 *   p ret #=> nil
 *
 * == License
 *
 *  C) Copyright 1998 by Akinori Ito.
 *
 *  This software may be redistributed freely for this purpose, in full
 *  or in part, provided that this entire copyright notice is included
 *  on any copies of this software and applications and derivations thereof.
 *
 *  This software is provided on an "as is" basis, without warranty of any
 *  kind, either expressed or implied, as to any matter including, but not
 *  limited to warranty of fitness of purpose, or merchantability, or
 *  results obtained from use of this software.
 */

void
Init_pty(void)
{
    cPTY = rb_define_module("PTY");
    /* :nodoc: */
    rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
    rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
    rb_define_singleton_method(cPTY,"check",pty_check,-1);
    rb_define_singleton_method(cPTY,"open",pty_open,0);

    eChildExited = rb_define_class_under(cPTY,"ChildExited",rb_eRuntimeError);
    rb_define_method(eChildExited,"status",echild_status,0);
}
03c0a2'>lib/cgi/session/pstore.rb5
-rw-r--r--lib/date/format.rb10
-rw-r--r--lib/delegate.rb14
-rw-r--r--lib/drb/drb.rb60
-rw-r--r--lib/drb/extservm.rb8
-rw-r--r--lib/drb/ssl.rb4
-rw-r--r--lib/erb.rb379
-rw-r--r--lib/jcode.rb3
-rw-r--r--lib/net/http.rb2
-rw-r--r--lib/optparse.rb101
-rw-r--r--lib/optparse/version.rb36
-rw-r--r--lib/ostruct.rb25
-rw-r--r--lib/pathname.rb6
-rw-r--r--lib/pp.rb4
-rw-r--r--lib/rdoc/README17
-rw-r--r--lib/rdoc/code_objects.rb61
-rw-r--r--lib/rdoc/generators/html_generator.rb132
-rw-r--r--lib/rdoc/generators/template/html/html.rb602
-rw-r--r--lib/rdoc/markup/simple_markup/preprocess.rb2
-rw-r--r--lib/rdoc/options.rb2
-rw-r--r--lib/rdoc/parsers/parse_rb.rb34
-rw-r--r--lib/rdoc/rdoc.rb18
-rw-r--r--lib/rdoc/ri/ri_options.rb6
-rw-r--r--lib/rexml/encodings/SHIFT-JIS.rb8
-rw-r--r--lib/rexml/encodings/SHIFT_JIS.rb2
-rw-r--r--lib/rss/0.9.rb367
-rw-r--r--lib/rss/1.0.rb209
-rw-r--r--lib/rss/2.0.rb69
-rw-r--r--lib/rss/maker.rb14
-rw-r--r--lib/rss/maker/0.9.rb100
-rw-r--r--lib/rss/maker/1.0.rb74
-rw-r--r--lib/rss/maker/2.0.rb73
-rw-r--r--lib/rss/maker/base.rb260
-rw-r--r--lib/rss/maker/trackback.rb118
-rw-r--r--lib/rss/parser.rb14
-rw-r--r--lib/rss/rexmlparser.rb2
-rw-r--r--lib/rss/rss.rb256
-rw-r--r--lib/rss/trackback.rb260
-rw-r--r--lib/rss/xml-stylesheet.rb7
-rw-r--r--lib/rss/xmlscanner.rb2
-rw-r--r--lib/set.rb14
-rw-r--r--lib/shellwords.rb4
-rw-r--r--lib/soap/baseData.rb67
-rw-r--r--lib/soap/encodingstyle/literalHandler.rb2
-rw-r--r--lib/soap/encodingstyle/soapHandler.rb6
-rw-r--r--lib/soap/mapping/factory.rb81
-rw-r--r--lib/soap/mapping/mapping.rb83
-rw-r--r--lib/soap/mapping/registry.rb207
-rw-r--r--lib/soap/mapping/rubytypeFactory.rb18
-rw-r--r--lib/soap/mapping/typeMap.rb9
-rw-r--r--lib/soap/mapping/wsdlencodedregistry.rb173
-rw-r--r--lib/soap/mapping/wsdlliteralregistry.rb281
-rw-r--r--lib/soap/netHttpClient.rb11
-rw-r--r--lib/soap/property.rb17
-rw-r--r--lib/soap/rpc/cgistub.rb8
-rw-r--r--lib/soap/rpc/driver.rb274
-rw-r--r--lib/soap/rpc/httpserver.rb57
-rw-r--r--lib/soap/rpc/proxy.rb264
-rw-r--r--lib/soap/rpc/router.rb221
-rw-r--r--lib/soap/rpc/rpc.rb2
-rw-r--r--lib/soap/rpc/soaplet.rb92
-rw-r--r--lib/soap/soap.rb2
-rw-r--r--lib/soap/streamHandler.rb80
-rw-r--r--lib/soap/wsdlDriver.rb394
-rw-r--r--lib/test/unit.rb6
-rw-r--r--lib/test/unit/autorunner.rb17
-rw-r--r--lib/test/unit/collector/dir.rb15
-rw-r--r--lib/thwait.rb7
-rw-r--r--lib/webrick/accesslog.rb7
-rw-r--r--lib/webrick/config.rb3
-rw-r--r--lib/webrick/httpauth.rb1
-rw-r--r--lib/webrick/httpauth/basicauth.rb1
-rw-r--r--lib/webrick/httpauth/digestauth.rb5
-rw-r--r--lib/webrick/httpserver.rb7
-rw-r--r--lib/webrick/httpservlet/filehandler.rb27
-rw-r--r--lib/webrick/server.rb12
-rw-r--r--lib/wsdl/binding.rb2
-rw-r--r--lib/wsdl/definitions.rb4
-rw-r--r--lib/wsdl/import.rb4
-rw-r--r--lib/wsdl/importer.rb9
-rw-r--r--lib/wsdl/message.rb2
-rw-r--r--lib/wsdl/operation.rb4
-rw-r--r--lib/wsdl/operationBinding.rb2
-rw-r--r--lib/wsdl/param.rb2
-rw-r--r--lib/wsdl/parser.rb24
-rw-r--r--lib/wsdl/part.rb2
-rw-r--r--lib/wsdl/port.rb2
-rw-r--r--lib/wsdl/portType.rb2
-rw-r--r--lib/wsdl/service.rb2
-rw-r--r--lib/wsdl/soap/address.rb2
-rw-r--r--lib/wsdl/soap/binding.rb9
-rw-r--r--lib/wsdl/soap/body.rb8
-rw-r--r--lib/wsdl/soap/cgiStubCreator.rb9
-rw-r--r--lib/wsdl/soap/classDefCreator.rb156
-rw-r--r--lib/wsdl/soap/classDefCreatorSupport.rb22
-rw-r--r--lib/wsdl/soap/clientSkeltonCreator.rb2
-rw-r--r--lib/wsdl/soap/complexType.rb40
-rw-r--r--lib/wsdl/soap/data.rb1
-rw-r--r--lib/wsdl/soap/driverCreator.rb11
-rw-r--r--lib/wsdl/soap/element.rb34
-rw-r--r--lib/wsdl/soap/fault.rb8
-rw-r--r--lib/wsdl/soap/header.rb10
-rw-r--r--lib/wsdl/soap/headerfault.rb8
-rw-r--r--lib/wsdl/soap/methodDefCreator.rb55
-rw-r--r--lib/wsdl/soap/operation.rb9
-rw-r--r--lib/wsdl/soap/servantSkeltonCreator.rb16
-rw-r--r--lib/wsdl/soap/standaloneServerStubCreator.rb16
-rw-r--r--lib/wsdl/xmlSchema/all.rb8
-rw-r--r--lib/wsdl/xmlSchema/any.rb12
-rw-r--r--lib/wsdl/xmlSchema/attribute.rb25
-rw-r--r--lib/wsdl/xmlSchema/choice.rb8
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb30
-rw-r--r--lib/wsdl/xmlSchema/content.rb4
-rw-r--r--lib/wsdl/xmlSchema/data.rb3
-rw-r--r--lib/wsdl/xmlSchema/element.rb45
-rw-r--r--lib/wsdl/xmlSchema/enumeration.rb4
-rw-r--r--lib/wsdl/xmlSchema/import.rb4
-rw-r--r--lib/wsdl/xmlSchema/parser.rb31
-rw-r--r--lib/wsdl/xmlSchema/schema.rb8
-rw-r--r--lib/wsdl/xmlSchema/sequence.rb8
-rw-r--r--lib/wsdl/xmlSchema/simpleContent.rb65
-rw-r--r--lib/wsdl/xmlSchema/simpleType.rb2
-rw-r--r--lib/xsd/charset.rb6
-rw-r--r--lib/xsd/codegen/methoddef.rb2
-rw-r--r--lib/xsd/datatypes.rb431
-rw-r--r--lib/xsd/namedelements.rb4
-rw-r--r--lib/xsd/ns.rb22
-rw-r--r--lib/xsd/qname.rb4
-rw-r--r--misc/ruby-mode.el13
-rw-r--r--numeric.c5
-rw-r--r--object.c23
-rw-r--r--pack.c118
-rw-r--r--parse.y1
-rw-r--r--process.c60
-rw-r--r--re.c4
-rw-r--r--regex.c10
-rw-r--r--rubyio.h5
-rw-r--r--rubysig.h5
-rwxr-xr-xsample/optparse/subcommand.rb19
-rwxr-xr-xsample/rss/blend.rb76
-rw-r--r--sample/rss/list_description.rb114
-rw-r--r--sample/rss/rss_recent.rb114
-rw-r--r--sample/soap/authheader/client2.rb15
-rw-r--r--sample/soap/authheader/server.rb1
-rw-r--r--sample/soap/authheader/server2.rb22
-rw-r--r--sample/soap/calc/server.rb6
-rw-r--r--sample/soap/calc/server2.rb6
-rw-r--r--sample/soap/helloworld/hw_c_gzip.rb8
-rw-r--r--sample/soap/helloworld/hw_s.rb3
-rw-r--r--sample/soap/helloworld/hw_s_gzip.rb21
-rw-r--r--sample/soap/scopesample/client.rb34
-rw-r--r--sample/soap/scopesample/httpd.rb22
-rw-r--r--sample/soap/scopesample/samplehttpd.conf2
-rw-r--r--sample/soap/scopesample/servant.rb18
-rwxr-xr-xsample/soap/scopesample/server.cgi29
-rw-r--r--sample/soap/scopesample/server.rb20
-rw-r--r--sprintf.c1
-rw-r--r--st.h41
-rw-r--r--string.c61
-rw-r--r--struct.c2
-rw-r--r--test/drb/drbtest.rb16
-rw-r--r--test/drb/test_drb.rb5
-rw-r--r--test/drb/ut_drb.rb4
-rw-r--r--test/io/nonblock/test_flush.rb28
-rw-r--r--test/logger/test_logger.rb10
-rw-r--r--test/openssl/ssl_server.rb12
-rw-r--r--test/openssl/test_asn1.rb197
-rw-r--r--test/openssl/test_pkey_rsa.rb38
-rw-r--r--test/openssl/test_ssl.rb32
-rw-r--r--test/openssl/test_x509name.rb134
-rw-r--r--test/openssl/test_x509store.rb32
-rw-r--r--test/optparse/test_noarg.rb4
-rw-r--r--test/readline/test_readline.rb77
-rw-r--r--test/rss/rss-assertions.rb341
-rw-r--r--test/rss/test_1.0.rb5
-rw-r--r--test/rss/test_maker_0.9.rb204
-rw-r--r--test/rss/test_maker_1.0.rb84
-rw-r--r--test/rss/test_maker_2.0.rb135
-rw-r--r--test/rss/test_maker_content.rb2
-rw-r--r--test/rss/test_maker_dc.rb2
-rw-r--r--test/rss/test_maker_sy.rb2
-rw-r--r--test/rss/test_maker_trackback.rb13
-rw-r--r--test/rss/test_parser.rb12
-rw-r--r--test/rss/test_setup_maker_0.9.rb221
-rw-r--r--test/rss/test_setup_maker_1.0.rb276
-rw-r--r--test/rss/test_setup_maker_2.0.rb295
-rw-r--r--test/rss/test_to_s.rb440
-rw-r--r--test/rss/test_trackback.rb10
-rw-r--r--test/rss/test_version.rb9
-rw-r--r--test/rss/test_xml-stylesheet.rb6
-rw-r--r--test/ruby/beginmainend.rb5
-rw-r--r--test/ruby/test_file.rb6
-rw-r--r--test/ruby/test_pack.rb38
-rw-r--r--test/ruby/test_settracefunc.rb26
-rw-r--r--test/ruby/test_stringchar.rb50
-rw-r--r--test/soap/ssl/sslsvr.rb16
-rw-r--r--test/soap/ssl/test_ssl.rb13
-rw-r--r--test/soap/test_property.rb46
-rw-r--r--test/soap/test_soapelement.rb2
-rw-r--r--test/soap/test_streamhandler.rb8
-rw-r--r--test/stringio/test_stringio.rb10
-rw-r--r--test/testunit/collector/test_dir.rb8
-rw-r--r--test/wsdl/map/map.wsdl50
-rw-r--r--test/wsdl/map/test_map.rb75
-rw-r--r--test/xsd/test_xsd.rb494
-rw-r--r--version.h8
-rw-r--r--vms/config.h99
-rw-r--r--vms/config.h_in61
-rw-r--r--vms/vms.h6
-rw-r--r--vms/vmsruby_private.c52
-rw-r--r--vms/vmsruby_private.h7
-rw-r--r--win32/Makefile.sub2
-rw-r--r--win32/setup.mak2
-rw-r--r--win32/win32.c90
-rw-r--r--win32/win32.h7
-rw-r--r--wince/Makefile.sub2
-rw-r--r--wince/setup.mak2
323 files changed, 4509 insertions, 13492 deletions
diff --git a/ChangeLog b/ChangeLog
index 78755343f4..027f0c2a6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1158 +1,3 @@
-Wed Dec 22 11:14:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_mode_modenum): replace O_ACCMODE with O_RDWR.
- fixed: [ruby-dev:25273]
-
-Wed Dec 22 08:34:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/dl/sym.c (rb_dlsym_initialize): extract internal pointers after
- all argument conversion. fixed: [ruby-dev:25271]
-
-Wed Dec 22 00:08:01 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-
- * lib/soap/*, test/soap/*, sample/soap/authheader/*: eval cleanup.
-
-Tue Dec 21 22:07:33 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode,
- ossl_asn1_decode_all): temporary value should be marked volatile.
-
-Tue Dec 21 14:40:02 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode,
- ossl_asn1_decode_all): use rb_str_new4 to avoid SEGV.
- fix [ruby-dev:25261]
-
- * test/openssl/test_asn1.rb: add tests for OpenSSL::ASN1.
-
-Tue Dec 21 12:22:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (io_reopen): keep duplex pipe in correct mode for exception
- safeness. fixed: [ruby-dev:25152]
-
-Tue Dec 21 12:10:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/grid.rb: rescue bug of 'grid configure' on Tcl/Tk8.3-
-
-Tue Dec 21 00:53:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/openssl/ossl_asn1.c (ossl_asn1_traverse): [ruby-dev:25261]
-
- * ext/openssl/ossl_asn1.c (ossl_asn1_decode): ditto.
-
- * ext/openssl/ossl_asn1.c (ossl_asn1_decode_all): ditto.
-
-Mon Dec 20 23:22:26 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-
- * added files:
- * lib/soap/mapping/wsdl*.rb
- * lib/wsdl/soap/element.rb
- * lib/wsdl/xmlSchema/simpleContent.rb
-
- * modified files:
- * lib/soap/*
- * lib/wsdl/*
- * lib/xsd/*
- * test/soap/*
- * test/wsdl/*
- * test/xsd/*
- * sample/soap/*
- * sample/sdl/*
-
- * summary
- * imported from the soap4r repository. Version: 1.5.3-ruby1.8.2
-
- * added several XSD basetype support: nonPositiveInteger,
- negativeInteger, nonNegativeInteger, unsignedLong, unsignedInt,
- unsignedShort, unsignedByte, positiveInteger
-
- * HTTP client connection/send/receive timeout support.
-
- * HTTP client/server gzipped content encoding support.
-
- * improved WSDL schema definition support; still is far from
- complete, but is making step by step improovement.
-
-Mon Dec 20 22:56:39 2004 Tanaka Akira <akr@m17n.org>
-
- * gc.c (stack_end_address): gcc noinline attribute is available since
- gcc-3.1.
-
-Mon Dec 20 14:07:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/multi-tk.rb: supports new features of Tcl/Tk8.5a2
-
- * ext/tk/lib/tk/clock.rb: ditto
-
- * ext/tk/lib/tk/text.rb: ditto
-
- * ext/tk/lib/tk/panedwindow.rb: ditto
-
-Mon Dec 20 12:47:13 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/lib/net/https.rb,protocols.rb,telnets.rb: delete
- doc and code about SSLContext#{key_file,cert_file}.
- fixed: [ruby-dev:25243]
-
-Mon Dec 20 12:42:17 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (io_fwrite): workaround for MSVCRT's bug.
- fixed: [ruby-core:03982]
-
-Mon Dec 20 11:21:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (rb_io_eof): check if closed before clearerr().
- fixed: [ruby-dev:25251]
-
-Mon Dec 20 03:30:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/cgi/session.rb (CGI::Session#initialize): empty session id was
- used if request had no session key. fixed: [ruby-core:03981]
-
-Mon Dec 20 01:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * struct.c (make_struct): [ruby-dev:25249]
-
-Mon Dec 20 00:28:20 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rexml/encodings/SHIFT-JIS.rb: backported from CVS HEAD.
-
- * lib/rexml/encodings/SHIFT_JIS.rb: ditto.
-
-Sun Dec 19 17:19:48 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_x509store.c
- (ossl_x509store_set_time): add OpenSSL::X509::Store#time=.
- (ossl_x509stctx_set_time): add OpenSSL::X509::StoreContext#time=.
-
- * test/openssl/ossl_x509store.rb: test certificate validity times.
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_to_s): add optional
- second argument to specify the output format (see also
- X509_NAME_print_ex).
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_init): new constants:
- OpenSSL::X509::Name::COMPAT, OpenSSL::X509::Name::RFC2253,
- OpenSSL::X509::ONELINE, OpenSSL::X509::MULTILINE.
-
- * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name::RFC2253DN):
- new module to provide the parse for RFC2253 DN format.
-
- * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name.parse_rfc2253):
- new method to parse RFC2253 DN format.
-
- * test/openssl/ossl_x509name.rb: add tests about RFC2253 DN.
-
- * text/openssl/ssl_server.rb: try to listen ports from 20443 to 20542
- while EADDRINUSE is raised.
-
- * all changes in this entry are backport from 1.9.
-
-Sun Dec 19 17:24:59 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (enable_rpath): use rpath flag to embed the library
- path into extensions on ELF environment. [ruby-dev:25035]
-
-Sun Dec 19 11:01:25 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/test/unit.rb: use standalone runner for -e.
-
- * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner#options): accept
- multiple -p and -x options.
-
- * lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir#recursive_collect):
- ditto.
-
-Sat Dec 18 16:36:23 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/zlib/zlib.c (rb_deflate_s_deflate, rb_inflate_s_inflate):
- disallow interrupt by type conversion. fixed: [ruby-dev:25226]
-
-Sat Dec 18 15:16:41 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-
- * lib/webrick/httpauth.rb,
- lib/webrick/httpauth/{basicauth.rb,digestauth.rb}: use
- pack/unpack-template char "m" instead of lib/base64.rb to do base64
- encoding/decoding.
-
-Sat Dec 18 10:51:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (dir_open_dir): new function. [ruby-dev:25242]
-
-Fri Dec 17 18:07:01 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * test/readline/test_readline.rb: fix for BSD. Thanks, GOTOU Yuuzou.
- fixed: [ruby-dev:25218]
-
-Fri Dec 17 16:28:12 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: fix bug on setting up system encoding
-
- * ext/tk/lib/tk/event.rb: fix error on require process
-
- * ext/tk/lib/tk/font.rb: fix abnormal termination error on Windows
-
- * ext/tk/lib/tk/virtevent.rb: TkVirtualEvent::PreDefVirtEvent.new()
- accepts event-sequence arguments
-
- * ext/tk/lib/tk/text.rb: fail to dump embedded images
-
- * ext/tk/lib/tk/text.rb: tag_nextrange and tag_prevrange returns wrong
- types of values
-
- * ext/tk/lib/tk/texttag.rb: nextrange and prevrange returns wrong
- types of values
-
- * ext/tk/lib/tk/text.rb: add TkText::IndexModMethods module and
- TkText::IndexString class to treat text index modifiers
-
- * ext/tk/lib/tk/texttag.rb: use TkText::IndexModMethods module
-
- * ext/tk/lib/tk/textmark.rb: ditto
-
- * ext/tk/lib/tk/textimage.rb: ditto
-
- * ext/tk/lib/tk/textwindow.rb: ditto
-
- * ext/tk/lib/tk/textimage.rb: wrong gravity of text mark for embedded
- image
-
- * ext/tk/lib/tk/textwindow.rb: wrong gravity of text mark for
- embedded window
-
-Fri Dec 17 13:50:00 2004 Akiyoshi, Masamichi (akiyoshi@hp.com)
-
- * vms/vmsruby_private.c, vms/vmsruby_private.h: private routines
- for VMS port are added.
-
- * eval.c (ruby_init): change to call VMS private intialization routine.
-
-Fri Dec 17 13:33:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/cgi/session.rb (CGI::Session#initialize): control adding
- session_id hidden fields. fixed: [ruby-talk:123850]
-
-Thu Dec 16 23:25:25 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb, lib/drb/ssl.rb: backported from CVS HEAD.
- [druby-ja:101]
-
- * test/drb/test_drb.rb: adjust and reduce sleep (backported from
- CVS HEAD.)
-
-Thu Dec 16 18:44:58 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): should wait
- for reading request till data arrive. [ruby-talk:121068]
-
- * lib/webrick/server.rb (WEBrick::GenericServer#start_thread):
- should log about all accepted socket. [ruby-core:03962]
-
- * lib/webrick/accesslog.rb (WEBrick::AccessLog#setup_params):
- "%%" and "%u" are supported. [webricken:135]
-
- * lib/webrick/httpservlet/filehandler.rb
- (WEBrick::HTTPServlet::FileHandler#check_filename):
- :NondisclosureName is acceptable if it is Enumerable.
-
- * lib/webrick/config.rb (WEBrick::Config::FileHandler):
- default value of :NondisclosureName is [".ht*", "*~"].
-
-Thu Dec 16 18:36:52 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl.c (ossl_raise): refine message format.
-
-Thu Dec 16 16:29:44 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/sample/demos-en/widget: modify version check for
- supporting features
-
-Thu Dec 16 16:03:50 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/bindtag.rb: bug fix [ruby-talk: 123667]
-
- * ext/tk/lib/tk/timer.rb: accept :idle for the interval argument
-
- * ext/tk/lib/tk.rb: add TkComm._callback_entry?()
-
- * ext/tk/lib/multi-tk.rb: add MultiTkIp.cb_entry_class
-
- * ext/tk/lib/tk/canvas.rb: use TkComm._callback_entry?()
-
- * ext/tk/lib/tk/canvastag.rb: ditto
-
- * ext/tk/lib/tk/dialog.rb: ditto
-
- * ext/tk/lib/tk/optiondb.rb: ditto
-
- * ext/tk/lib/tk/text.rb: ditto
-
- * ext/tk/lib/tk/texttag.rb: ditto
-
- * ext/tk/lib/tk/textwindow.rb: ditto
-
- * ext/tk/lib/tk/timer.rb: ditto
-
- * ext/tk/lib/tk/validation.rb: ditto
-
- * ext/tk/lib/tkextlib/*: ditto
-
-Thu Dec 16 03:14:28 2004 Minero Aoki <aamine@loveruby.net>
-
- * lib/net/http.rb (basic_encode): return value of pack('m') may
- include multiple CR/LFs. Backported from main trunk (rev 1.112).
- [ruby-dev:25212]
-
-Thu Dec 16 00:33:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * hash.c (Init_Hash): remove custom "hash" and "eql?".
-
-Wed Dec 15 18:57:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/set.rb (Set::eql): wrong definition. [ruby-dev:25207]
-
-Wed Dec 15 18:48:42 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/curses/curses.c (window_subwin): call NUM2INT() before
- GetWINDOW(). (backported from CVS HEAD)
-
-Wed Dec 15 17:03:50 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.[ch] (rb_w32_isatty): new function to replace MSVCRT's
- isatty because it never sets errno. (backported from CVS HEAD)
-
-Wed Dec 15 15:39:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_x509name.c (ossl_x509name_to_a): avoid SEGV
- (rollback the previous commit).
-
-Wed Dec 15 16:10:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_obj_id_obsolete): warn always.
-
- * eval.c (rb_enable_super): ditto.
-
-Wed Dec 15 15:31:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/set.rb (Set#==): [ruby-dev:25206]
-
-Wed Dec 15 14:22:10 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_fdisset): check whether the handle is valid.
- fixed: [ruby-core:03959]
-
-Wed Dec 15 10:30:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/openssl/ossl_digest.c (ossl_digest_initialize): [ruby-dev:25198]
-
-Tue Dec 14 17:10:09 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_close): need to reset osfhnd().
-
-Tue Dec 14 14:03:57 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl.c (ossl_raise): avoid buffer overrun.
- [ruby-dev:25187]
-
-Tue Dec 14 12:36:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi/session.rb (CGI::Session::initialize): generate new
- session if given session_id does not exist. [ruby-list:40368]
-
-Mon Dec 13 18:13:52 2004 Tanaka Akira <akr@m17n.org>
-
- * gc.c (stack_end_address): new function to obtain stack end address.
- stack_end_address calls __builtin_frame_address(0) to obtain the
- frame pointer of a stack frame of stack_end_address. The address
- is the stack pointer of the caller's stack frame.
- (SET_STACK_END): use stack_end_address.
- This makes the conservative garbage collector to scan a stack frame
- of the garbage_collect function itself. This is required because
- callee-save registers may be stored in the frame.
- [ruby-dev:25158]
-
-Mon Dec 13 00:58:02 2004 Tanaka Akira <akr@m17n.org>
-
- * lib/pathname.rb (cleanpath_aggressive): make it private.
- (cleanpath_conservative): ditto.
- Suggested by Daniel Berger. [ruby-core:3914]
-
-Sun Dec 12 20:06:38 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb: backported from CVS HEAD.
-
-Sun Dec 12 10:35:10 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/generators/template/html/html.rb (RDoc::Page): Don't
- show an accessor's r/w flag if none was specified
-
-Sun Dec 12 10:14:03 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/rdoc.rb (RDoc::RDoc::parse_files): Never exclude files
- explicitly given on the command line.
-
-Sat Dec 11 20:12:21 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/drb.rb: add DRbRemoteError. [ruby-list:40348],
- [ruby-list:40390]
-
- * test/drb/drbtest.rb: ditto.
-
- * test/drb/ut_drb.rb: ditto.
-
-Sat Dec 11 15:38:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/jcode.rb (String::succ): [ruby-dev:25156]
-
-Sat Dec 11 12:41:55 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * eval.c (run_trap_eval): prototype; avoid VC++ warnings.
-
- * ext/socket/getaddrinfo.c: fix typo. fixed: [ruby-core:03947]
-
- * win32/win32.c: need to include dln.h.
-
-Sat Dec 11 00:10:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_reopen): [ruby-dev:25150]
-
-Fri Dec 10 08:39:27 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/socket/socket.c (sock_listen): get OpenFile just before calling
- listen(2). fixed: [ruby-dev:25149]
-
-Thu Dec 9 17:00:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
-
- * ext/socket/socket.c, ext/socket/getaddrinfo.c: port to VMS
-
-Thu Dec 9 16:31:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * ext/sdbm/init.c (GetDBM): typo.
-
-Thu Dec 9 16:05:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
-
- * defines.h: change path of vms.h
- * vms/vms.h: delete reference for snprintf()
- * vms/config.h: new file
- * vms/config.h_in: deleted
-
-Thu Dec 9 14:38:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_inspect): escape # which starts an expression
- substitution. fixed: [ruby-core:03922]
-
- * string.c (rb_str_dump): not escape # which isn't a substitution.
-
-Thu Dec 9 10:54:36 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dbm/dbm.c (fdbm_select): [ruby-dev:25132]
-
- * ext/sdbm/init.c: ditto.
-
- * ext/gdbm/gdbm.c: ditto.
-
-Thu Dec 9 03:08:36 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tcltklib/tcltklib.c (ip_init): set root-win title to "ruby" when
- the running script is '-e one-liner' or '-' (stdin).
-
- * ext/tcltklib/extconf.rb: add find_library("#{lib}#{ver}",..) for
- stub libs
-
- * ext/tk/lib/tk/textmark.rb: TkTextMarkCurrent and TkTextMarkAnchor
- have a wrong parent class.
-
- * ext/tk/lib/tk/dialog.rb: rename TkDialog2 --> TkDialogObj and
- TkWarning2 --> TkWarningObj (old names are changed to alias names)
-
- * ext/tk/lib/tk/dialog.rb: bug fix of treatment of 'prev_command'
- option and hashes for configuration
-
- * ext/tk/lib/tk/dialog.rb: add TkDialogObj#name to return the
- button name
-
- * ext/tk/lib/tk/radiobutton.rb: rename enbugged method value() ==>
- get_value() and value=(val) ==> set_value(val).
-
- * ext/tk/lib/tk/menu.rb: add TkMenu.new_menuspec
-
- * ext/tk/lib/tk/menu.rb: add alias (TkMenuButton = TkMenubutton,
- TkOptionMenuButton = TkOptionMenubutton)
-
- * ext/tk/lib/tk/event.rb: new method aliases (same as option keys of
- event_generate) for Event object
-
- * ext/tk/lib/tk/font.rb: configinfo returns proper types of values
-
- * ext/tk/lib/tk.rb: bind methods accept subst_args + block
-
- * ext/tk/lib/tk/canvas.rb: ditto
-
- * ext/tk/lib/tk/canvastag.rb: ditto
-
- * ext/tk/lib/tk/frame.rb: ditto
-
- * ext/tk/lib/tk/text.rb: ditto
-
- * ext/tk/lib/tk/texttag.rb: ditto
-
- * ext/tk/lib/tk/toplevel.rb: ditto
-
- * ext/tk/lib/tkextlib/*: ditto and bug fix
-
-Wed Dec 8 23:54:29 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/generators/template/html/html.rb (RDoc::Page): Typo
- meant that h2 tag was invisible.
-
-Wed Dec 8 21:56:31 2004 Kouhei Sutou <kou@cozmixng.org>
-
- * lib/rss, test/rss, sample/rss: backported from CVS HEAD.
-
-Wed Dec 8 14:31:36 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_fwrite): change dereference for cosmetic reason.
-
- * sprintf.c (rb_f_sprintf): [ruby-dev:25104]
-
-Tue Dec 7 19:08:00 2004 Akiyoshi, Masamichi <akiyoshi@hp.com>
-
- * io.c (io_fwrite): fix offset incrementation (for VMS and Human68k)
-
-Tue Dec 7 00:27:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * process.c (proc_setgroups): [ruby-dev:25081]
-
-Mon Dec 6 18:08:10 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_eqq): document fix. [ruby-talk:122541]
-
-Mon Dec 6 17:19:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * rubysig.h (TRAP_BEG, TRAP_END): safe errno around CHECK_INTS.
- (backported from CVS HEAD) [ruby-dev:24993]
-
-Mon Dec 6 10:18:17 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::look_for_directives_in):
- Oops - 1.8 doesn't have String#clear
-
-Mon Dec 6 09:59:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (sock_connect): use rb_str_new4().
- [ruby-dev:25052]
-
-Mon Dec 6 01:42:08 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_public_encrypt,
- ossl_rsa_public_decrypt, ossl_rsa_private_encrypt,
- ossl_rsa_private_decrypt): should take an optional argument
- to specify padding mode. [ruby-talk:122539]
-
- * ext/openssl/ossl_pkey_rsa.c (Init_ossl_rsa): add new constants
- PKCS1_PADDING, SSLV23_PADDING, NO_PADDING and PKCS1_OAEP_PADDING
- under OpenSSL::PKey::RSA.
-
- * test/openssl/test_pkey_rsa.rb: new file.
-
-Sun Dec 5 19:39:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (OptionParser::Completion#complete): new parameter
- to direct case insensitiveness.
-
- * lib/optparse.rb (OptionParser#order!): ignore case only for long
- option. [ruby-dev:25048]
-
-Sat Dec 4 22:54:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_write): remove rb_str_locktmp(). [ruby-dev:25050]
-
- * io.c (io_fwrite): takes VALUE string as an argument.
- [ruby-dev:25050]
-
- * ext/socket/socket.c (sock_connect): remove rb_str_locktmp().
- [ruby-dev:25050]
-
- * ext/socket/socket.c (udp_connect): [ruby-dev:25045]
-
- * ext/socket/socket.c (udp_bind): ditto.
-
- * ext/socket/socket.c (udp_send): ditto.
-
- * ext/socket/socket.c (bsock_send): ditto.
-
- * ext/socket/socket.c (s_recvfrom): ditto.
-
- * hash.c (rb_hash_hash): should provide "hash" method where "eql?"
- is redefined. [ruby-talk:122482]
-
-Sat Dec 4 14:54:52 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * eval.c (proc_invoke): use volatile `tmp' rather than `args'.
- [ruby-core:03882]
-
-Sat Dec 4 14:28:56 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/code_objects.rb (RDoc::Context::Section::set_comment):
- Section comments may now be bracketed by lines which are
- ignored. You can now write
- # -----------
- # :section: Dave's Section
- # comment material
- # -----------
- The lines before :section: are removed, and identical lines at the end are
- also removed if present.
-
-Sat Dec 4 03:33:45 2004 Shugo Maeda <shugo@ruby-lang.org>
-
- * ext/readline/readline.c: check $SAFE. (backported from CVS HEAD)
-
- * test/readline/test_readline.rb: added tests for readline.
- (backported from CVS HEAD)
-
-Fri Dec 4 02:24:00 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf.c: add constant NKF::VERSION
-
- * ext/nkf/nkf.c(guess): this becomes an alias of guess2
-
- * ext/nkf/test.rb(mime_out2): add --no-cp932
-
- * ext/nkf/nkf-utf8/nkf.c: original nkf2 revision 1.47
-
-Sat Dec 4 00:35:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039]
-
-Fri Dec 3 18:57:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/ostruct.rb: 1.9 marshaling support back-ported.
- [ruby-core:03871]
-
-Fri Dec 3 13:45:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_invoke): copy arguments to frame.argv.
- [ruby-core:03861]
-
-Fri Dec 3 12:25:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * st.h: fix prototypes.
-
-Fri Dec 3 00:21:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (convert_type): use rb_respond_to() again.
- [ruby-dev:25021]
-
- * eval.c (rb_respond_to): funcall respond_to? if it's redefined.
- [ruby-dev:25021]
-
-Fri Dec 3 01:55:24 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: widget configuration by TkWindow#method_missing
- returns proper object. "widget.option = val" returns val, and
- "widget.option(val)" returns self.
-
- * ext/tk/lib/tk/font.rb: TkFont#replace accepts only one font argument.
-
- * ext/tk/lib/tk/radiobutton.rb: add TkRadiobutton#value and
- TkRadiobutton#value=(val).
-
- * ext/tk/lib/tk/spinbox.rb: callback substitution support on
- command option.
-
- * ext/tk/sample/demos-en/widget: bug fix (wrong image height)
-
- * ext/tk/sample/demos-jp/widget: ditto.
-
-Fri Dec 3 00:11:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_file_initialize): [ruby-dev:25032]
-
-Thu Dec 2 16:41:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_protect): prevent continuations created inside from being
- called from the outside. [ruby-dev:25003]
-
- * eval.c (rb_callcc, rb_cont_call): prohibit calling from different
- signal contexts. [ruby-dev:25022]
-
-Thu Dec 2 09:57:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/ostruct.rb (OpenStruct::Marshaler): OpenStruct can be
- marshaled again. [ruby-core:03862]
-
-Thu Dec 2 09:30:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (thread_mark): mark thread group. [ruby-dev:25020]
-
- * eval.c (thgroup_add): check whether the argument is really a Thread.
-
-Thu Dec 2 07:57:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_ctl): [ruby-dev:25019]
-
-Wed Dec 1 02:21:02 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * signal.c (sighandler): call handler immediately only for default
- handlers. [ruby-dev:25003]
-
-Tue Nov 30 23:38:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (io_fread): need not to null terminate. [ruby-dev:24998]
-
- * io.c (read_all): remove unnecessary rb_str_resize().
- [ruby-dev:24996] (backported from CVS HEAD)
-
- * io.c (io_readpartial): ditto.
-
- * io.c (io_read): ditto.
-
-Tue Nov 30 16:18:50 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_fread): need not to null terminate. [ruby-dev:24998]
-
- * io.c (read_all): remove unnecessary rb_str_resize().
- [ruby-dev:24996]
-
- * io.c (io_read): ditto.
-
-Tue Nov 30 00:49:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]
-
-Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_write): insufficiently filled string
- being extended when overwriting. [ruby-core:03836]
-
-Mon Nov 29 15:59:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/ostruct.rb (OpenStruct::method_missing): check method
- duplication for -d.
-
- * lib/ostruct.rb (OpenStruct::initialize): ditto.
-
-Mon Nov 29 15:22:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * test/io/nonblock/test_flush.rb: abandon tests when io/nonblock is
- not supported.
-
-Mon Nov 29 03:08:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (convert_type): [ruby-core:03845]
-
- * eval.c (rb_funcall_rescue): new function.
-
- * object.c (rb_Array): avoid using rb_respond_to().
-
- * object.c (rb_Integer): ditto.
-
- * parse.y (reduce_nodes): empty body should return nil.
-
- * string.c (rb_str_aset): [ruby-dev:24981]
-
-Mon Nov 29 13:57:38 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (CreateChild): search executable file if no program
- name given. (backported from CVS HEAD)
-
-Mon Nov 29 13:37:54 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (fptr_finalize): must not use FILE after fclose().
- [ruby-dev:24985]
-
-Mon Nov 29 13:16:31 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (CreateChild): push back the last space before next
- loop because CharNext() eats it.
-
-Mon Nov 29 01:18:18 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c (rb_io_check_writable): call io_seek regardless of
- NEED_IO_SEEK_BETWEEN_RW. [ruby-dev:24986]
-
-Sat Nov 27 21:43:39 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c: avoid data lost with nonblocking fd and
- stdio buffering in sync mode. [ruby-dev:24966]
- based on matz's patch [ruby-dev:24967]
- (io_fwrite): new primitive writing function which writes
- directly if sync mode.
- (rb_io_fwrite): wrapper for io_fwrite now.
- (io_write): call io_fwrite instead of rb_io_fwrite.
-
-Sat Nov 27 14:44:15 2004 Kent Sibilev <ksibilev@bellsouth.net>
-
- * lib/cgi/session.rb (CGI::Session::initialize): [ruby-core:03832]
-
-Sat Nov 27 09:41:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_fread): old rb_io_fread with file closing checking.
- (rb_io_fread): wrapper for io_fread now.
- [ruby-dev:24964]
-
-Fri Nov 26 18:02:44 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: Tk.destroy uses TkWindow#epath
-
- * ext/tk/lib/tk/image.rb: bug fix
-
- * ext/tk/lib/tk/wm.rb: add 'iconphoto' method(Windows only)
-
- * ext/tk/lib/tkextlib/*: some methods uses TkWindow#epath
-
-Fri Nov 26 13:49:06 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (method_missing): raise TypeError for classes do not
- have allocators. [ruby-core:03752]
-
- * lib/erb.rb: add RDoc by James Edward Gray II. [ruby-core:03786]
-
-Fri Nov 26 13:29:02 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::look_for_directives_in): Break
- out of preprocessing when we find a :section: directive (previously cleared out the
- comment, but this apparently now generates an error in gsub!)
-
-Fri Nov 26 00:17:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_read): move StringValue() check before GetOpenFile().
- [ruby-dev:24959]
-
-Thu Nov 25 20:14:57 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/thwait.rb (ThreadsWait#join_nowait): abnormally terminated
- threads should be also processed. [ruby-talk:121320]
-
-Thu Nov 25 10:14:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (push_braces): do not reuse buffer strings. [ruby-core:03806]
-
-Thu Nov 25 07:59:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (read_all): stringify non-nil buffer argument, and always
- taint the result. [ruby-dev:24955]
-
-Wed Nov 24 01:01:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (io_read): integer conversion should be prior to
- GetOpenFile(). [ruby-dev:24952]
-
- * configure.in, io.c: cancel [ ruby-Patches-1074 ].
-
-Tue Nov 23 08:09:50 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/menu.rb: improve usability of TkOptionMenubutton
-
-Tue Nov 23 02:00:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (rb_file_chown): integer conversion should be prior to
- GetOpenFile(). [ruby-dev:24949]
-
-Tue Nov 23 00:10:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (rb_file_chown): integer conversion should be prior to
- GetOpenFile(). [ruby-dev:24947]
-
- * file.c (rb_file_truncate): ditto.
-
- * file.c (rb_file_s_truncate): ditto.
-
- * dir.c (dir_seek): use NUM2OFFT().
-
- * misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719]
-
-Mon Nov 22 22:33:02 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Don't use names
- of variables or constants when oarsing 'require'
-
-Mon Nov 22 00:13:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (dir_seek): should retrieve dir_data after NUM2INT().
- [ruby-dev:24941]
-
-Sat Nov 20 23:57:33 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/README (et al): Add a new directive, :section:, and
- change the output format to accomodate. :section: allows to to
- group together methods, attributes, constants, etc under
- headings in the output. If used, a table of contents is
- generated.
-
-Sat Nov 20 23:56:54 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/options.rb (Options::parse): Force --inline-source if
- --one-file option given
-
-Sat Nov 20 23:55:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_splice): should place index wrapping after
- possible modification. [ruby-dev:24940]
-
-Tue Nov 20 13:26:03 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/utf8tbl.c: original revision 1.7
-
-Tue Nov 20 05:34:24 2004 NARUSE, Yui <naruse@ruby-lang.org>
-
- * ext/nkf/nkf-utf8/nkf.c: original nkf.c rev:1.40
-
- * ext/nkf/test.rb: add test for mime encode/decode
-
-Sat Nov 20 01:37:34 2004 Johan Holmberg <holmberg@iar.se>
-
- * eval.c (error_print): nicer traceback at interrupt.
- [ruby-core:03774]
-
-Sat Nov 20 00:07:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (str_gsub): internal buffer should not be listed by
- ObjectSpace.each_object() by String#gsub. [ruby-dev:24931]
-
-Fri Nov 19 01:20:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
- exception if data corresponding to session specified from the
- client does not exist.
-
-Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (str_gsub): internal buffer should not be listed by
- ObjectSpace.each_object(). [ruby-dev:24919]
-
-Thu Nov 18 18:41:08 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-
- * test/ruby/test_stringchar.rb (test_bang): added.
-
- * string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
- (rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
-
-Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * process.c (proc_getpgrp): prohibit for $SAFE=2.
- [ruby-dev:24899]
-
- * process.c (get_pid): ditto. [ruby-dev:24904]
-
- * process.c (get_ppid): ditto.
-
- * array.c (rb_ary_delete): defer rb_ary_modify() until actual
- modification. [ruby-dev:24901]
-
-Thu Nov 18 10:10:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c, rubyio.h (rb_io_modenum_flags): exported.
-
- * ext/stringio/stringio.c (strio_initialize): allow Fixnum as mode as
- well as IO.new does. [ruby-dev:24896]
-
-Wed Nov 17 23:42:40 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-
- * test/ruby/test_settracefunc.rb: added. [ruby-dev:24884]
-
-Wed Nov 17 13:56:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (newline_node): should not use FL_SET. [ruby-dev:24874]
-
- * parse.y (string_content): should not use FL_UNSET.
-
- * node.h (NODE_NEWLINE): remove unused bit to utilize flag field
- in nodes.
-
-Wed Nov 17 13:09:40 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * {bcc32,win32,wince}/Makefile.sub (test): should build ruby.exe
- before running test. [ruby-core:03756]
-
-Wed Nov 17 04:33:01 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * pack.c: all features are backport from 1.9. [ruby-dev:24826]
-
- * bignum.c (rb_big2ulong_pack): new function to pack Bignums.
-
-Wed Nov 17 03:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_splice): move rb_str_modify() after
- StringValue(), which may alter the receiver. [ruby-dev:24878]
-
-Tue Nov 16 23:45:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (flo_divmod): protect float values from GC by
- assignment to local variables. [ruby-dev:24873]
-
-Tue Nov 16 16:30:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * {bcc32,win32,wince}/setup.mak (-epilogue-): remove config.h and
- config.status to force updating them.
-
-Tue Nov 16 16:20:45 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/stringio/stringio.c (strio_read): position was ignored when a
- buffer was passed. http://www.yo.rim.or.jp/~nov/d/?date=20041116#p03
-
-Tue Nov 16 11:19:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::options): use
- Regexp conversion.
-
-Tue Nov 16 01:41:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (str_mod_check): frozen check should be separated.
- [ruby-core:3742]
-
- * array.c (rb_ary_update): pedantic check to detect
- rb_ary_to_ary() to modify the receiver. [ruby-dev:24861]
-
-Mon Nov 15 13:50:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_justify): typo fixed. [ruby-dev:24851]
-
-Mon Nov 15 11:50:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-mode.el (ruby-special-char-p, ruby-parse-partial): handle
- operator symbols. [ruby-talk:120177]
-
-Sun Nov 14 13:27:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/pp.rb (PP#object_address_group): remove odd number of 'f'
- prefixed to negative address.
-
-Sun Nov 14 08:51:04 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-
- * test/logger/test_logger.rb: Logger just expects
- Logger#datetime_format to be used for Time#strftime independently of
- locale. [ruby-dev:24828]
-
-Fri Nov 12 15:03:26 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * eval.c (ruby_options): now we cannot call rb_glob() before
- ruby_init(), so call rb_w32_cmdvector() at ruby_options().
-
- * win32.{c,h} (rb_w32_cmdvector): rename make_cmdvector() and
- export it.
-
-Fri Nov 12 14:08:01 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk/event.rb: remove $LOADED_FEATURES trick
-
- * ext/tk/lib/tk.rb: ditto
-
-Fri Nov 12 00:31:05 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/gdbm/gdbm.c (fgdbm_store): StringValue() may alter string
- pointer. [ruby-dev:24783]
-
-Thu Nov 11 17:36:12 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * dir.c (rb_globi): also should call back via rb_glob_caller().
- [ruby-dev:24775]
-
-Thu Nov 11 16:47:21 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * test/ruby/test_file.rb (test_truncate_wbuf): we want to test
- only File#truncate, not behaviour of seek(2).
-
-Thu Nov 11 09:41:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (push_braces): was confusing VALUE and char*.
-
- * dir.c (rb_push_glob): Dir.glob should have called its block.
-
-Thu Nov 11 01:52:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * error.c (syserr_initialize): use stringified object.
- [ruby-dev:24768]
-
-Wed Nov 10 22:49:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/delegate.rb (SimpleDelegator::dup): wrong number of
- arguments.
-
- * lib/delegate.rb (DelegateClass::dup): ditto.
-
-Wed Nov 10 12:31:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * README.EXT (Example): extconf.rb is indispensable now.
-
-Wed Nov 10 03:33:36 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tcltklib/tcltklib.c: fix SEGV when compiled with Tcl/Tk8.3.x
- or older
-
- * ext/tk/lib/tkextlib/tile/style.rb: bug fix
-
-Tue Nov 9 14:27:18 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/optparse.rb (OptionParser::Officious): moved from DefaultList.
-
-Tue Nov 9 01:05:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (rb_glob2): do not allocate buffer from heap to avoid
- memory leaks. use string object for buffering instead.
- [ruby-dev:24738]
-
- * dir.c (join_path): ditto.
-
- * io.c (io_read): external input buffer may be modified even after
- rb_str_locktmp(). [ruby-dev:24735]
-
- * dir.c (fnmatch): p or s may be NULL. [ruby-dev:24749]
-
-Tue Nov 9 00:53:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * regex.c (slow_match): avoid GCC 3.4.x warnings.
-
-Tue Nov 9 00:50:06 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/rdoc.rb: Change version numbering of RDoc and ri
-
-Mon Nov 8 23:38:35 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/drb/extservm.rb: add DRb::ExtServManager#uri=.
- [ruby-dev:24743]
-
-Mon Nov 8 22:20:19 2004 Dave Thomas <dave@pragprog.com>
-
- * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_class):
- Fix bug where parent class wasn't being detected if the
- child class was defined using the A::B notation.
-
-Mon Nov 8 00:14:13 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in: add setup for mignw32 cross compiling.
- [ruby-talk:119413]
-
-Sun Nov 7 23:49:26 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-
- * ext/tk/lib/tk.rb: bind-event methods accept multi substitution
- arguments.
-
- * ext/tk/lib/tk/canvas.rb: ditto.
-
- * ext/tk/lib/tk/canvastag.rb: ditto.
-
- * ext/tk/lib/tk/text.rb: ditto.
-
- * ext/tk/lib/tk/texttag.rb: ditto.
-
- * ext/tk/lib/tkextlib: ditto.
-
-Sat Nov 6 14:58:44 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/server.rb (WEBrick::HTTPServer#start): remove
- :DoNotReverseLookup option. (Socket#do_not_reverse_lookup is a
- ruby 1.9 feature)
-
-Sat Nov 6 11:31:04 2004 Tadayoshi Funaba <tadf@dotrb.org>
-Sat Nov 6 00:46:27 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_locktmp): check STR_TMPLOCK flag before
- locking. [ruby-dev:24727]
-
-
- * lib/date.rb (_parse): checks whether zone was given.
-
Sat Nov 6 00:46:27 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_locktmp): check STR_TMPLOCK flag before
@@ -1160,7 +5,7 @@ Sat Nov 6 00:46:27 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
Fri Nov 5 18:12:42 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
+ * ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
X_Scrollable and Y_Scrollable
* ext/tk/lib/tk/entry.rb: include X_Scrollable instead of Scrollable
@@ -1184,10 +29,6 @@ Fri Nov 5 08:52:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (gc_mark): stricter GC stack check.
-Fri Nov 5 08:52:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (gc_mark): stricter GC stack check.
-
Fri Nov 5 08:34:43 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (str_gsub): should have removed rb_str_unlocktmp(str).
@@ -1222,7 +63,7 @@ Wed Nov 3 22:32:12 2004 NARUSE, Yui <naruse@ruby-lang.org>
* process.c: On NetBSD don't use setruid() and setrgid().
-Wed Nov 3 22:24:17 2004 Daigo Moriwaki <techml@sgtpepper.net>
+Wed Nov 3 22:24:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpauth/digestauth.rb: use Base64.encode64 to
avoid warnings.
@@ -1242,12 +83,12 @@ Wed Nov 3 17:13:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Wed Nov 3 16:58:07 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/lib/tk.rb: support to use different Tcl commands between
+ * ext/tk/lib/tk.rb: support to use different Tcl commands between
configure and configinfo
* ext/tk/lib/font.rb: ditto.
- * ext/tk/lib/itemconfig.rb: support to use different Tcl commands
+ * ext/tk/lib/itemconfig.rb: support to use different Tcl commands
between item_configure and item_configinfo
* ext/tk/lib/itemfont.rb: ditto.
@@ -1265,7 +106,7 @@ Wed Nov 3 15:53:34 2004 Kouhei Sutou <kou@cozmixng.org>
* test/rss/test_maker_*.rb: added tests for RSS Maker.
* lib/rss/maker.rb: added RSS Maker.
-
+
* lib/rss/maker/*.rb: ditto.
Tue Nov 2 16:35:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -1339,12 +180,6 @@ Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ruby_cleanup): ruby_finalize_1 may cause exception,
should be wrapped by PUSH_TAG/POP_TAG(). [ruby-dev:24627]
-Thu Oct 28 08:42:02 2004 Tanaka Akira <akr@m17n.org>
-
- * io.c (argf_forward): use ANSI style.
- (argf_read): call argf_forward with argv argument.
- [ruby-dev:24624]
-
Thu Oct 28 23:32:54 2004 akira yamada <akira@ruby-lang.org>
* ext/zlib/zlib.c (zstream_detach_input): resets klass of z->input if
@@ -1451,11 +286,6 @@ Fri Oct 22 00:20:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_include): should not treat char as negative value.
[ruby-dev:24558]
-Thu Oct 21 21:32:30 2004 IWATSUKI Hiroyuki <don@na.rim.or.jp>
-
- * lib/pstore.rb (PStore#transaction): Use the empty content when a
- file is not found. [ruby-dev:24561]
-
Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
@@ -1544,11 +374,6 @@ Mon Oct 18 15:58:01 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* range.c (range_step, range_each): need cast.
-Fri Oct 29 16:34:19 2004 Daiki Ueno <ueno@unixuser.org>
-
- * misc/ruby-mode.el (ruby-parse-partial): Parse the rest of the
- line after opening heredoc identifier. [ruby-dev:24635]
-
Mon Oct 18 07:26:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_truncate): discard read buffer before truncation.
diff --git a/README.EXT b/README.EXT
index e5c4203832..d832d1e0af 100644
--- a/README.EXT
+++ b/README.EXT
@@ -595,7 +595,8 @@ are not exported to the Ruby world. You need to protect them by
(4) prepare extconf.rb
If the file named extconf.rb exists, it will be executed to generate
-Makefile.
+Makefile. If not, the compilation scheme will try to generate Makefile
+anyway.
extconf.rb is the file for check compilation conditions etc. You
need to put
diff --git a/array.c b/array.c
index 4ba3f7390d..03647f81fd 100644
--- a/array.c
+++ b/array.c
@@ -270,6 +270,7 @@ rb_ary_initialize(argc, argv, ary)
long len;
VALUE size, val;
+ rb_ary_modify(ary);
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
RARRAY(ary)->len = 0;
if (rb_block_given_p()) {
@@ -293,7 +294,6 @@ rb_ary_initialize(argc, argv, ary)
if (len > 0 && len * (long)sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
- rb_ary_modify(ary);
if (len > RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
RARRAY(ary)->aux.capa = len;
@@ -352,6 +352,7 @@ rb_ary_store(ary, idx, val)
long idx;
VALUE val;
{
+ rb_ary_modify(ary);
if (idx < 0) {
idx += RARRAY(ary)->len;
if (idx < 0) {
@@ -360,7 +361,6 @@ rb_ary_store(ary, idx, val)
}
}
- rb_ary_modify(ary);
if (idx >= RARRAY(ary)->aux.capa) {
long new_capa = RARRAY(ary)->aux.capa / 2;
@@ -938,7 +938,7 @@ rb_ary_to_ary(obj)
}
static void
-rb_ary_splice(ary, beg, len, rpl)
+rb_ary_update(ary, beg, len, rpl)
VALUE ary;
long beg, len;
VALUE rpl;
@@ -957,6 +957,7 @@ rb_ary_splice(ary, beg, len, rpl)
len = RARRAY(ary)->len - beg;
}
+ rb_ary_modify(ary);
if (NIL_P(rpl)) {
rlen = 0;
}
@@ -964,7 +965,6 @@ rb_ary_splice(ary, beg, len, rpl)
rpl = rb_ary_to_ary(rpl);
rlen = RARRAY(rpl)->len;
}
- rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
len = beg + rlen;
@@ -1045,7 +1045,7 @@ rb_ary_aset(argc, argv, ary)
if (SYMBOL_P(argv[1])) {
rb_raise(rb_eTypeError, "Symbol as subarray length");
}
- rb_ary_splice(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
+ rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
return argv[2];
}
if (argc != 2) {
@@ -1060,7 +1060,7 @@ rb_ary_aset(argc, argv, ary)
}
if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
/* check if idx is Range */
- rb_ary_splice(ary, beg, len, argv[1]);
+ rb_ary_update(ary, beg, len, argv[1]);
return argv[1];
}
@@ -1102,7 +1102,7 @@ rb_ary_insert(argc, argv, ary)
}
if (argc == 1) return ary;
- rb_ary_splice(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
+ rb_ary_update(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
return ary;
}
@@ -1849,6 +1849,7 @@ rb_ary_delete(ary, item)
{
long i1, i2;
+ rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
VALUE e = RARRAY(ary)->ptr[i1];
@@ -1865,7 +1866,6 @@ rb_ary_delete(ary, item)
return Qnil;
}
- rb_ary_modify(ary);
if (RARRAY(ary)->len > i2) {
RARRAY(ary)->len = i2;
if (i2 * 2 < RARRAY(ary)->aux.capa &&
@@ -1886,13 +1886,13 @@ rb_ary_delete_at(ary, pos)
long i, len = RARRAY(ary)->len;
VALUE del;
+ rb_ary_modify(ary);
if (pos >= len) return Qnil;
if (pos < 0) {
pos += len;
if (pos < 0) return Qnil;
}
- rb_ary_modify(ary);
del = RARRAY(ary)->ptr[pos];
for (i = pos + 1; i < len; i++, pos++) {
RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
@@ -1957,6 +1957,7 @@ rb_ary_slice_bang(argc, argv, ary)
VALUE arg1, arg2;
long pos, len;
+ rb_ary_modify(ary);
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
pos = NUM2LONG(arg1);
len = NUM2LONG(arg2);
@@ -1965,7 +1966,7 @@ rb_ary_slice_bang(argc, argv, ary)
pos = RARRAY(ary)->len + pos;
}
arg2 = rb_ary_subseq(ary, pos, len);
- rb_ary_splice(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
+ rb_ary_update(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
return arg2;
}
@@ -2337,7 +2338,7 @@ rb_ary_concat(x, y)
{
y = to_ary(y);
if (RARRAY(y)->len > 0) {
- rb_ary_splice(x, RARRAY(x)->len, 0, y);
+ rb_ary_update(x, RARRAY(x)->len, 0, y);
}
return x;
}
@@ -2753,6 +2754,8 @@ rb_ary_uniq_bang(ary)
VALUE hash, v, vv;
long i, j;
+ rb_ary_modify(ary);
+
hash = ary_make_hash(ary, 0);
if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) {
@@ -2883,7 +2886,7 @@ flatten(ary, idx, ary2, memo)
rb_raise(rb_eArgError, "tried to flatten recursive array");
}
rb_ary_push(memo, id);
- rb_ary_splice(ary, idx, 1, ary2);
+ rb_ary_update(ary, idx, 1, ary2);
while (i < lim) {
VALUE tmp;
@@ -2921,6 +2924,7 @@ rb_ary_flatten_bang(ary)
int mod = 0;
VALUE memo = Qnil;
+ rb_ary_modify(ary);
while (i<RARRAY(ary)->len) {
VALUE ary2 = RARRAY(ary)->ptr[i];
VALUE tmp;
diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub
index d04c649fa5..0c4c6bb126 100644
--- a/bcc32/Makefile.sub
+++ b/bcc32/Makefile.sub
@@ -476,7 +476,7 @@ realclean: distclean
@if exist parse.c del parse.c
@if exist lex.c del lex.c
-test: miniruby$(EXEEXT) rbconfig.rb $(PROGRAM) NUL
+test: miniruby$(EXEEXT) NUL
@$(MINIRUBY) $(srcdir)rubytest.rb
rbconfig.rb: miniruby$(EXEEXT) config.status
diff --git a/bcc32/setup.mak b/bcc32/setup.mak
index 1a243af9b6..3b37b92fa8 100644
--- a/bcc32/setup.mak
+++ b/bcc32/setup.mak
@@ -86,6 +86,4 @@ PROCESSOR_LEVEL = $(PROCESSOR_LEVEL)
\# EXTLIBS = cw32.lib import32.lib user32.lib kernel32.lib
$(INCLUDE) $$(srcdir)bcc32/Makefile.sub
|
- @if exist config.h del config.h
- @if exist config.status del config.status
@echo type "`$(MAKE)'" to make ruby for $(OS).
diff --git a/bignum.c b/bignum.c
index aba88df04d..06228416bf 100644
--- a/bignum.c
+++ b/bignum.c
@@ -748,17 +748,6 @@ big2ulong(x, type)
}
unsigned long
-rb_big2ulong_pack(x)
- VALUE x;
-{
- unsigned long num = big2ulong(x, "unsigned long", Qfalse);
- if (!RBIGNUM(x)->sign) {
- return -num;
- }
- return num;
-}
-
-unsigned long
rb_big2ulong(x)
VALUE x;
{
diff --git a/configure.in b/configure.in
index b38b59bb68..641954adfe 100644
--- a/configure.in
+++ b/configure.in
@@ -308,11 +308,6 @@ mingw*) LIBS="-lwsock32 $LIBS"
ac_cv_func_isnan=yes
ac_cv_func_finite=yes
ac_cv_lib_crypt_crypt=no
- ac_cv_func_getpgrp_void=no
- ac_cv_func_setpgrp_void=yes
- ac_cv_func_memcmp_working=yes
- rb_cv_binary_elf=no
- rb_cv_negative_time_t=no
enable_pthread=no
;;
os2-emx*) LIBS="-lm $LIBS"
@@ -787,6 +782,14 @@ linux* | gnu* | k*bsd*-gnu)
else
LDFLAGS="$LDFLAGS -rdynamic"
fi;;
+netbsd*|openbsd*)
+ if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
+ then
+ netbsd_elf=yes
+ else
+ netbsd_elf=no
+ fi
+ ;;
esac
LIBEXT=a
@@ -853,11 +856,8 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes ;;
osf*) : ${LDSHARED="ld -shared -expect_unresolved \"*\""}
rb_cv_dlopen=yes ;;
- linux* | gnu* | k*bsd*-gnu | netbsd*)
- : ${LDSHARED='${CC} -shared'}
- if test "$rb_cv_binary_elf" = yes; then
- LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
- fi
+ linux* | gnu* | k*bsd*-gnu)
+ : ${LDSHARED="$CC -shared"}
rb_cv_dlopen=yes ;;
interix*) : ${LDSHARED="$CC -shared"}
XLDFLAGS="$XLDFLAGS -Wl,-E"
@@ -871,6 +871,13 @@ if test "$with_dln_a_out" != yes; then
test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="ld -Bshareable"
fi
rb_cv_dlopen=yes ;;
+ netbsd*) : ${LDSHARED='${CC} -shared'}
+ if test "$rb_cv_binary_elf" = yes; then
+ LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
+ LIBPATHFLAG=" -L'%1\$-s'"
+ RPATHFLAG=" -Wl,-R'%1\$-s'"
+ fi
+ rb_cv_dlopen=yes ;;
openbsd*) : ${LDSHARED="\$(CC) -shared ${CCDLFLAGS}"}
if test "$rb_cv_binary_elf" = yes; then
LDFLAGS="$LDFLAGS -Wl,-E"
@@ -937,14 +944,6 @@ if test "$with_dln_a_out" != yes; then
*) : ${LDSHARED='ld'} ;;
esac
AC_MSG_RESULT($rb_cv_dlopen)
-
- AC_ARG_ENABLE(rpath,
- [ --disable-rpath embed run path into extension libraries.],
- [enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
- if test "$enable_rpath" = yes; then
- LIBPATHFLAG=" -L'%1\$-s'"
- RPATHFLAG=" -Wl,-R'%1\$-s'"
- fi
fi
AC_SUBST(LINK_SO)
AC_SUBST(LIBPATHFLAG)
@@ -1153,7 +1152,7 @@ if test "$enable_shared" = 'yes'; then
sunos4*)
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
;;
- linux* | gnu* | k*bsd*-gnu | atheos*)
+ linux* | gnu* | k*bsd*-gnu)
LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
;;
@@ -1169,6 +1168,7 @@ if test "$enable_shared" = 'yes'; then
SOLIBS='$(LIBS)'
LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)'
LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
+ LIBRUBYARG_SHARED='-Wl,-R -Wl,${libdir} -L${libdir} -L. -l$(RUBY_SO_NAME)'
if test "$rb_cv_binary_elf" = yes; then # ELF platforms
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so'
else # a.out platforms
@@ -1180,14 +1180,6 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
;;
solaris*)
- SOLIBS='$(LIBS)'
- LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)'
- LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so'
- if test "$GCC" = yes; then
- LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)'
- else
- enable_rpath=no
- fi
XLDFLAGS="$XLDFLAGS "'-R${libdir}'
;;
hpux*)
@@ -1219,6 +1211,10 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_DLDFLAGS='-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
;;
+ atheos*)
+ LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
+ ;;
interix*)
LIBRUBYARG_SHARED='-L${libdir} -L. -l$(RUBY_SO_NAME)'
;;
@@ -1226,10 +1222,6 @@ if test "$enable_shared" = 'yes'; then
;;
esac
fi
-if test "$enable_rpath" = yes; then
- LIBRUBYARG_SHARED='-Wl,-R -Wl,$(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED"
-fi
-
XLDFLAGS="$XLDFLAGS -L."
AC_SUBST(ARCHFILE)
diff --git a/defines.h b/defines.h
index a059a29b47..77f3f40a55 100644
--- a/defines.h
+++ b/defines.h
@@ -185,7 +185,7 @@ typedef int pid_t;
#endif
#if defined(__VMS)
-#include "vms.h"
+#include "vms/vms.h"
#endif
#if defined(__BEOS__)
diff --git a/dir.c b/dir.c
index 97b78cb2d2..2de990ad8a 100644
--- a/dir.c
+++ b/dir.c
@@ -145,8 +145,6 @@ fnmatch(pat, string, flags)
int period = !(flags & FNM_DOTMATCH);
int nocase = flags & FNM_CASEFOLD;
- if (!pat) pat = "";
- if (!string) string = "";
while (c = *pat++) {
switch (c) {
case '?':
@@ -305,7 +303,6 @@ dir_initialize(dir, dirname)
* the block, and <code>Dir::open</code> returns the value of the
* block.
*/
-
static VALUE
dir_s_open(klass, dirname)
VALUE klass, dirname;
@@ -466,11 +463,10 @@ dir_seek(dir, pos)
VALUE dir, pos;
{
struct dir_data *dirp;
- off_t p = NUM2OFFT(pos);
- GetDIR(dir, dirp);
#ifdef HAVE_SEEKDIR
- seekdir(dirp->dir, p);
+ GetDIR(dir, dirp);
+ seekdir(dirp->dir, NUM2INT(pos));
return dir;
#else
rb_notimplement();
@@ -884,8 +880,8 @@ remove_backslashes(p)
#endif
struct glob_args {
- void (*func) _((VALUE, VALUE));
- VALUE c;
+ void (*func) _((const char*, VALUE));
+ const char *c;
VALUE v;
};
@@ -896,18 +892,14 @@ glob_func_caller(val)
VALUE val;
{
struct glob_args *args = (struct glob_args *)val;
- VALUE path = args->c;
-
- OBJ_TAINT(path);
- RSTRING(path)->len = strlen(RSTRING(path)->ptr);
- (*args->func)(path, args->v);
+ (*args->func)(args->c, args->v);
return Qnil;
}
static int
glob_call_func(func, path, arg)
- void (*func) _((VALUE, VALUE));
- VALUE path;
+ void (*func) _((const char*, VALUE));
+ const char *path;
VALUE arg;
{
int status;
@@ -921,22 +913,18 @@ glob_call_func(func, path, arg)
return status;
}
-static int glob_helper(VALUE path, char *sub, int flags, void (*func)(VALUE,VALUE), VALUE arg);
-
static int
-glob_helper(pv, sub, flags, func, arg)
- VALUE pv;
+glob_helper(path, sub, flags, func, arg)
+ char *path;
char *sub;
int flags;
- void (*func) _((VALUE, VALUE));
+ void (*func) _((const char*, VALUE));
VALUE arg;
{
struct stat st;
- char *p, *m, *path;
+ char *p, *m;
int status = 0;
- StringValue(pv);
- path = RSTRING(pv)->ptr;
p = sub ? sub : path;
if (!has_magic(p, 0, flags)) {
#if defined DOSISH
@@ -945,7 +933,7 @@ glob_helper(pv, sub, flags, func, arg)
if (!(flags & FNM_NOESCAPE)) remove_backslashes(p);
#endif
if (lstat(path, &st) == 0) {
- status = glob_call_func(func, pv, arg);
+ status = glob_call_func(func, path, arg);
if (status) return status;
}
else if (errno != ENOENT) {
@@ -960,8 +948,7 @@ glob_helper(pv, sub, flags, func, arg)
if (*p == '/') p++;
m = strchr(p, '/');
if (has_magic(p, m, flags)) {
- char *dir, *base, *magic;
- VALUE buf;
+ char *dir, *base, *magic, *buf;
DIR *dirp;
struct dirent *dp;
int recursive = 0;
@@ -986,9 +973,10 @@ glob_helper(pv, sub, flags, func, arg)
if (m && strcmp(magic, "**") == 0) {
int n = strlen(base);
recursive = 1;
- buf = rb_str_new(0, n+strlen(m)+3);
- sprintf(RSTRING(buf)->ptr, "%s%s", base, *base ? m : m+1);
- status = glob_helper(buf, RSTRING(buf)->ptr+n, flags, func, arg);
+ buf = ALLOC_N(char, n+strlen(m)+3);
+ sprintf(buf, "%s%s", base, *base ? m : m+1);
+ status = glob_helper(buf, buf+n, flags, func, arg);
+ free(buf);
if (status) goto finalize;
}
dirp = opendir(dir);
@@ -1017,32 +1005,36 @@ glob_helper(pv, sub, flags, func, arg)
continue;
if (fnmatch("*", dp->d_name, flags) != 0)
continue;
- buf = rb_str_new(0, strlen(base)+NAMLEN(dp)+strlen(m)+6);
- sprintf(RSTRING(buf)->ptr, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
- if (lstat(RSTRING(buf)->ptr, &st) < 0) {
- if (errno != ENOENT) rb_sys_warning(RSTRING(buf)->ptr);
+ buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
+ sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
+ if (lstat(buf, &st) < 0) {
+ if (errno != ENOENT) rb_sys_warning(buf);
+ free(buf);
continue;
}
if (S_ISDIR(st.st_mode)) {
- char *t = RSTRING(buf)->ptr+strlen(RSTRING(buf)->ptr);
+ char *t = buf+strlen(buf);
strcpy(t, "/**");
strcpy(t+3, m);
status = glob_helper(buf, t, flags, func, arg);
+ free(buf);
if (status) break;
continue;
}
+ free(buf);
continue;
}
if (fnmatch(magic, dp->d_name, flags) == 0) {
- buf = rb_str_new(0, strlen(base)+NAMLEN(dp)+2);
- sprintf(RSTRING(buf)->ptr, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
+ buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2);
+ sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
if (!m) {
status = glob_call_func(func, buf, arg);
+ free(buf);
if (status) break;
continue;
}
tmp = ALLOC(struct d_link);
- tmp->path = strdup(RSTRING(buf)->ptr);
+ tmp->path = buf;
*tail = tmp;
tail = &tmp->next;
}
@@ -1059,10 +1051,11 @@ glob_helper(pv, sub, flags, func, arg)
if (S_ISDIR(st.st_mode)) {
int len = strlen(link->path);
int mlen = strlen(m);
+ char *t = ALLOC_N(char, len+mlen+1);
- buf = rb_str_new(0, len+mlen+1);
- sprintf(RSTRING(buf)->ptr, "%s%s", link->path, m);
- status = glob_helper(buf, RSTRING(buf)->ptr+len, flags, func, arg);
+ sprintf(t, "%s%s", link->path, m);
+ status = glob_helper(t, t+len, flags, func, arg);
+ free(t);
}
}
else {
@@ -1084,42 +1077,28 @@ glob_helper(pv, sub, flags, func, arg)
static int
rb_glob2(path, flags, func, arg)
- VALUE path;
+ const char *path;
int flags;
- void (*func) _((VALUE, VALUE));
+ void (*func) _((const char*, VALUE));
VALUE arg;
{
+ char *buf;
int status;
- status = glob_helper(path, 0, flags, func, arg);
+ buf = ALLOC_N(char, strlen(path)+1);
+ strcpy(buf, path);
+ status = glob_helper(buf, 0, flags, func, arg);
+ free(buf);
return status;
}
-struct rb_glob_args {
- void (*func) _((const char*, VALUE));
- VALUE arg;
-};
-
-static void
-rb_glob_caller(path, a)
- VALUE path, a;
-{
- struct rb_glob_args *args = (struct rb_glob_args *)a;
- (*args->func)(RSTRING(path)->ptr, args->arg);
-}
-
void
rb_glob(path, func, arg)
const char *path;
void (*func) _((const char*, VALUE));
VALUE arg;
{
- struct rb_glob_args args;
- int status;
-
- args.func = func;
- args.arg = arg;
- status = rb_glob2(rb_str_new2(path), 0, rb_glob_caller, (VALUE)&args);
+ int status = rb_glob2(path, 0, func, arg);
if (status) rb_jump_tag(status);
}
@@ -1130,46 +1109,41 @@ rb_globi(path, func, arg)
void (*func) _((const char*, VALUE));
VALUE arg;
{
- struct rb_glob_args args;
- int status;
-
- args.func = func;
- args.arg = arg;
- status = rb_glob2(rb_str_new2(path), FNM_CASEFOLD, rb_glob_caller, (VALUE)&args);
+ int status = rb_glob2(path, FNM_CASEFOLD, func, arg);
if (status) rb_jump_tag(status);
}
static void
push_pattern(path, ary)
- VALUE path;
+ const char *path;
VALUE ary;
{
- rb_ary_push(ary, path);
+ rb_ary_push(ary, rb_tainted_str_new2(path));
}
static int
push_globs(ary, s, flags)
VALUE ary;
- VALUE s;
+ const char *s;
int flags;
{
return rb_glob2(s, flags, push_pattern, ary);
}
static int
-push_braces(ary, str, flags)
- VALUE ary, str;
+push_braces(ary, s, flags)
+ VALUE ary;
+ const char *s;
int flags;
{
- VALUE buf;
- char *b;
- const char *s, *p, *t;
+ char *buf, *b;
+ const char *p, *t;
const char *lbrace, *rbrace;
int nest = 0;
int status = 0;
- s = p = RSTRING(str)->ptr;
+ p = s;
lbrace = rbrace = 0;
while (*p) {
if (*p == '{') {
@@ -1189,6 +1163,9 @@ push_braces(ary, str, flags)
if (lbrace && rbrace) {
int len = strlen(s);
+ buf = xmalloc(len + 1);
+ memcpy(buf, s, lbrace-s);
+ b = buf + (lbrace-s);
p = lbrace;
while (*p != '}') {
t = p + 1;
@@ -1196,17 +1173,15 @@ push_braces(ary, str, flags)
/* skip inner braces */
if (*p == '{') while (*p!='}') p++;
}
- buf = rb_str_new(0, len+1);
- memcpy(RSTRING(buf)->ptr, s, lbrace-s);
- b = RSTRING(buf)->ptr + (lbrace-s);
memcpy(b, t, p-t);
strcpy(b+(p-t), rbrace+1);
status = push_braces(ary, buf, flags);
if (status) break;
}
+ free(buf);
}
else {
- status = push_globs(ary, str, flags);
+ status = push_globs(ary, s, flags);
}
return status;
@@ -1220,7 +1195,7 @@ rb_push_glob(str, flags)
int flags;
{
const char *p, *pend;
- volatile VALUE buf;
+ char *buf;
char *t;
int nest, maxnest;
int status = 0;
@@ -1229,12 +1204,13 @@ rb_push_glob(str, flags)
ary = rb_ary_new();
SafeStringValue(str);
- buf = rb_str_new(0, RSTRING(str)->len + 1);
+ buf = xmalloc(RSTRING(str)->len + 1);
+
p = RSTRING(str)->ptr;
pend = p + RSTRING(str)->len;
while (p < pend) {
- t = RSTRING(buf)->ptr;
+ t = buf;
nest = maxnest = 0;
while (p < pend && isdelim(*p)) p++;
while (p < pend && !isdelim(*p)) {
@@ -1257,7 +1233,10 @@ rb_push_glob(str, flags)
}
/* else unmatched braces */
}
+ free(buf);
+
if (status) rb_jump_tag(status);
+
if (rb_block_given_p()) {
rb_ary_each(ary);
return Qnil;
@@ -1318,22 +1297,6 @@ dir_s_glob(argc, argv, obj)
return rb_push_glob(str, flags);
}
-static VALUE
-dir_open_dir(path)
- VALUE path;
-{
- struct dir_data *dp;
- VALUE dir = rb_funcall(rb_cDir, rb_intern("open"), 1, path);
-
- if (TYPE(dir) != T_DATA ||
- RDATA(dir)->dfree != (RUBY_DATA_FUNC)free_dir) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Dir)",
- rb_obj_classname(dir));
- }
- return dir;
-}
-
-
/*
* call-seq:
* Dir.foreach( dirname ) {| filename | block } => nil
@@ -1357,7 +1320,7 @@ dir_foreach(io, dirname)
{
VALUE dir;
- dir = dir_open_dir(dirname);
+ dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname);
rb_ensure(dir_each, dir, dir_close, dir);
return Qnil;
}
@@ -1379,7 +1342,7 @@ dir_entries(io, dirname)
{
VALUE dir;
- dir = dir_open_dir(dirname);
+ dir = rb_funcall(rb_cDir, rb_intern("open"), 1, dirname);
return rb_ensure(rb_Array, dir, dir_close, dir);
}
diff --git a/error.c b/error.c
index f4fbb10511..c67fce9d34 100644
--- a/error.c
+++ b/error.c
@@ -908,7 +908,7 @@ syserr_initialize(argc, argv, self)
if (!NIL_P(mesg)) {
VALUE str = mesg;
StringValue(str);
- mesg = rb_str_new(0, strlen(err)+RSTRING(str)->len+3);
+ mesg = rb_str_new(0, strlen(err)+RSTRING(mesg)->len+3);
sprintf(RSTRING(mesg)->ptr, "%s - %.*s", err,
(int)RSTRING(str)->len, RSTRING(str)->ptr);
rb_str_resize(mesg, strlen(RSTRING(mesg)->ptr));
diff --git a/eval.c b/eval.c
index a8a3cb19e2..043f349bbd 100644
--- a/eval.c
+++ b/eval.c
@@ -88,10 +88,6 @@ char *strrchr _((const char*,const char));
#include "macruby_private.h"
#endif
-#ifdef __VMS
-#include "vmsruby_private.h"
-#endif
-
#ifdef USE_CONTEXT
typedef struct {
ucontext_t context;
@@ -316,7 +312,7 @@ rb_clear_cache_by_class(klass)
static ID init, eqq, each, aref, aset, match, missing;
static ID added, singleton_added;
-static ID __id__, __send__, respond_to;
+static ID __id__, __send__;
void
rb_add_method(klass, mid, node, noex)
@@ -538,7 +534,7 @@ rb_enable_super(klass, name)
VALUE klass;
const char *name;
{
- rb_warn("rb_enable_super() is obsolete");
+ rb_warning("rb_enable_super() is obsolete");
}
static void
@@ -1081,9 +1077,7 @@ get_backtrace(info)
VALUE info;
{
if (NIL_P(info)) return Qnil;
- info = rb_funcall(info, rb_intern("backtrace"), 0);
- if (NIL_P(info)) return Qnil;
- return rb_check_array_type(info);
+ return rb_check_array_type(rb_funcall(info, rb_intern("backtrace"), 0));
}
static void
@@ -1152,7 +1146,6 @@ error_print()
if (elen == 0) {
warn_print(": ");
warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
- warn_print("\n");
}
else {
char *tail = 0;
@@ -1263,8 +1256,6 @@ ruby_init()
rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
#ifdef __MACOS__
_macruby_init();
-#elif defined(__VMS)
- _vmsruby_init();
#endif
ruby_prog_init();
ALLOW_INTS;
@@ -1375,10 +1366,6 @@ ruby_options(argc, argv)
{
int state;
-#ifdef _WIN32
- argc = rb_w32_cmdvector(GetCommandLine(), &argv);
-#endif
-
Init_stack((void*)&state);
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
@@ -1390,11 +1377,6 @@ ruby_options(argc, argv)
exit(error_handle(state));
}
POP_TAG();
-
-#ifdef _WIN32_WCE
- // free commandline buffer
- wce_FreeCommandLine();
-#endif
}
void rb_exec_end_proc _((void));
@@ -1413,7 +1395,6 @@ ruby_finalize_0()
static void
ruby_finalize_1()
{
- signal(SIGINT, SIG_DFL);
ruby_errinfo = 0;
rb_gc_call_finalizer_at_exit();
trace_func = 0;
@@ -1544,7 +1525,22 @@ rb_eval_string_protect(str, state)
const char *str;
int *state;
{
- return rb_protect((VALUE (*)_((VALUE)))rb_eval_string, (VALUE)str, state);
+ VALUE result = Qnil; /* OK */
+ int status;
+
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ result = rb_eval_string(str);
+ }
+ POP_TAG();
+ if (state) {
+ *state = status;
+ }
+ if (status != 0) {
+ return Qnil;
+ }
+
+ return result;
}
VALUE
@@ -3949,25 +3945,17 @@ module_setup(module, n)
return result;
}
-static NODE *basic_respond_to = 0;
-
int
rb_respond_to(obj, id)
VALUE obj;
ID id;
{
- VALUE klass = CLASS_OF(obj);
- if (rb_method_node(klass, respond_to) == basic_respond_to &&
- rb_method_boundp(klass, id, 0)) {
+ if (rb_method_boundp(CLASS_OF(obj), id, 0)) {
return Qtrue;
}
- else{
- return rb_funcall(obj, respond_to, 1, ID2SYM(id));
- }
return Qfalse;
}
-
/*
* call-seq:
* obj.respond_to?(symbol, include_private=false) => true or false
@@ -5152,8 +5140,6 @@ rb_rescue(b_proc, data1, r_proc, data2)
return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError, (VALUE)0);
}
-static VALUE cont_protect;
-
VALUE
rb_protect(proc, data, state)
VALUE (*proc) _((VALUE));
@@ -5164,11 +5150,9 @@ rb_protect(proc, data, state)
int status;
PUSH_TAG(PROT_NONE);
- cont_protect = (VALUE)rb_node_newnode(NODE_MEMO, cont_protect, 0, 0);
if ((status = EXEC_TAG()) == 0) {
result = (*proc)(data);
}
- cont_protect = ((NODE *)cont_protect)->u1.value;
POP_TAG();
if (state) {
*state = status;
@@ -5357,7 +5341,7 @@ method_missing(obj, id, argc, argv, call_status)
POP_FRAME();
}
else if (id == ID_ALLOCATOR) {
- rb_raise(rb_eTypeError, "allocator undefined for %s", rb_class2name(obj));
+ rb_raise(rb_eNoMethodError, "allocator undefined for %s", rb_class2name(obj));
}
nargv = ALLOCA_N(VALUE, argc+1);
@@ -5794,13 +5778,18 @@ rb_f_send(argc, argv, recv)
return vid;
}
-static VALUE
-vafuncall(recv, mid, n, ar)
+VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_funcall(VALUE recv, ID mid, int n, ...)
+#else
+rb_funcall(recv, mid, n, va_alist)
VALUE recv;
ID mid;
int n;
- va_list *ar;
+ va_dcl
+#endif
{
+ va_list ar;
VALUE *argv;
if (n > 0) {
@@ -5808,10 +5797,11 @@ vafuncall(recv, mid, n, ar)
argv = ALLOCA_N(VALUE, n);
+ va_init_list(ar, n);
for (i=0;i<n;i++) {
- argv[i] = va_arg(*ar, VALUE);
+ argv[i] = va_arg(ar, VALUE);
}
- va_end(*ar);
+ va_end(ar);
}
else {
argv = 0;
@@ -5821,55 +5811,6 @@ vafuncall(recv, mid, n, ar)
}
VALUE
-#ifdef HAVE_STDARG_PROTOTYPES
-rb_funcall(VALUE recv, ID mid, int n, ...)
-#else
-rb_funcall(recv, mid, n, va_alist)
- VALUE recv;
- ID mid;
- int n;
- va_dcl
-#endif
-{
- va_list ar;
- va_init_list(ar, n);
-
- return vafuncall(recv, mid, n, &ar);
-}
-
-VALUE
-#ifdef HAVE_STDARG_PROTOTYPES
-rb_funcall_rescue(VALUE recv, ID mid, int n, ...)
-#else
-rb_funcall_rescue(recv, mid, n, va_alist)
- VALUE recv;
- ID mid;
- int n;
- va_dcl
-#endif
-{
- VALUE result = Qnil; /* OK */
- int status;
- va_list ar;
-
- va_init_list(ar, n);
-
- PUSH_TAG(PROT_NONE);
- if ((status = EXEC_TAG()) == 0) {
- result = vafuncall(recv, mid, n, &ar);
- }
- POP_TAG();
- switch (status) {
- case 0:
- return result;
- case TAG_RAISE:
- return Qundef;
- default:
- JUMP_TAG(status);
- }
-}
-
-VALUE
rb_funcall2(recv, mid, argc, argv)
VALUE recv;
ID mid;
@@ -7595,10 +7536,7 @@ Init_eval()
rb_define_global_function("loop", rb_f_loop, 0);
rb_define_method(rb_mKernel, "respond_to?", rb_obj_respond_to, -1);
- respond_to = rb_intern("respond_to?");
- basic_respond_to = rb_method_node(rb_cObject, respond_to);
- rb_global_variable((VALUE*)&basic_respond_to);
-
+
rb_define_global_function("raise", rb_f_raise, -1);
rb_define_global_function("fail", rb_f_raise, -1);
@@ -7816,9 +7754,9 @@ blk_free(data)
struct BLOCK *data;
{
void *tmp;
-
+
while (data) {
- frame_free(&data->frame);
+ frame_free(&data->frame);
tmp = data;
data = data->prev;
free(tmp);
@@ -8145,7 +8083,6 @@ proc_invoke(proc, args, self, klass)
volatile int safe = ruby_safe_level;
volatile VALUE old_wrapper = ruby_wrapper;
volatile int pcall, avalue = Qtrue;
- volatile VALUE tmp = args;
if (rb_block_given_p() && ruby_frame->last_func) {
if (klass != ruby_frame->last_class)
@@ -8170,10 +8107,6 @@ proc_invoke(proc, args, self, klass)
_block = *data;
if (self != Qundef) _block.frame.self = self;
if (klass) _block.frame.last_class = klass;
- _block.frame.argc = RARRAY(tmp)->len;
- _block.frame.argv = ALLOCA_N(VALUE, RARRAY(tmp)->len);
- MEMCPY(_block.frame.argv, RARRAY(tmp)->ptr, VALUE, RARRAY(tmp)->len);
- _block.frame.flags = FRAME_ALLOCA;
ruby_block = &_block;
PUSH_ITER(ITER_CUR);
@@ -9571,15 +9504,6 @@ thread_reset_raised()
static void rb_thread_ready _((rb_thread_t));
-static VALUE run_trap_eval _((VALUE));
-static VALUE
-run_trap_eval(arg)
- VALUE arg;
-{
- VALUE *p = (VALUE *)arg;
- return rb_eval_cmd(p[0], p[1], (int)p[2]);
-}
-
static VALUE
rb_trap_eval(cmd, sig, safe)
VALUE cmd;
@@ -9588,16 +9512,16 @@ rb_trap_eval(cmd, sig, safe)
int state;
VALUE val = Qnil; /* OK */
volatile struct thread_status_t save;
- VALUE arg[3];
- arg[0] = cmd;
- arg[1] = rb_ary_new3(1, INT2FIX(sig));
- arg[2] = (VALUE)safe;
THREAD_COPY_STATUS(curr_thread, &save);
rb_thread_ready(curr_thread);
+ PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
- val = rb_protect(run_trap_eval, (VALUE)&arg, &state);
+ if ((state = EXEC_TAG()) == 0) {
+ val = rb_eval_cmd(cmd, rb_ary_new3(1, INT2FIX(sig)), safe);
+ }
POP_ITER();
+ POP_TAG();
THREAD_COPY_STATUS(&save, curr_thread);
if (state) {
@@ -9716,7 +9640,6 @@ thread_mark(th)
rb_gc_mark(th->last_line);
rb_gc_mark(th->last_match);
rb_mark_tbl(th->locals);
- rb_gc_mark(th->thgroup);
/* mark data in copied stack */
if (th == curr_thread) return;
@@ -11831,10 +11754,6 @@ rb_thread_trap_eval(cmd, sig, safe)
int sig, safe;
{
rb_thread_critical = 0;
- if (curr_thread == main_thread) {
- rb_trap_eval(cmd, sig, safe);
- return;
- }
if (!rb_thread_dead(curr_thread)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
@@ -12191,7 +12110,6 @@ rb_callcc(self)
scope_dup(tag->scope);
}
th->thread = curr_thread->thread;
- th->thgroup = cont_protect;
for (vars = ruby_dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
@@ -12233,9 +12151,6 @@ rb_cont_call(argc, argv, cont)
if (th->thread != curr_thread->thread) {
rb_raise(rb_eRuntimeError, "continuation called across threads");
}
- if (th->thgroup != cont_protect) {
- rb_raise(rb_eRuntimeError, "continuation called across trap");
- }
switch (argc) {
case 0:
th->result = Qnil;
@@ -12404,10 +12319,6 @@ thgroup_add(group, thread)
rb_secure(4);
th = rb_thread_check(thread);
- if (!th->next || !th->prev) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)",
- rb_obj_classname(thread));
- }
if (OBJ_FROZEN(group)) {
rb_raise(rb_eThreadError, "can't move to the frozen thread group");
@@ -12503,7 +12414,6 @@ Init_Thread()
rb_define_method(rb_cCont, "call", rb_cont_call, -1);
rb_define_method(rb_cCont, "[]", rb_cont_call, -1);
rb_define_global_function("callcc", rb_callcc, 0);
- rb_global_variable(&cont_protect);
cThGroup = rb_define_class("ThreadGroup", rb_cObject);
rb_define_alloc_func(cThGroup, thgroup_s_alloc);
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index a8952bf186..106c43da4c 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -21,11 +21,7 @@
#elif defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
#elif defined(HAVE_CURSES_COLR_CURSES_H)
-# ifdef HAVE_STDARG_PROTOTYPES
-# include <stdarg.h>
-# else
-# include <varargs.h>
-# endif
+# include <varargs.h>
# include <curses_colr/curses.h>
#else
# include <curses.h>
@@ -766,26 +762,22 @@ window_initialize(obj, h, w, top, left)
return obj;
}
-/* def subwin(height, width, top, left) */
+/* def subwin(h, w, top, left) */
static VALUE
-window_subwin(obj, height, width, top, left)
+window_subwin(obj, h, w, top, left)
VALUE obj;
- VALUE height;
- VALUE width;
+ VALUE h;
+ VALUE w;
VALUE top;
VALUE left;
{
struct windata *winp;
WINDOW *window;
VALUE win;
- int h, w, t, l;
- h = NUM2INT(height);
- w = NUM2INT(width);
- t = NUM2INT(top);
- l = NUM2INT(left);
GetWINDOW(obj, winp);
- window = subwin(winp->window, h, w, t, l);
+ window = subwin(winp->window, NUM2INT(h), NUM2INT(w),
+ NUM2INT(top), NUM2INT(left));
win = prep_window(rb_obj_class(obj), window);
return win;
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 9caf808961..e609327c46 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -43,11 +43,6 @@ closed_dbm()
if (dbmp->di_dbm == 0) closed_dbm();\
}
-#define GetDBM2(obj, data, dbm) {\
- GetDBM(obj, data);\
- (dbm) = dbmp->di_dbm;\
-}
-
static void
free_dbm(dbmp)
struct dbmdata *dbmp;
@@ -166,7 +161,8 @@ fdbm_fetch(obj, keystr, ifnone)
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
value = dbm_fetch(dbm, key);
if (value.dptr == 0) {
if (ifnone == Qnil && rb_block_given_p())
@@ -211,7 +207,8 @@ fdbm_index(obj, valstr)
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
if (val.dsize == RSTRING(valstr)->len &&
@@ -256,18 +253,17 @@ fdbm_select(argc, argv, obj)
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
}
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
- VALUE assoc, v;
+ VALUE assoc;
val = dbm_fetch(dbm, key);
assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
rb_tainted_str_new(val.dptr, val.dsize));
- v = rb_yield(assoc);
- if (RTEST(v)) {
- rb_ary_push(new, assoc);
- }
- GetDBM2(obj, dbmp, dbm);
- }
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
+ }
}
else {
rb_warn("DBM#select(index..) is deprecated; use DBM#values_at");
@@ -318,7 +314,9 @@ fdbm_delete(obj, keystr)
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
value = dbm_fetch(dbm, key);
if (value.dptr == 0) {
if (rb_block_given_p()) return rb_yield(keystr);
@@ -348,7 +346,8 @@ fdbm_shift(obj)
VALUE keystr, valstr;
fdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
dbmp->di_size = -1;
key = dbm_firstkey(dbm);
@@ -373,7 +372,8 @@ fdbm_delete_if(obj)
int i, status = 0, n;
fdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
n = dbmp->di_size;
dbmp->di_size = -1;
@@ -384,7 +384,6 @@ fdbm_delete_if(obj)
ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
if (status != 0) break;
if (RTEST(ret)) rb_ary_push(ary, keystr);
- GetDBM2(obj, dbmp, dbm);
}
for (i = 0; i < RARRAY(ary)->len; i++) {
@@ -411,7 +410,8 @@ fdbm_clear(obj)
DBM *dbm;
fdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
dbmp->di_size = -1;
while (key = dbm_firstkey(dbm), key.dptr) {
if (dbm_delete(dbm, key)) {
@@ -433,7 +433,8 @@ fdbm_invert(obj)
VALUE keystr, valstr;
VALUE hash = rb_hash_new();
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
keystr = rb_tainted_str_new(key.dptr, key.dsize);
@@ -493,16 +494,17 @@ fdbm_store(obj, keystr, valstr)
fdbm_modify(obj);
keystr = rb_obj_as_string(keystr);
- valstr = rb_obj_as_string(valstr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
+ valstr = rb_obj_as_string(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
dbmp->di_size = -1;
+ dbm = dbmp->di_dbm;
if (dbm_store(dbm, key, val, DBM_REPLACE)) {
#ifdef HAVE_DBM_CLEARERR
dbm_clearerr(dbm);
@@ -523,8 +525,9 @@ fdbm_length(obj)
DBM *dbm;
int i = 0;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
i++;
@@ -543,7 +546,7 @@ fdbm_empty_p(obj)
DBM *dbm;
int i = 0;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
if (dbmp->di_size < 0) {
dbm = dbmp->di_dbm;
@@ -566,11 +569,11 @@ fdbm_each_value(obj)
struct dbmdata *dbmp;
DBM *dbm;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
rb_yield(rb_tainted_str_new(val.dptr, val.dsize));
- GetDBM2(obj, dbmp, dbm);
}
return obj;
}
@@ -583,10 +586,10 @@ fdbm_each_key(obj)
struct dbmdata *dbmp;
DBM *dbm;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
- GetDBM2(obj, dbmp, dbm);
}
return obj;
}
@@ -600,14 +603,14 @@ fdbm_each_pair(obj)
struct dbmdata *dbmp;
VALUE keystr, valstr;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
keystr = rb_tainted_str_new(key.dptr, key.dsize);
valstr = rb_tainted_str_new(val.dptr, val.dsize);
rb_yield(rb_assoc_new(keystr, valstr));
- GetDBM2(obj, dbmp, dbm);
}
return obj;
@@ -622,7 +625,8 @@ fdbm_keys(obj)
DBM *dbm;
VALUE ary;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
@@ -641,7 +645,9 @@ fdbm_values(obj)
DBM *dbm;
VALUE ary;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
@@ -663,7 +669,8 @@ fdbm_has_key(obj, keystr)
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
val = dbm_fetch(dbm, key);
if (val.dptr) return Qtrue;
return Qfalse;
@@ -681,7 +688,8 @@ fdbm_has_value(obj, valstr)
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
if (val.dsize == RSTRING(valstr)->len &&
@@ -700,12 +708,14 @@ fdbm_to_a(obj)
DBM *dbm;
VALUE ary;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
rb_ary_push(ary, rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
- rb_tainted_str_new(val.dptr, val.dsize)));
+ rb_tainted_str_new(val.dptr, val.dsize)));
}
return ary;
@@ -720,7 +730,9 @@ fdbm_to_hash(obj)
DBM *dbm;
VALUE hash;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
hash = rb_hash_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
@@ -757,7 +769,7 @@ Init_dbm()
rb_define_method(rb_cDBM, "index", fdbm_index, 1);
rb_define_method(rb_cDBM, "indexes", fdbm_indexes, -1);
rb_define_method(rb_cDBM, "indices", fdbm_indexes, -1);
- rb_define_method(rb_cDBM, "select", fdbm_select, -1);
+ rb_define_method(rb_cDBM, "select", fdbm_select, 0);
rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
rb_define_method(rb_cDBM, "length", fdbm_length, 0);
rb_define_method(rb_cDBM, "size", fdbm_length, 0);
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index 2a98ace8ab..1ab5145def 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -70,11 +70,8 @@ module DL
init_types()
init_sym()
- rty,renc,rdec = @types.encode_return_type(ret)
- if( !rty )
- raise(TypeError, "unsupported type: #{ret}")
- end
- ty,enc,dec = encode_argument_types(args)
+ rty,renc,rdec = @types.encode_type(ret)
+ ty,enc,dec = encode_types(args)
symty = rty + ty
module_eval("module_function :#{func}")
@@ -134,11 +131,8 @@ module DL
init_types()
init_sym()
- rty,_,rdec = @types.encode_return_type(rettype)
- if( !rty )
- raise(TypeError, "unsupported type: #{rettype}")
- end
- ty,enc,dec = encode_argument_types(argtypes)
+ rty,_,rdec = @types.encode_type(rettype)
+ ty,enc,dec = encode_types(argtypes)
symty = rty + ty
sym = symbol(name, symty)
@@ -184,16 +178,13 @@ module DL
return @retval
end
- def encode_argument_types(tys)
+ def encode_types(tys)
init_types()
encty = []
enc = nil
dec = nil
tys.each_with_index{|ty,idx|
- ty,c1,c2 = @types.encode_argument_type(ty)
- if( !ty )
- raise(TypeError, "unsupported type: #{ty}")
- end
+ ty,c1,c2,_,_ = @types.encode_type(ty)
encty.push(ty)
if( enc )
if( c1 )
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 2f54019294..2c52d5040d 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -128,10 +128,7 @@ module DL
else
raise(RuntimeError, "invalid element: #{elem}")
end
- ty,enc,dec = @types.encode_struct_type(ty)
- if( !ty )
- raise(TypeError, "unsupported type: #{ty}")
- end
+ ty,_,_,enc,dec = @types.encode_type(ty)
return [name,ty,num,enc,dec]
end
end # class Struct
diff --git a/ext/dl/lib/dl/types.rb b/ext/dl/lib/dl/types.rb
index 1144917dae..139426473a 100644
--- a/ext/dl/lib/dl/types.rb
+++ b/ext/dl/lib/dl/types.rb
@@ -6,240 +6,175 @@ module DL
class Types
TYPES = [
# FORMAT:
- # ["alias name",
- # "type name", encoding_method, decoding_method, for function prototypes
- # "type name", encoding_method, decoding_method] for structures (not implemented)
+ # ["alias name", "type name",
+ # encoding_method, decoding_method, for function prototypes
+ # encoding_method, decoding_method] for structures (not implemented)
# for Windows
- ["DWORD", "unsigned long", nil, nil,
- "unsigned long", nil, nil],
- ["PDWORD", "unsigned long *", nil, nil,
- "unsigned long *", nil, nil],
- ["WORD", "unsigned short", nil, nil,
- "unsigned short", nil, nil],
- ["PWORD", "unsigned int *", nil, nil,
- "unsigned int *", nil, nil],
- ["BYTE", "unsigned char", nil, nil,
- "unsigned char", nil, nil],
- ["PBYTE", "unsigned char *", nil, nil,
- "unsigned char *", nil, nil],
- ["BOOL", "ibool", nil, nil,
- "ibool", nil, nil],
- ["ATOM", "int", nil, nil,
- "int", nil, nil],
- ["BYTE", "unsigned char", nil, nil,
- "unsigned char", nil, nil],
- ["PBYTE", "unsigned char *", nil, nil,
- "unsigned char *", nil, nil],
- ["UINT", "unsigned int", nil, nil,
- "unsigned int", nil, nil],
- ["ULONG", "unsigned long", nil, nil,
- "unsigned long", nil, nil],
- ["UCHAR", "unsigned char", nil, nil,
- "unsigned char", nil, nil],
- ["HANDLE", "unsigned long", nil, nil,
- "unsigned long", nil, nil],
- ["PHANDLE","void*", nil, nil,
- "void*", nil, nil],
- ["PVOID", "void*", nil, nil,
- "void*", nil, nil],
- ["LPCSTR", "char*", nil, nil,
- "char*", nil, nil],
- ["HDC", "unsigned int", nil, nil,
- "unsigned int", nil, nil],
- ["HWND", "unsigned int", nil, nil,
- "unsigned int", nil, nil],
+ ["DWORD", "unsigned long", nil, nil, nil, nil],
+ ["PDWORD", "unsigned long *", nil, nil, nil, nil],
+ ["WORD", "unsigned short", nil, nil, nil, nil],
+ ["PWORD", "unsigned int *", nil, nil, nil, nil],
+ ["BYTE", "unsigned char", nil, nil, nil, nil],
+ ["PBYTE", "unsigned char *", nil, nil, nil, nil],
+ ["BOOL", "ibool", nil, nil, nil, nil],
+ ["ATOM", "int", nil, nil, nil, nil],
+ ["BYTE", "unsigned char", nil, nil, nil, nil],
+ ["PBYTE", "unsigned char *", nil, nil, nil, nil],
+ ["UINT", "unsigned int", nil, nil, nil, nil],
+ ["ULONG", "unsigned long", nil, nil, nil, nil],
+ ["UCHAR", "unsigned char", nil, nil, nil, nil],
+ ["HANDLE", "unsigned long", nil, nil, nil, nil],
+ ["PHANDLE","void*", nil, nil, nil, nil],
+ ["PVOID", "void*", nil, nil, nil, nil],
+ ["LPCSTR", "char*", nil, nil, nil, nil],
+ ["HDC", "unsigned int", nil, nil, nil, nil],
+ ["HWND", "unsigned int", nil, nil, nil, nil],
# Others
- ["uint", "unsigned int", nil, nil,
- "unsigned int", nil, nil],
- ["u_int", "unsigned int", nil, nil,
- "unsigned int", nil, nil],
- ["ulong", "unsigned long", nil, nil,
- "unsigned long", nil, nil],
- ["u_long", "unsigned long", nil, nil,
- "unsigned long", nil, nil],
+ ["uint", "unsigned int", nil, nil, nil, nil],
+ ["u_int", "unsigned int", nil, nil, nil, nil],
+ ["ulong", "unsigned long", nil, nil, nil, nil],
+ ["u_long", "unsigned long", nil, nil, nil, nil],
# DL::Importable primitive types
- ["ibool",
- "I",
+ ["ibool", "I",
proc{|v| v ? 1 : 0},
proc{|v| (v != 0) ? true : false},
- "I",
proc{|v| v ? 1 : 0 },
proc{|v| (v != 0) ? true : false} ],
- ["cbool",
- "C",
+ ["cbool", "C",
proc{|v| v ? 1 : 0},
proc{|v| (v != 0) ? true : false},
- "C",
proc{|v,len| v ? 1 : 0},
proc{|v,len| (v != 0) ? true : false}],
- ["lbool",
- "L",
+ ["lbool", "L",
proc{|v| v ? 1 : 0},
proc{|v| (v != 0) ? true : false},
- "L",
proc{|v,len| v ? 1 : 0},
proc{|v,len| (v != 0) ? true : false}],
- ["unsigned char",
- "C",
+ ["unsigned char", "C",
proc{|v| [v].pack("C").unpack("c")[0]},
proc{|v| [v].pack("c").unpack("C")[0]},
- "C",
proc{|v| [v].pack("C").unpack("c")[0]},
proc{|v| [v].pack("c").unpack("C")[0]}],
- ["unsigned short",
- "H",
+ ["unsigned short", "H",
proc{|v| [v].pack("S").unpack("s")[0]},
proc{|v| [v].pack("s").unpack("S")[0]},
- "H",
proc{|v| [v].pack("S").unpack("s")[0]},
proc{|v| [v].pack("s").unpack("S")[0]}],
- ["unsigned int",
- "I",
+ ["unsigned int", "I",
proc{|v| [v].pack("I").unpack("i")[0]},
proc{|v| [v].pack("i").unpack("I")[0]},
- "I",
proc{|v| [v].pack("I").unpack("i")[0]},
proc{|v| [v].pack("i").unpack("I")[0]}],
- ["unsigned long",
- "L",
+ ["unsigned long", "L",
proc{|v| [v].pack("L").unpack("l")[0]},
proc{|v| [v].pack("l").unpack("L")[0]},
- "L",
proc{|v| [v].pack("L").unpack("l")[0]},
proc{|v| [v].pack("l").unpack("L")[0]}],
- ["unsigned char ref",
- "c",
+ ["unsigned char ref", "c",
proc{|v| [v].pack("C").unpack("c")[0]},
proc{|v| [v].pack("c").unpack("C")[0]},
- nil, nil, nil],
- ["unsigned int ref",
- "i",
+ nil, nil],
+ ["unsigned int ref", "i",
proc{|v| [v].pack("I").unpack("i")[0]},
proc{|v| [v].pack("i").unpack("I")[0]},
- nil, nil, nil],
- ["unsigned long ref",
- "l",
+ nil, nil],
+ ["unsigned long ref", "l",
proc{|v| [v].pack("L").unpack("l")[0]},
proc{|v| [v].pack("l").unpack("L")[0]},
- nil, nil, nil],
- ["char ref", "c", nil, nil,
- nil, nil, nil],
- ["short ref", "h", nil, nil,
- nil, nil, nil],
- ["int ref", "i", nil, nil,
- nil, nil, nil],
- ["long ref", "l", nil, nil,
- nil, nil, nil],
- ["float ref", "f", nil, nil,
- nil, nil, nil],
- ["double ref","d", nil, nil,
- nil, nil, nil],
- ["char", "C", nil, nil,
- "C", nil, nil],
- ["short", "H", nil, nil,
- "H", nil, nil],
- ["int", "I", nil, nil,
- "I", nil, nil],
- ["long", "L", nil, nil,
- "L", nil, nil],
- ["float", "F", nil, nil,
- "F", nil, nil],
- ["double", "D", nil, nil,
- "D", nil, nil],
- [/^char\s*\*$/,"s",nil, nil,
- "S",nil, nil],
- [/^const char\s*\*$/,"S",nil, nil,
- "S",nil, nil],
- [/^.+\*$/, "P", nil, nil,
- "P", nil, nil],
- [/^.+\[\]$/, "a", nil, nil,
- "a", nil, nil],
- ["void", "0", nil, nil,
- nil, nil, nil],
+ nil, nil],
+ ["char ref", "c", nil, nil, nil, nil],
+ ["short ref", "h", nil, nil, nil, nil],
+ ["int ref", "i", nil, nil, nil, nil],
+ ["long ref", "l", nil, nil, nil, nil],
+ ["float ref", "f", nil, nil, nil, nil],
+ ["double ref","d", nil, nil, nil, nil],
+ ["char", "C", nil, nil, nil, nil],
+ ["short", "H", nil, nil, nil, nil],
+ ["int", "I", nil, nil, nil, nil],
+ ["long", "L", nil, nil, nil, nil],
+ ["float", "F", nil, nil, nil, nil],
+ ["double", "D", nil, nil, nil, nil],
+ [/^char\s*\*$/,"s",nil, nil, nil, nil],
+ [/^const char\s*\*$/,"S",nil, nil, nil, nil],
+ [/^.+\*$/, "p", nil, nil, nil, nil],
+ [/^.+\[\]$/, "a", nil, nil, nil, nil],
+ ["void", "0", nil, nil, nil, nil],
]
def initialize
init_types()
end
- def typealias(ty1, ty2, enc=nil, dec=nil, ty3=nil, senc=nil, sdec=nil)
- @TYDEFS.unshift([ty1, ty2, enc, dec, ty3, senc, sdec])
+ def typealias(ty1, ty2, enc=nil, dec=nil, senc=nil, sdec=nil)
+ @TYDEFS.unshift([ty1,ty2, enc,dec, senc, sdec])
end
def init_types
@TYDEFS = TYPES.dup
end
- def encode_argument_type(alias_type)
- proc_encode = nil
- proc_decode = nil
- @TYDEFS.each{|aty,ty,enc,dec,_,_,_|
- if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
- alias_type = alias_type.gsub(aty,ty) if ty
- alias_type.strip! if alias_type
- if( proc_encode )
- if( enc )
- conv1 = proc_encode
- proc_encode = proc{|v| enc.call(conv1.call(v))}
+ def encode_type(ty)
+ orig_ty = ty
+ enc = nil
+ dec = nil
+ senc = nil
+ sdec = nil
+ @TYDEFS.each{|t1,t2,c1,c2,c3,c4|
+# if( t1.is_a?(String) )
+# t1 = Regexp.new("^" + t1 + "$")
+# end
+ if( (t1.is_a?(Regexp) && (t1 =~ ty)) || (t1 == ty) )
+ ty = ty.gsub(t1,t2)
+ if( enc )
+ if( c1 )
+ conv1 = enc
+ enc = proc{|v| c1.call(conv1.call(v))}
end
else
- if( enc )
- proc_encode = enc
+ if( c1 )
+ enc = c1
end
end
- if( proc_decode )
- if( dec )
- conv2 = proc_decode
- proc_decode = proc{|v| dec.call(conv2.call(v))}
+ if( dec )
+ if( c2 )
+ conv2 = dec
+ dec = proc{|v| c2.call(conv2.call(v))}
end
else
- if( dec )
- proc_decode = dec
+ if( c2 )
+ dec = c2
end
end
- end
- }
- return [alias_type, proc_encode, proc_decode]
- end
-
- def encode_return_type(ty)
- ty, enc, dec = encode_argument_type(ty)
- return [ty, enc, dec]
- end
-
- def encode_struct_type(alias_type)
- proc_encode = nil
- proc_decode = nil
- @TYDEFS.each{|aty,_,_,_,ty,enc,dec|
- if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
- alias_type = alias_type.gsub(aty,ty) if ty
- alias_type.strip! if alias_type
- if( proc_encode )
- if( enc )
- conv1 = proc_encode
- proc_encode = proc{|v| enc.call(conv1.call(v))}
+ if( senc )
+ if( c3 )
+ conv3 = senc
+ senc = proc{|v| c3.call(conv3.call(v))}
end
else
- if( enc )
- proc_encode = enc
+ if( c3 )
+ senc = c3
end
end
- if( proc_decode )
- if( dec )
- conv2 = proc_decode
- proc_decode = proc{|v| dec.call(conv2.call(v))}
+ if( sdec )
+ if( c4 )
+ conv4 = sdec
+ sdec = proc{|v| c4.call(conv4.call(v))}
end
else
- if( dec )
- proc_decode = dec
+ if( c4 )
+ sdec = c4
end
end
end
}
- return [alias_type, proc_encode, proc_decode]
+ ty = ty.strip
+ if( ty.length != 1 )
+ raise(TypeError, "unknown type: #{orig_ty}.")
+ end
+ return [ty,enc,dec,senc,sdec]
end
end # end of Types
end
diff --git a/ext/dl/sym.c b/ext/dl/sym.c
index 59a618496f..c2f5434c61 100644
--- a/ext/dl/sym.c
+++ b/ext/dl/sym.c
@@ -154,9 +154,8 @@ rb_dlsym_initialize(int argc, VALUE argv[], VALUE self)
rb_scan_args(argc, argv, "12", &addr, &name, &type);
saddr = (void*)(DLNUM2LONG(rb_Integer(addr)));
- if (!NIL_P(name)) StringValue(name);
+ sname = NIL_P(name) ? NULL : StringValuePtr(name);
stype = NIL_P(type) ? NULL : StringValuePtr(type);
- sname = NIL_P(name) ? NULL : RSTRING(name)->ptr;
if( saddr ){
Data_Get_Struct(self, struct sym_data, data);
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index e59b01addf..799445a89c 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -44,11 +44,6 @@ closed_dbm()
if (dbmp->di_dbm == 0) closed_dbm();\
} while (0)
-#define GetDBM2(obj, data, dbm) {\
- GetDBM(obj, data);\
- (dbm) = dbmp->di_dbm;\
-}
-
static void
free_dbm(dbmp)
struct dbmdata *dbmp;
@@ -207,7 +202,8 @@ rb_gdbm_fetch3(obj, keystr)
struct dbmdata *dbmp;
GDBM_FILE dbm;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
return rb_gdbm_fetch2(dbm, keystr);
}
@@ -303,7 +299,8 @@ fgdbm_index(obj, valstr)
VALUE keystr, valstr2;
StringValue(valstr);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
@@ -352,16 +349,15 @@ fgdbm_select(argc, argv, obj)
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
}
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
- VALUE v = rb_yield(assoc);
- if (RTEST(v)) {
- rb_ary_push(new, assoc);
- }
- GetDBM2(obj, dbmp, dbm);
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
}
}
else {
@@ -412,7 +408,9 @@ rb_gdbm_delete(obj, keystr)
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
if (!gdbm_exists(dbm, key)) {
return Qnil;
}
@@ -447,7 +445,9 @@ fgdbm_shift(obj)
VALUE keystr, valstr;
rb_gdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
keystr = rb_gdbm_firstkey(dbm);
if (NIL_P(keystr)) return Qnil;
valstr = rb_gdbm_fetch2(dbm, keystr);
@@ -467,7 +467,8 @@ fgdbm_delete_if(obj)
int i, status = 0, n;
rb_gdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
n = dbmp->di_size;
dbmp->di_size = -1;
@@ -478,7 +479,6 @@ fgdbm_delete_if(obj)
ret = rb_protect(rb_yield, rb_assoc_new(keystr, valstr), &status);
if (status != 0) break;
if (RTEST(ret)) rb_ary_push(ary, keystr);
- GetDBM2(obj, dbmp, dbm);
}
for (i = 0; i < RARRAY(ary)->len; i++)
@@ -498,7 +498,8 @@ fgdbm_clear(obj)
GDBM_FILE dbm;
rb_gdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
dbmp->di_size = -1;
#if 0
@@ -536,7 +537,8 @@ fgdbm_invert(obj)
VALUE keystr, valstr;
VALUE hash = rb_hash_new();
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
valstr = rb_gdbm_fetch2(dbm, keystr);
@@ -596,16 +598,16 @@ fgdbm_store(obj, keystr, valstr)
rb_gdbm_modify(obj);
StringValue(keystr);
- StringValue(valstr);
-
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
dbmp->di_size = -1;
+ dbm = dbmp->di_dbm;
if (gdbm_store(dbm, key, val, GDBM_REPLACE)) {
if (errno == EPERM) rb_sys_fail(0);
rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
@@ -623,8 +625,9 @@ fgdbm_length(obj)
GDBM_FILE dbm;
int i = 0;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size);
+ dbm = dbmp->di_dbm;
for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
nextkey = gdbm_nextkey(dbm, key);
@@ -668,12 +671,13 @@ fgdbm_each_value(obj)
GDBM_FILE dbm;
VALUE keystr;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
rb_yield(rb_gdbm_fetch2(dbm, keystr));
- GetDBM2(obj, dbmp, dbm);
}
return obj;
}
@@ -686,12 +690,13 @@ fgdbm_each_key(obj)
GDBM_FILE dbm;
VALUE keystr;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
rb_yield(keystr);
- GetDBM2(obj, dbmp, dbm);
}
return obj;
}
@@ -704,12 +709,13 @@ fgdbm_each_pair(obj)
struct dbmdata *dbmp;
VALUE keystr;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
rb_yield(rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)));
- GetDBM2(obj, dbmp, dbm);
}
return obj;
@@ -723,7 +729,9 @@ fgdbm_keys(obj)
GDBM_FILE dbm;
VALUE keystr, ary;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
ary = rb_ary_new();
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
@@ -743,7 +751,9 @@ fgdbm_values(obj)
GDBM_FILE dbm;
VALUE valstr, ary;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
ary = rb_ary_new();
for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
nextkey = gdbm_nextkey(dbm, key);
@@ -767,7 +777,8 @@ fgdbm_has_key(obj, keystr)
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
if (gdbm_exists(dbm, key))
return Qtrue;
return Qfalse;
@@ -782,7 +793,8 @@ fgdbm_has_value(obj, valstr)
VALUE keystr, valstr2;
StringValue(valstr);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
@@ -806,7 +818,9 @@ fgdbm_to_a(obj)
GDBM_FILE dbm;
VALUE keystr, ary;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
ary = rb_ary_new();
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
@@ -825,7 +839,8 @@ fgdbm_reorganize(obj)
GDBM_FILE dbm;
rb_gdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
gdbm_reorganize(dbm);
return obj;
}
@@ -838,7 +853,8 @@ fgdbm_sync(obj)
GDBM_FILE dbm;
rb_gdbm_modify(obj);
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
gdbm_sync(dbm);
return obj;
}
@@ -851,7 +867,9 @@ fgdbm_set_cachesize(obj, val)
GDBM_FILE dbm;
int optval;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
optval = FIX2INT(val);
if (gdbm_setopt(dbm, GDBM_CACHESIZE, &optval, sizeof(optval)) == -1) {
rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
@@ -867,7 +885,9 @@ fgdbm_set_fastmode(obj, val)
GDBM_FILE dbm;
int optval;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
optval = 0;
if (RTEST(val))
optval = 1;
@@ -890,7 +910,9 @@ fgdbm_set_syncmode(obj, val)
GDBM_FILE dbm;
int optval;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
optval = 0;
if (RTEST(val))
optval = 1;
@@ -910,7 +932,9 @@ fgdbm_to_hash(obj)
GDBM_FILE dbm;
VALUE keystr, hash;
- GetDBM2(obj, dbmp, dbm);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
hash = rb_hash_new();
for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
keystr = rb_gdbm_nextkey(dbm, keystr)) {
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index c395373ff2..29ab2c7d7b 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -732,7 +732,7 @@ iconv_iconv
return iconv_convert(VALUE2ICONV(cd), str,
NIL_P(n1) ? 0 : NUM2INT(n1),
- NIL_P(n2) ? -1 : NUM2INT(n2),
+ NIL_P(n2) ? -1 : NUM2INT(n1),
NULL);
}
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
index 5fa1956bf9..aa7c459b83 100644
--- a/ext/nkf/nkf-utf8/nkf.c
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -39,14 +39,14 @@
** E-Mail: furukawa@tcp-ip.or.jp
** $B$^$G8fO"Mm$r$*4j$$$7$^$9!#(B
***********************************************************************/
-/* $Id$ */
-#define NKF_VERSION "2.0.4"
-#define NKF_RELEASE_DATE "2004-12-01"
#include "config.h"
static char *CopyRight =
"Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW, 2002-2004 Kono, Furukawa";
-
+static char *Version =
+ "2.0";
+static char *Patchlevel =
+ "4/0401/Shinji Kono";
/*
**
@@ -110,8 +110,6 @@ static char *CopyRight =
#include <stdio.h>
#endif
-#include <stdlib.h>
-
#if defined(MSDOS) || defined(__OS2__)
#include <fcntl.h>
#include <io.h>
@@ -144,6 +142,7 @@ static char *CopyRight =
#ifdef OVERWRITE
/* added by satoru@isoternet.org */
+#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#ifndef MSDOS /* UNIX, OS/2 */
@@ -199,7 +198,7 @@ static char *CopyRight =
#define UTF8 12
#define UTF8_INPUT 13
-#define UTF16LE_INPUT 14
+#define UTF16_INPUT 14
#define UTF16BE_INPUT 15
#define WISH_TRUE 15
@@ -207,7 +206,6 @@ static char *CopyRight =
/* ASCII CODE */
#define BS 0x08
-#define TAB 0x09
#define NL 0x0a
#define CR 0x0d
#define ESC 0x1b
@@ -218,7 +216,6 @@ static char *CopyRight =
#define SI 0x0f
#define SO 0x0e
#define SSO 0x8e
-#define SS3 0x8f
#define is_alnum(c) \
(('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))
@@ -379,9 +376,8 @@ static int x0201_f = NO_X0201; /* Assume NO JISX0201 */
#endif
static int iso2022jp_f = FALSE; /* convert ISO-2022-JP */
#ifdef UTF8_OUTPUT_ENABLE
-static int unicode_bom_f= 0; /* Output Unicode BOM */
+static int w_oconv16_begin_f= 0; /* utf-16 header */
static int w_oconv16_LE = 0; /* utf-16 little endian */
-static int ms_ucs_map_f = FALSE; /* Microsoft UCS Mapping Compatible */
#endif
@@ -433,7 +429,7 @@ STATIC int cp932_f = TRUE;
#define CP932_TABLE_BEGIN (0xfa)
#define CP932_TABLE_END (0xfc)
-STATIC int cp932inv_f = TRUE;
+STATIC int cp932inv_f = FALSE;
#define CP932INV_TABLE_BEGIN (0xed)
#define CP932INV_TABLE_END (0xee)
@@ -447,7 +443,7 @@ STATIC void s_status PROTO((struct input_code *, int));
#ifdef UTF8_INPUT_ENABLE
STATIC void w_status PROTO((struct input_code *, int));
STATIC void w16_status PROTO((struct input_code *, int));
-static int utf16_mode = UTF16LE_INPUT;
+static int utf16_mode = UTF16_INPUT;
#endif
struct input_code input_code_list[] = {
@@ -471,8 +467,8 @@ static int fold_f = FALSE;
static int fold_len = 0;
/* options */
-static unsigned char kanji_intro = DEFAULT_J;
-static unsigned char ascii_intro = DEFAULT_R;
+static unsigned char kanji_intro = DEFAULT_J,
+ ascii_intro = DEFAULT_R;
/* Folding */
@@ -647,7 +643,7 @@ main(argc, argv)
FILE *fin;
unsigned char *cp;
- char *outfname = NULL;
+ char *outfname;
char *origfname;
#ifdef EASYWIN /*Easy Win */
@@ -723,8 +719,8 @@ main(argc, argv)
return(-1);
} else {
#ifdef OVERWRITE
- int fd = 0;
- int fd_backup = 0;
+ int fd;
+ int fd_backup;
#endif
/* reopen file for stdout */
@@ -893,12 +889,9 @@ struct {
{"katakana","h2"},
{"katakana-hiragana","h3"},
{"guess", "g"},
- {"cp932", ""},
- {"no-cp932", ""},
#ifdef UTF8_OUTPUT_ENABLE
{"utf8", "w"},
{"utf16", "w16"},
- {"ms-ucs-map", ""},
#endif
#ifdef UTF8_INPUT_ENABLE
{"utf8-input", "W"},
@@ -919,6 +912,7 @@ struct {
{"debug", ""},
#endif
#ifdef SHIFTJIS_CP932
+ {"no-cp932", ""},
{"cp932inv", ""},
#endif
#ifdef EXEC_IO
@@ -928,24 +922,20 @@ struct {
{"prefix=", ""},
};
-static int option_mode = 0;
+static int option_mode;
void
options(cp)
unsigned char *cp;
{
int i;
- unsigned char *p = NULL;
+ unsigned char *p;
if (option_mode==1)
return;
if (*cp++ != '-')
return;
while (*cp) {
- if (p && !*cp) {
- cp = p;
- p = 0;
- }
switch (*cp++) {
case '-': /* literal options */
if (!*cp) { /* ignore the rest of arguments */
@@ -956,9 +946,9 @@ options(cp)
int j;
p = (unsigned char *)long_option[i].name;
for (j=0;*p && (*p != '=') && *p == cp[j];p++, j++);
- if (!*p || *p == cp[j]){
- p = &cp[j];
- break;
+ if (*p == cp[j]){
+ p = &cp[j];
+ break;
}
p = 0;
}
@@ -998,27 +988,11 @@ options(cp)
continue;
}
#endif
- if (strcmp(long_option[i].name, "cp932") == 0){
#ifdef SHIFTJIS_CP932
- cp932_f = TRUE;
- cp932inv_f = TRUE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = TRUE;
-#endif
- continue;
- }
if (strcmp(long_option[i].name, "no-cp932") == 0){
-#ifdef SHIFTJIS_CP932
cp932_f = FALSE;
- cp932inv_f = FALSE;
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- ms_ucs_map_f = FALSE;
-#endif
continue;
}
-#ifdef SHIFTJIS_CP932
if (strcmp(long_option[i].name, "cp932inv") == 0){
cp932inv_f = TRUE;
continue;
@@ -1034,12 +1008,6 @@ options(cp)
return;
}
#endif
-#ifdef UTF8_OUTPUT_ENABLE
- if (strcmp(long_option[i].name, "ms-ucs-map") == 0){
- ms_ucs_map_f = TRUE;
- continue;
- }
-#endif
if (strcmp(long_option[i].name, "prefix=") == 0){
if (*p == '=' && ' ' < p[1] && p[1] < 128){
for (i = 2; ' ' < p[i] && p[i] < 128; i++){
@@ -1114,23 +1082,17 @@ options(cp)
if ('1'== cp[0] && '6'==cp[1]) {
output_conv = w_oconv16; cp+=2;
if (cp[0]=='L') {
- unicode_bom_f=2; cp++;
+ w_oconv16_begin_f=2; cp++;
w_oconv16_LE = 1;
if (cp[0] == '0'){
- unicode_bom_f=1; cp++;
+ w_oconv16_begin_f=1; cp++;
}
} else if (cp[0] == 'B') {
- unicode_bom_f=2; cp++;
+ w_oconv16_begin_f=2; cp++;
if (cp[0] == '0'){
- unicode_bom_f=1; cp++;
+ w_oconv16_begin_f=1; cp++;
}
- }
- } else if (cp[0] == '8') {
- output_conv = w_oconv; cp++;
- unicode_bom_f=2;
- if (cp[0] == '0'){
- unicode_bom_f=1; cp++;
- }
+ }
} else
output_conv = w_oconv;
continue;
@@ -1138,16 +1100,7 @@ options(cp)
#ifdef UTF8_INPUT_ENABLE
case 'W': /* UTF-8 input */
if ('1'== cp[0] && '6'==cp[1]) {
- input_f = UTF16LE_INPUT;
- if (cp[0]=='L') {
- cp++;
- } else if (cp[0] == 'B') {
- cp++;
- input_f = UTF16BE_INPUT;
- }
- } else if (cp[0] == '8') {
- cp++;
- input_f = UTF8_INPUT;
+ input_f = UTF16_INPUT;
} else
input_f = UTF8_INPUT;
continue;
@@ -1677,17 +1630,21 @@ code_status(c)
}
}
+#ifdef PERL_XS
#define STD_GC_BUFSIZE (256)
int std_gc_buf[STD_GC_BUFSIZE];
int std_gc_ndx;
+#endif
int
std_getc(f)
FILE *f;
{
+#ifdef PERL_XS
if (std_gc_ndx){
return std_gc_buf[--std_gc_ndx];
}
+#endif
return getc(f);
}
@@ -1696,11 +1653,14 @@ std_ungetc(c,f)
int c;
FILE *f;
{
+#ifdef PERL_XS
if (std_gc_ndx == STD_GC_BUFSIZE){
return EOF;
}
std_gc_buf[std_gc_ndx++] = c;
return c;
+#endif
+ return ungetc(c,f);
}
void
@@ -1800,7 +1760,7 @@ module_connection()
#ifdef UTF8_INPUT_ENABLE
} else if (input_f == UTF8_INPUT) {
set_iconv(-TRUE, w_iconv);
- } else if (input_f == UTF16LE_INPUT) {
+ } else if (input_f == UTF16_INPUT) {
set_iconv(-TRUE, w_iconv16);
#endif
} else {
@@ -2079,34 +2039,6 @@ kanji_convert(f)
} else if ((c1 == NL || c1 == CR) && broken_f&4) {
input_mode = ASCII; set_iconv(FALSE, 0);
SEND;
- /*
- } else if (c1 == NL && mime_f && !mime_decode_mode ) {
- if ((c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
- i_ungetc(SPACE,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- c1 = NL;
- SEND;
- } else if (c1 == CR && mime_f && !mime_decode_mode ) {
- if ((c1=(*i_getc)(f))!=EOF) {
- if (c1==SPACE) {
- i_ungetc(SPACE,f);
- continue;
- } else if (c1 == NL && (c1=(*i_getc)(f))!=EOF && c1 == SPACE) {
- i_ungetc(SPACE,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- i_ungetc(NL,f);
- } else {
- i_ungetc(c1,f);
- }
- c1 = CR;
- SEND;
- */
} else
SEND;
}
@@ -2432,7 +2364,7 @@ w_iconv16(c2, c1, c0)
int ret;
if (c2==0376 && c1==0377){
- utf16_mode = UTF16LE_INPUT;
+ utf16_mode = UTF16_INPUT;
return 0;
} else if (c2==0377 && c1==0376){
utf16_mode = UTF16BE_INPUT;
@@ -2492,7 +2424,6 @@ e2w_conv(c2, c1)
{
extern unsigned short euc_to_utf8_1byte[];
extern unsigned short * euc_to_utf8_2bytes[];
- extern unsigned short * euc_to_utf8_2bytes_ms[];
unsigned short *p;
if (c2 == X0201) {
@@ -2501,7 +2432,7 @@ e2w_conv(c2, c1)
c2 &= 0x7f;
c2 = (c2&0x7f) - 0x21;
if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
- p = ms_ucs_map_f ? euc_to_utf8_2bytes_ms[c2] : euc_to_utf8_2bytes[c2];
+ p = euc_to_utf8_2bytes[c2];
else
return 0;
}
@@ -2531,16 +2462,7 @@ w_oconv(c2, c1)
if (c2 == EOF) {
(*o_putc)(EOF);
return;
- }
-
- if (unicode_bom_f==2) {
- (*o_putc)('\357');
- (*o_putc)('\273');
- (*o_putc)('\277');
- unicode_bom_f=1;
- }
-
- if (c2 == 0) {
+ } else if (c2 == 0) {
output_mode = ASCII;
(*o_putc)(c1);
} else if (c2 == ISO8859_1) {
@@ -2567,7 +2489,7 @@ w_oconv16(c2, c1)
return;
}
- if (unicode_bom_f==2) {
+ if (w_oconv16_begin_f==2) {
if (w_oconv16_LE){
(*o_putc)((unsigned char)'\377');
(*o_putc)('\376');
@@ -2575,7 +2497,7 @@ w_oconv16(c2, c1)
(*o_putc)('\376');
(*o_putc)((unsigned char)'\377');
}
- unicode_bom_f=1;
+ w_oconv16_begin_f=1;
}
if (c2 == ISO8859_1) {
@@ -2757,12 +2679,11 @@ base64_conv(c2, c1)
c1;
{
if (base64_count>50 && !mimeout_mode && c2==0 && c1==SPACE) {
- (*o_putc)(EOF);
(*o_putc)(NL);
} else if (base64_count>66 && mimeout_mode) {
(*o_base64conv)(EOF,0);
- (*o_base64conv)(NL,0);
- (*o_base64conv)(SPACE,0);
+ (*o_putc)(NL);
+ (*o_putc)('\t'); base64_count += 7;
}
(*o_base64conv)(c2,c1);
}
@@ -3609,10 +3530,6 @@ FILE *f;
{
int c1, c2, c3, c4, cc;
int t1, t2, t3, t4, mode, exit_mode;
- int lwsp_count;
- char *lwsp_buf;
- char *lwsp_buf_new;
- int lwsp_size = 128;
if (mime_top != mime_last) { /* Something is in FIFO */
return Fifo(mime_top++);
@@ -3641,69 +3558,8 @@ restart_mime_q:
if (c1=='?'&&c2=='=' && mimebuf_f != FIXED_MIME) {
/* end Q encoding */
input_mode = exit_mode;
- lwsp_count = 0;
- lwsp_buf = malloc((lwsp_size+5)*sizeof(char));
- if (lwsp_buf==NULL) {
- perror("can't malloc");
- return -1;
- }
- while ((c1=(*i_getc)(f))!=EOF) {
- switch (c1) {
- case NL:
- case CR:
- if (c1==NL) {
- if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
- i_ungetc(SPACE,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- c1 = NL;
- } else {
- if ((c1=(*i_getc)(f))!=EOF && c1 == NL) {
- if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
- i_ungetc(SPACE,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- i_ungetc(NL,f);
- } else {
- i_ungetc(c1,f);
- }
- c1 = CR;
- }
- break;
- case SPACE:
- case TAB:
- lwsp_buf[lwsp_count] = c1;
- if (lwsp_count++>lwsp_size){
- lwsp_size *= 2;
- lwsp_buf_new = realloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
- if (lwsp_buf_new==NULL) {
- free(lwsp_buf);
- lwsp_buf = NULL;
- perror("can't realloc");
- return -1;
- }
- lwsp_buf = lwsp_buf_new;
- }
- continue;
- }
- break;
- }
- if (lwsp_count > 0) {
- if (c1=='=' && (lwsp_buf[lwsp_count-1]==SPACE||lwsp_buf[lwsp_count-1]==TAB)) {
- lwsp_count = 0;
- } else {
- i_ungetc(c1,f);
- for(lwsp_count--;lwsp_count>0;lwsp_count--)
- i_ungetc(lwsp_buf[lwsp_count],f);
- c1 = lwsp_buf[0];
- }
- }
- free(lwsp_buf);
- lwsp_buf = NULL;
+ while((c1=(*i_getc)(f))!=EOF && c1==SPACE
+ /* && (c1==NL||c1==TAB||c1=='\r') */ ) ;
return c1;
}
if (c1=='='&&c2<' ') { /* this is soft wrap */
@@ -3757,72 +3613,8 @@ mime_c2_retry:
}
if ((c1 == '?') && (c2 == '=')) {
input_mode = ASCII;
- lwsp_count = 0;
- lwsp_buf = malloc((lwsp_size+5)*sizeof(char));
- if (lwsp_buf==NULL) {
- perror("can't malloc");
- return -1;
- }
- while ((c1=(*i_getc)(f))!=EOF) {
- switch (c1) {
- case NL:
- case CR:
- if (c1==NL) {
- if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
- i_ungetc(SPACE,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- c1 = NL;
- } else {
- if ((c1=(*i_getc)(f))!=EOF) {
- if (c1==SPACE) {
- i_ungetc(SPACE,f);
- continue;
- } else if ((c1=(*i_getc)(f))!=EOF && (c1==SPACE||c1==TAB)) {
- i_ungetc(SPACE,f);
- continue;
- } else {
- i_ungetc(c1,f);
- }
- i_ungetc(NL,f);
- } else {
- i_ungetc(c1,f);
- }
- c1 = CR;
- }
- break;
- case SPACE:
- case TAB:
- lwsp_buf[lwsp_count] = c1;
- if (lwsp_count++>lwsp_size){
- lwsp_size *= 2;
- lwsp_buf_new = realloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
- if (lwsp_buf_new==NULL) {
- free(lwsp_buf);
- lwsp_buf = NULL;
- perror("can't realloc");
- return -1;
- }
- lwsp_buf = lwsp_buf_new;
- }
- continue;
- }
- break;
- }
- if (lwsp_count > 0) {
- if (c1=='=' && (lwsp_buf[lwsp_count-1]==SPACE||lwsp_buf[lwsp_count-1]==TAB)) {
- lwsp_count = 0;
- } else {
- i_ungetc(c1,f);
- for(lwsp_count--;lwsp_count>0;lwsp_count--)
- i_ungetc(lwsp_buf[lwsp_count],f);
- c1 = lwsp_buf[0];
- }
- }
- free(lwsp_buf);
- lwsp_buf = NULL;
+ while((c1=(*i_getc)(f))!=EOF && c1==SPACE
+ /* && (c1==NL||c1==TAB||c1=='\r') */ ) ;
return c1;
}
mime_c3_retry:
@@ -3940,11 +3732,6 @@ static char basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static int b64c;
-#define MIMEOUT_BUF_LENGTH (60)
-char mimeout_buf[MIMEOUT_BUF_LENGTH+1];
-int mimeout_buf_count = 0;
-int mimeout_preserve_space = 0;
-#define itoh4(c) (c>=10?c+'A'-10:c+'0')
void
open_mime(mode)
@@ -3952,49 +3739,20 @@ int mode;
{
unsigned char *p;
int i;
- int j;
p = mime_pattern[0];
for(i=0;mime_encode[i];i++) {
if (mode == mime_encode[i]) {
p = mime_pattern[i];
- break;
- }
- }
- mimeout_mode = mime_encode_method[i];
-
- i = 0;
- if (base64_count>45) {
- (*o_mputc)(NL);
- (*o_mputc)(SPACE);
- base64_count = 1;
- if (!mimeout_preserve_space && mimeout_buf_count>0
- && (mimeout_buf[i]==SPACE || mimeout_buf[i]==TAB
- || mimeout_buf[i]==CR || mimeout_buf[i]==NL )) {
- i++;
- }
- }
- if (!mimeout_preserve_space) {
- for (;i<mimeout_buf_count;i++) {
- if (mimeout_buf[i]==SPACE || mimeout_buf[i]==TAB
- || mimeout_buf[i]==CR || mimeout_buf[i]==NL ) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count ++;
- } else {
break;
- }
}
}
- mimeout_preserve_space = FALSE;
-
+ mimeout_mode = mime_encode_method[i];
+
+ /* (*o_mputc)(' '); */
while(*p) {
(*o_mputc)(*p++);
base64_count ++;
}
- j = mimeout_buf_count;
- mimeout_buf_count = 0;
- for (;i<j;i++) {
- mime_putc(mimeout_buf[i]);
- }
}
void
@@ -4002,51 +3760,80 @@ close_mime()
{
(*o_mputc)('?');
(*o_mputc)('=');
- base64_count += 2;
+ (*o_mputc)(' ');
+ base64_count += 3;
mimeout_mode = 0;
}
-void
-eof_mime()
-{
- switch(mimeout_mode) {
- case 'Q':
- case 'B':
- break;
- case 2:
- (*o_mputc)(basis_64[((b64c & 0x3)<< 4)]);
- (*o_mputc)('=');
- (*o_mputc)('=');
- base64_count += 3;
- break;
- case 1:
- (*o_mputc)(basis_64[((b64c & 0xF) << 2)]);
- (*o_mputc)('=');
- base64_count += 2;
- break;
- }
- if (mimeout_mode) {
- if (mimeout_f!=FIXED_MIME) {
- close_mime();
- } else if (mimeout_mode != 'Q')
- mimeout_mode = 'B';
- }
-}
+#define itoh4(c) (c>=10?c+'A'-10:c+'0')
void
-mimeout_addchar(c)
+mime_putc(c)
int c;
{
+ if (mimeout_f==FIXED_MIME) {
+ if (base64_count>71) {
+ (*o_mputc)('\n');
+ base64_count=0;
+ }
+ } else if (c==NL) {
+ base64_count=0;
+ }
+ if (c!=EOF) {
+ if ( c<=DEL &&(output_mode==ASCII ||output_mode == ISO8859_1 )
+ && mimeout_f!=FIXED_MIME) {
+ if (mimeout_mode=='Q') {
+ if (c<=SPACE) {
+ close_mime();
+ }
+ (*o_mputc)(c);
+ return;
+ }
+ if (mimeout_mode!='B' || c!=SPACE) {
+ if (mimeout_mode) {
+ mime_putc(EOF);
+ mimeout_mode=0;
+ }
+ (*o_mputc)(c);
+ base64_count ++;
+ return;
+ }
+ } else if (!mimeout_mode && mimeout_f!=FIXED_MIME) {
+ open_mime(output_mode);
+ }
+ } else { /* c==EOF */
+ switch(mimeout_mode) {
+ case 'Q':
+ case 'B':
+ break;
+ case 2:
+ (*o_mputc)(basis_64[((b64c & 0x3)<< 4)]);
+ (*o_mputc)('=');
+ (*o_mputc)('=');
+ base64_count += 3;
+ break;
+ case 1:
+ (*o_mputc)(basis_64[((b64c & 0xF) << 2)]);
+ (*o_mputc)('=');
+ base64_count += 2;
+ break;
+ }
+ if (mimeout_mode) {
+ if (mimeout_f!=FIXED_MIME) {
+ close_mime();
+ } else if (mimeout_mode != 'Q')
+ mimeout_mode = 'B';
+ }
+ return;
+ }
switch(mimeout_mode) {
case 'Q':
if(c>=DEL) {
(*o_mputc)('=');
(*o_mputc)(itoh4(((c>>4)&0xf)));
(*o_mputc)(itoh4((c&0xf)));
- base64_count += 3;
} else {
(*o_mputc)(c);
- base64_count++;
}
break;
case 'B':
@@ -4070,229 +3857,102 @@ mimeout_addchar(c)
}
}
-void
-mime_putc(c)
- int c;
-{
- int i = 0;
- int j = 0;
-
- if (mimeout_f==FIXED_MIME && base64_count>50) {
- eof_mime();
- (*o_mputc)(NL);
- base64_count=0;
- } else if (c==CR||c==NL) {
- base64_count=0;
- }
- if (c!=EOF && mimeout_f!=FIXED_MIME) {
- if ( c<=DEL &&(output_mode==ASCII ||output_mode == ISO8859_1 ) ) {
- if (mimeout_mode=='Q') {
- if (c<=SPACE) {
- close_mime();
- (*o_mputc)(SPACE);
- base64_count++;
- }
- (*o_mputc)(c);
- base64_count++;
- return;
- } else if (mimeout_mode) {
- if (base64_count>63) {
- eof_mime();
- (*o_mputc)(NL);
- (*o_mputc)(SPACE);
- base64_count=1;
- mimeout_preserve_space = TRUE;
- }
- if (c==SPACE || c==TAB || c==CR || c==NL) {
- for (i=0;i<mimeout_buf_count;i++) {
- if (SPACE<mimeout_buf[i] && mimeout_buf[i]<DEL) {
- eof_mime();
- for (i=0;i<mimeout_buf_count;i++) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count++;
- }
- mimeout_buf_count = 0;
- }
- }
- mimeout_buf[mimeout_buf_count++] = c;
- if (mimeout_buf_count>MIMEOUT_BUF_LENGTH) {
- eof_mime();
- base64_count = 0;
- for (i=0;i<mimeout_buf_count;i++) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count++;
- }
- }
- return;
- }
- if (mimeout_buf_count>0 && SPACE<c) {
- mimeout_buf[mimeout_buf_count++] = c;
- if (mimeout_buf_count>MIMEOUT_BUF_LENGTH) {
- } else {
- return;
- }
- }
- } else if (!mimeout_mode) {
- if (c==SPACE || c==TAB || c==CR || c==NL) {
- if ((c==CR || c==NL)
- &&(mimeout_buf[mimeout_buf_count-1]==SPACE
- || mimeout_buf[mimeout_buf_count-1]==TAB)) {
- mimeout_buf_count--;
- }
- for (i=0;i<mimeout_buf_count;i++) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count++;
- }
- mimeout_buf_count = 0;
- }
- mimeout_buf[mimeout_buf_count++] = c;
- if (mimeout_buf_count>75) {
- open_mime(output_mode);
- }
- return;
- }
- } else if (!mimeout_mode) {
- if (mimeout_buf_count>0 && mimeout_buf[mimeout_buf_count-1]==SPACE) {
- for (i=0;i<mimeout_buf_count-1;i++) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count++;
- }
- mimeout_buf[0] = SPACE;
- mimeout_buf_count = 1;
- }
- open_mime(output_mode);
- }
- } else { /* c==EOF */
- j = mimeout_buf_count;
- i = 0;
- for (;i<j;i++) {
- if (mimeout_buf[i]==SPACE || mimeout_buf[i]==TAB
- || mimeout_buf[i]==CR || mimeout_buf[i]==NL)
- break;
- (*mime_putc)(mimeout_buf[i]);
- }
- eof_mime();
- for (;i<j;i++) {
- (*o_mputc)(mimeout_buf[i]);
- base64_count++;
- }
- return;
- }
-
- if (mimeout_buf_count>0) {
- j = mimeout_buf_count;
- mimeout_buf_count = 0;
- for (i=0;i<j;i++) {
- mimeout_addchar(mimeout_buf[i]);
- }
- }
- mimeout_addchar(c);
-}
-
#ifdef PERL_XS
void
reinit()
{
- {
- struct input_code *p = input_code_list;
- while (p->name){
- status_reinit(p++);
- }
- }
unbuf_f = FALSE;
estab_f = FALSE;
nop_f = FALSE;
- binmode_f = TRUE;
- rot_f = FALSE;
- hira_f = FALSE;
- input_f = FALSE;
- alpha_f = FALSE;
- mime_f = STRICT_MIME;
- mimebuf_f = FALSE;
- broken_f = FALSE;
- iso8859_f = FALSE;
- mimeout_f = FALSE;
-#if defined(MSDOS) || defined(__OS2__)
- x0201_f = TRUE;
+ binmode_f = TRUE;
+ rot_f = FALSE;
+ hira_f = FALSE;
+ input_f = FALSE;
+ alpha_f = FALSE;
+ mime_f = STRICT_MIME;
+ mimebuf_f = FALSE;
+ broken_f = FALSE;
+ iso8859_f = FALSE;
+#if defined(MSDOS) || defined(__OS2__)
+ x0201_f = TRUE;
#else
x0201_f = NO_X0201;
#endif
iso2022jp_f = FALSE;
-#ifdef UTF8_OUTPUT_ENABLE
- unicode_bom_f = 0;
- w_oconv16_LE = 0;
- ms_ucs_map_f = FALSE;
-#endif
-#ifdef INPUT_OPTION
- cap_f = FALSE;
- url_f = FALSE;
- numchar_f = FALSE;
-#endif
-#ifdef CHECK_OPTION
- noout_f = FALSE;
- debug_f = FALSE;
-#endif
- guess_f = FALSE;
- is_inputcode_mixed = FALSE;
- is_inputcode_set = FALSE;
-#ifdef EXEC_IO
- exec_f = 0;
-#endif
-#ifdef SHIFTJIS_CP932
- cp932_f = TRUE;
- cp932inv_f = TRUE;
-#endif
- {
- int i;
- for (i = 0; i < 256; i++){
- prefix_table[i] = 0;
- }
- }
-#ifdef UTF8_INPUT_ENABLE
- utf16_mode = UTF16LE_INPUT;
-#endif
- mimeout_buf_count = 0;
- mimeout_mode = 0;
- base64_count = 0;
- f_line = 0;
- f_prev = 0;
- fold_preserve_f = FALSE;
- fold_f = FALSE;
- fold_len = 0;
+
kanji_intro = DEFAULT_J;
ascii_intro = DEFAULT_R;
- fold_margin = FOLD_MARGIN;
- output_conv = DEFAULT_CONV;
- oconv = DEFAULT_CONV;
- o_zconv = no_connection;
- o_fconv = no_connection;
- o_crconv = no_connection;
- o_rot_conv = no_connection;
- o_hira_conv = no_connection;
- o_base64conv = no_connection;
- o_iso2022jp_check_conv = no_connection;
+
+ output_conv = DEFAULT_CONV;
+ oconv = DEFAULT_CONV;
+
+ i_mgetc = std_getc;
+ i_mungetc = std_ungetc;
+ i_mgetc_buf = std_getc;
+ i_mungetc_buf = std_ungetc;
+
+ i_getc= std_getc;
+ i_ungetc=std_ungetc;
+
+ i_bgetc= std_getc;
+ i_bungetc= std_ungetc;
+
o_putc = std_putc;
+ o_mputc = std_putc;
+ o_crconv = no_connection;
+ o_rot_conv = no_connection;
+ o_iso2022jp_check_conv = no_connection;
+ o_hira_conv = no_connection;
+ o_fconv = no_connection;
+ o_zconv = no_connection;
+
i_getc = std_getc;
i_ungetc = std_ungetc;
- i_bgetc = std_getc;
- i_bungetc = std_ungetc;
- o_mputc = std_putc;
- i_mgetc = std_getc;
- i_mungetc = std_ungetc;
- i_mgetc_buf = std_getc;
- i_mungetc_buf = std_ungetc;
+ i_mgetc = std_getc;
+ i_mungetc = std_ungetc;
+
output_mode = ASCII;
input_mode = ASCII;
shift_mode = FALSE;
- mime_decode_mode = FALSE;
+ mime_decode_mode = FALSE;
file_out = FALSE;
- crmode_f = 0;
+ mimeout_mode = 0;
+ mimeout_f = FALSE;
+ base64_count = 0;
option_mode = 0;
+ crmode_f = 0;
+
+ {
+ struct input_code *p = input_code_list;
+ while (p->name){
+ status_reinit(p++);
+ }
+ }
+#ifdef UTF8_OUTPUT_ENABLE
+ if (w_oconv16_begin_f) {
+ w_oconv16_begin_f = 2;
+ }
+#endif
+ f_line = 0;
+ f_prev = 0;
+ fold_preserve_f = FALSE;
+ fold_f = FALSE;
+ fold_len = 0;
+ fold_margin = FOLD_MARGIN;
broken_counter = 0;
broken_last = 0;
z_prev2=0,z_prev1=0;
+ {
+ int i;
+ for (i = 0; i < 256; i++){
+ prefix_table[i] = 0;
+ }
+ }
+ input_codename = "";
+ is_inputcode_mixed = FALSE;
+ is_inputcode_set = FALSE;
}
#endif
@@ -4330,13 +3990,7 @@ usage()
#ifdef DEFAULT_CODE_UTF8
fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS, AT&T JIS (EUC), UTF-8 (DEFAULT)\n");
#endif
-#ifdef UTF8_OUTPUT_ENABLE
- fprintf(stderr," After 'w' you can add more options. (80?|16((B|L)0?)?) \n");
-#endif
fprintf(stderr,"J,S,E,W Input assumption is JIS 7 bit , Shift JIS, AT&T JIS (EUC), UTF-8\n");
-#ifdef UTF8_INPUT_ENABLE
- fprintf(stderr," After 'W' you can add more options. (8|16(B|L)?) \n");
-#endif
fprintf(stderr,"t no conversion\n");
fprintf(stderr,"i_/o_ Output sequence to designate JIS-kanji/ASCII (DEFAULT B)\n");
fprintf(stderr,"r {de/en}crypt ROT13/47\n");
@@ -4358,23 +4012,12 @@ usage()
fprintf(stderr,"I Convert non ISO-2022-JP charactor to GETA\n");
fprintf(stderr,"-L[uwm] line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n");
fprintf(stderr,"long name options\n");
- fprintf(stderr," --fj,--unix,--mac,--windows convert for the system\n");
+ fprintf(stderr," --fj,--unix,--mac,--windows convert for the system\n");
fprintf(stderr," --jis,--euc,--sjis,--utf8,--utf16,--mime,--base64 convert for the code\n");
- fprintf(stderr," --hiragana, --katakana Hiragana/Katakana Conversion\n");
- fprintf(stderr," --cp932, --no-cp932 CP932 compatible\n");
-#ifdef INPUT_OPTION
- fprintf(stderr," --cap-input, --url-input Convert hex after ':' or '%%'\n");
-#endif
-#ifdef NUMCHAR_OPTION
- fprintf(stderr," --numchar-input Convert Unicode Character Reference\n");
-#endif
-#ifdef UTF8_OUTPUT_ENABLE
- fprintf(stderr," --ms-ucs-map Microsoft UCS Mapping Compatible\n");
-#endif
#ifdef OVERWRITE
- fprintf(stderr," --overwrite Overwrite original listed files by filtered result\n");
+ fprintf(stderr," --overwrite Overwrite original listed files by filtered result\n");
#endif
- fprintf(stderr," -g, --guess Guess the input code\n");
+ fprintf(stderr," -g, --guess Guess the input code\n");
fprintf(stderr," --help,--version\n");
version();
}
@@ -4395,7 +4038,7 @@ version()
#ifdef __OS2__
"for OS/2"
#endif
- ,NKF_VERSION,NKF_RELEASE_DATE);
+ ,Version,Patchlevel);
fprintf(stderr,"\n%s\n",CopyRight);
}
#endif
diff --git a/ext/nkf/nkf-utf8/utf8tbl.c b/ext/nkf/nkf-utf8/utf8tbl.c
index 7969081b4f..b2e49c49d2 100644
--- a/ext/nkf/nkf-utf8/utf8tbl.c
+++ b/ext/nkf/nkf-utf8/utf8tbl.c
@@ -15,23 +15,6 @@ unsigned short euc_to_utf8_A1[] = {
0xFF04, 0x00A2, 0x00A3, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
};
-
-/* Microsoft UCS Mapping Compatible */
-unsigned short euc_to_utf8_A1_ms[] = {
- 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A,
- 0xFF1B, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8,
- 0xFF3E, 0xFFE3, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003,
- 0x4EDD, 0x3005, 0x3006, 0x3007, 0x30FC, 0x2015, 0x2010, 0xFF0F,
- 0xFF3C, 0xFF5E, 0x2225, 0xFF5C, 0x2026, 0x2025, 0x2018, 0x2019,
- 0x201C, 0x201D, 0xFF08, 0xFF09, 0x3014, 0x3015, 0xFF3B, 0xFF3D,
- 0xFF5B, 0xFF5D, 0x3008, 0x3009, 0x300A, 0x300B, 0x300C, 0x300D,
- 0x300E, 0x300F, 0x3010, 0x3011, 0xFF0B, 0xFF0D, 0x00B1, 0x00D7,
- 0x00F7, 0xFF1D, 0x2260, 0xFF1C, 0xFF1E, 0x2266, 0x2267, 0x221E,
- 0x2234, 0x2642, 0x2640, 0x00B0, 0x2032, 0x2033, 0x2103, 0xFFE5,
- 0xFF04, 0xFFE0, 0xFFE1, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
- 0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
-};
-
unsigned short euc_to_utf8_A2[] = {
0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
@@ -46,22 +29,6 @@ unsigned short euc_to_utf8_A2[] = {
0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
};
-
-/* Microsoft UCS Mapping Compatible */
-unsigned short euc_to_utf8_A2_ms[] = {
- 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
- 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
- 0x222A, 0x2229, 0, 0, 0, 0, 0, 0,
- 0, 0, 0x2227, 0x2228, 0xFFE2, 0x21D2, 0x21D4, 0x2200,
- 0x2203, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0x2220, 0x22A5, 0x2312, 0x2202,
- 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
- 0x2235, 0x222B, 0x222C, 0, 0, 0, 0, 0,
- 0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
- 0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
-};
unsigned short euc_to_utf8_A3[] = {
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -1320,33 +1287,6 @@ unsigned short * euc_to_utf8_2bytes[] = {
0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
euc_to_utf8_FC, 0, 0,
};
-/* Microsoft UCS Mapping Compatible */
-unsigned short * euc_to_utf8_2bytes_ms[] = {
- euc_to_utf8_A1_ms,euc_to_utf8_A2_ms, euc_to_utf8_A3,
- euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
- euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
- euc_to_utf8_AC, euc_to_utf8_AD, euc_to_utf8_AE, euc_to_utf8_AF,
- euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
- euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
- euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
- euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
- euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
- euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
- euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
- euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
- euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
- euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
- euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
- euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
- euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
- euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
- euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
- euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
- euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
- euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
- 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
- euc_to_utf8_FC, 0, 0,
-};
#endif /* UTF8_OUTPUT_ENABLE */
#ifdef UTF8_INPUT_ENABLE
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 65442a130c..6517b3aba1 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -1,14 +1,11 @@
/*
* NKF Module for Ruby base on nkf 2.x
*
- * original nkf2.x is maintained at http://sourceforge.jp/projects/nkf/
- *
- * $Id$
+ * original nkf2.0 is maintained at http://sourceforge.jp/projects/nkf/
*
*/
-#define RUBY_NKF_REVISION "$Revision$"
-#define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
+static char *RVersion = "2.0.4.1r1";
#include "ruby.h"
@@ -74,7 +71,6 @@ rb_nkf_putchar(c)
/* getchar and putchar will be replaced during inclusion */
#define PERL_XS 1
-#include "nkf-utf8/config.h"
#include "nkf-utf8/utf8tbl.c"
#include "nkf-utf8/nkf.c"
@@ -89,7 +85,12 @@ rb_nkf_kconv(obj, opt, src)
StringValue(opt);
opt_ptr = RSTRING(opt)->ptr;
opt_end = opt_ptr + RSTRING(opt)->len;
- options(opt_ptr);
+ for (; opt_ptr < opt_end; opt_ptr++) {
+ if (*opt_ptr != '-') {
+ continue;
+ }
+ options(opt_ptr);
+ }
incsize = INCSIZE;
@@ -269,7 +270,7 @@ Init_nkf()
VALUE mKconv = rb_define_module("NKF");
rb_define_module_function(mKconv, "nkf", rb_nkf_kconv, 2);
- rb_define_module_function(mKconv, "guess", rb_nkf_guess2, 1);
+ rb_define_module_function(mKconv, "guess", rb_nkf_guess1, 1);
rb_define_module_function(mKconv, "guess1", rb_nkf_guess1, 1);
rb_define_module_function(mKconv, "guess2", rb_nkf_guess2, 1);
@@ -284,9 +285,5 @@ Init_nkf()
rb_define_const(mKconv, "UTF16", INT2FIX(_UTF16));
rb_define_const(mKconv, "UTF32", INT2FIX(_UTF32));
rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN));
- rb_define_const(mKconv, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
- /* for debug */
- rb_define_const(mKconv, "NKF_VERSION", rb_str_new2(NKF_VERSION));
- rb_define_const(mKconv, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
- rb_define_const(mKconv, "REVISION", rb_str_new2(RUBY_NKF_REVISION));
+ rb_define_const(mKconv, "VERSION", rb_str_new2(RVersion));
}
diff --git a/ext/nkf/test.rb b/ext/nkf/test.rb
index b3406cbb6c..7a2390d649 100644
--- a/ext/nkf/test.rb
+++ b/ext/nkf/test.rb
@@ -1,9 +1,6 @@
#!/usr/local/bin/ruby
#
-# nkf test program for nkf-2
-#
-# $Id$
-#
+# nkf test program for nkf 1.7
# Shinji KONO <kono@ie.u-ryukyu.ac.jp>
# Sun Aug 18 12:25:40 JST 1996
# Sun Nov 8 00:16:06 JST 1998
@@ -72,24 +69,19 @@ def test(opt, input, expects)
print "\nINPUT:\n", input if $detail
print "\nEXPECT:\n", expects.to_s if $detail
result = nkf(opt, input)
- result.delete!(' ') if opt.include?('-m')
print "\nGOT:\n", result if $detail
expects.each do |e|
- e.delete!(' ') if opt.include?('-m')
if result == e then
puts "Ok"
return result
end
end
puts "Fail"
- puts result.unpack('H*').first
- puts expects.map{|x|x.unpack('H*').first}.join("\n\n")
end
-$example = Hash.new
-
+example = Hash.new
# Basic Conversion
print "\nBasic Conversion test\n\n";
@@ -98,173 +90,127 @@ print "\nBasic Conversion test\n\n";
# on perl4 and perl5 on literal quote. Of course we cannot use
# jperl.
-$example['jis'] = <<'eofeof'.unpack('u')[0]
+example['jis'] = <<'eofeof'.unpack('u')[0]
M1FER<W0@4W1A9V4@&R1"(3DQ(3%^2R%+?D]3&RA"(%-E8V]N9"!3=&%G92`;
M)$)0)TU:&RA"($AI<F%G86YA(!LD0B0B)"0D)B0H)"HD;R1R)',;*$(*2V%T
M86MA;F$@&R1")2(E)"4F)2@E*B5O)7(E<QLH0B!+:6=O=2`;)$(A)B%G(S`C
/029!)E@G(B=!*$`;*$(*
eofeof
-$example['sjis'] = <<'eofeof'.unpack('u')[0]
+example['sjis'] = <<'eofeof'.unpack('u')[0]
M1FER<W0@4W1A9V4@@5B)0(F>ED"6GIAR(%-E8V]N9"!3=&%G92"8I9=Y($AI
M<F%G86YA((*@@J*"I(*F@JB"[8+P@O$*2V%T86MA;F$@@T&#0X-%@T>#28./
>@Y*#DR!+:6=O=2"!18&'@D^"8(._@]:$081@A+X*
eofeof
-$example['euc'] = <<'eofeof'.unpack('u')[0]
+example['euc'] = <<'eofeof'.unpack('u')[0]
M1FER<W0@4W1A9V4@H;FQH;'^RZ'+_L_3(%-E8V]N9"!3=&%G92#0I\W:($AI
M<F%G86YA(*2BI*2DIJ2HI*JD[Z3RI/,*2V%T86MA;F$@I:*EI*6FI:BEJJ7O
>I?*E\R!+:6=O=2"AIJ'GH["CP:;!IMBGHJ?!J,`*
eofeof
-$example['utf8'] = <<'eofeof'.unpack('u')[0]
-M[[N_1FER<W0@4W1A9V4@XX"%Z9FBY;^<YK.5YKJ`Z(65(%-E8V]N9"!3=&%G
-M92#DN+SI@:4@2&ER86=A;F$@XX&"XX&$XX&&XX&(XX&*XX*/XX*2XX*3"DMA
-M=&%K86YA(.."HN."I.."IN."J.."JN.#K^.#LN.#LR!+:6=O=2#C@[OBB)[O
-1O)#OO*'.L<^)T)'0K^*5@@H`
-eofeof
-
-$example['utf8N'] = <<'eofeof'.unpack('u')[0]
+example['utf'] = <<'eofeof'.unpack('u')[0]
M1FER<W0@4W1A9V4@XX"%Z9FBY;^<YK.5YKJ`Z(65(%-E8V]N9"!3=&%G92#D
MN+SI@:4@2&ER86=A;F$@XX&"XX&$XX&&XX&(XX&*XX*/XX*2XX*3"DMA=&%K
M86YA(.."HN."I.."IN."J.."JN.#K^.#LN.#LR!+:6=O=2#C@[OBB)[OO)#O
.O*'.L<^)T)'0K^*5@@H`
eofeof
-$example['u16L'] = <<'eofeof'.unpack('u')[0]
-M__Y&`&D`<@!S`'0`(`!3`'0`80!G`&4`(``%,&*6W%_5;(!N58$@`%,`90!C
-M`&\`;@!D`"``4P!T`&$`9P!E`"``/$YED"``2`!I`'(`80!G`&$`;@!A`"``
-M0C!$,$8P2#!*,(\PDC"3,`H`2P!A`'0`80!K`&$`;@!A`"``HC"D,*8PJ#"J
-I,.\P\C#S,"``2P!I`&<`;P!U`"``^S`>(A#_(?^Q`\D#$00O!$(E"@``
-eofeof
-
-$example['u16L0'] = <<'eofeof'.unpack('u')[0]
-M1@!I`'(`<P!T`"``4P!T`&$`9P!E`"``!3!BEMQ?U6R`;E6!(`!3`&4`8P!O
-M`&X`9``@`%,`=`!A`&<`90`@`#Q.99`@`$@`:0!R`&$`9P!A`&X`80`@`$(P
-M1#!&,$@P2C"/,)(PDS`*`$L`80!T`&$`:P!A`&X`80`@`*(PI#"F,*@PJC#O
-G,/(P\S`@`$L`:0!G`&\`=0`@`/LP'B(0_R'_L0/)`Q$$+P1")0H`
-eofeof
-
-$example['u16B'] = <<'eofeof'.unpack('u')[0]
-M_O\`1@!I`'(`<P!T`"``4P!T`&$`9P!E`"`P!99B7]QLU6Z`@54`(`!3`&4`
-M8P!O`&X`9``@`%,`=`!A`&<`90`@3CR090`@`$@`:0!R`&$`9P!A`&X`80`@
-M,$(P1#!&,$@P2C"/,)(PDP`*`$L`80!T`&$`:P!A`&X`80`@,*(PI#"F,*@P
-IJC#O,/(P\P`@`$L`:0!G`&\`=0`@,/LB'O\0_R$#L0/)!!$$+R5"``H`
-eofeof
-
-$example['u16B0'] = <<'eofeof'.unpack('u')[0]
-M`$8`:0!R`',`=``@`%,`=`!A`&<`90`@,`668E_<;-5N@(%5`"``4P!E`&,`
-M;P!N`&0`(`!3`'0`80!G`&4`($X\D&4`(`!(`&D`<@!A`&<`80!N`&$`(#!"
-M,$0P1C!(,$HPCS"2,),`"@!+`&$`=`!A`&L`80!N`&$`(#"B,*0PIC"H,*HP
-G[S#R,/,`(`!+`&D`9P!O`'4`(##[(A[_$/\A`[$#R001!"\E0@`*
-eofeof
-$example['jis1'] = <<'eofeof'.unpack('u')[0]
+example['jis1'] = <<'eofeof'.unpack('u')[0]
M&R1";3%Q<$$L&RA""ALD0F4Z3F\;*$(*&R1"<FT;*$()&R1"/F5.3D]+&RA"
#"0D*
eofeof
-$example['sjis1'] = <<'eofeof'.unpack('u')[0]
+example['sjis1'] = <<'eofeof'.unpack('u')[0]
8YU#ID)%+"N-9E^T*Z>L)C^.7S)AJ"0D*
eofeof
-$example['euc1'] = <<'eofeof'.unpack('u')[0]
+example['euc1'] = <<'eofeof'.unpack('u')[0]
8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
eofeof
-$example['utf1'] = <<'eofeof'.unpack('u')[0]
+example['utf1'] = <<'eofeof'.unpack('u')[0]
AZ+J%Z:N/Z8JM"N>VNNFZEPKIM(D)Y+B*Z:"8Y+J8"0D*
eofeof
-$example['jis2'] = <<'eofeof'.unpack('u')[0]
+example['jis2'] = <<'eofeof'.unpack('u')[0]
+&R1".EA&(QLH0@H`
eofeof
-$example['sjis2'] = <<'eofeof'.unpack('u')[0]
+example['sjis2'] = <<'eofeof'.unpack('u')[0]
%C=:3H0H`
eofeof
-$example['euc2'] = <<'eofeof'.unpack('u')[0]
+example['euc2'] = <<'eofeof'.unpack('u')[0]
%NMC&HPH`
eofeof
-$example['utf2'] = <<'eofeof'.unpack('u')[0]
+example['utf2'] = <<'eofeof'.unpack('u')[0]
'YI:.Z)>D"@``
eofeof
# From JIS
-print "JIS to JIS ... ";test("-j",$example['jis'],[$example['jis']])
-print "JIS to SJIS... ";test("-s",$example['jis'],[$example['sjis']])
-print "JIS to EUC ... ";test("-e",$example['jis'],[$example['euc']])
-print "JIS to UTF8... ";test("-w",$example['jis'],[$example['utf8N']])
-print "JIS to U16L... ";test("-w16L",$example['jis'],[$example['u16L']])
-print "JIS to U16B... ";test("-w16B",$example['jis'],[$example['u16B']])
+print "JIS to JIS ... ";test('-j',example['jis'],[example['jis']]);
+print "JIS to SJIS... ";test('-s',example['jis'],[example['sjis']]);
+print "JIS to EUC ... ";test('-e',example['jis'],[example['euc']]);
+print "JIS to UTF8... ";test('-w',example['jis'],[example['utf']]);
# From SJIS
-print "SJIS to JIS ... ";test("-j",$example['sjis'],[$example['jis']])
-print "SJIS to SJIS... ";test("-s",$example['sjis'],[$example['sjis']])
-print "SJIS to EUC ... ";test("-e",$example['sjis'],[$example['euc']])
-print "SJIS to UTF8... ";test("-w",$example['sjis'],[$example['utf8N']])
-print "SJIS to U16L... ";test("-w16L",$example['sjis'],[$example['u16L']])
-print "SJIS to U16B... ";test("-w16B",$example['sjis'],[$example['u16B']])
+print "SJIS to JIS ... ";test('-j',example['sjis'],[example['jis']]);
+print "SJIS to SJIS... ";test('-s',example['sjis'],[example['sjis']]);
+print "SJIS to EUC ... ";test('-e',example['sjis'],[example['euc']]);
+print "SJIS to UTF8... ";test('-w',example['sjis'],[example['utf']]);
# From EUC
-print "EUC to JIS ... ";test("-j",$example['euc'],[$example['jis']])
-print "EUC to SJIS... ";test("-s",$example['euc'],[$example['sjis']])
-print "EUC to EUC ... ";test("-e",$example['euc'],[$example['euc']])
-print "EUC to UTF8... ";test("-w",$example['euc'],[$example['utf8N']])
-print "EUC to U16L... ";test("-w16L",$example['euc'],[$example['u16L']])
-print "EUC to U16B... ";test("-w16B",$example['euc'],[$example['u16B']])
+print "EUC to JIS ... ";test('-j',example['euc'],[example['jis']]);
+print "EUC to SJIS... ";test('-s',example['euc'],[example['sjis']]);
+print "EUC to EUC ... ";test('-e',example['euc'],[example['euc']]);
+print "EUC to UTF8... ";test('-w',example['euc'],[example['utf']]);
# From UTF8
-print "UTF8 to JIS ... ";test("-j", $example['utf8N'],[$example['jis']])
-print "UTF8 to SJIS... ";test("-s", $example['utf8N'],[$example['sjis']])
-print "UTF8 to EUC ... ";test("-e", $example['utf8N'],[$example['euc']])
-print "UTF8 to UTF8N.. ";test("-w", $example['utf8N'],[$example['utf8N']])
-print "UTF8 to UTF8... ";test("-w8", $example['utf8N'],[$example['utf8']])
-print "UTF8 to UTF8N.. ";test("-w80", $example['utf8N'],[$example['utf8N']])
-print "UTF8 to U16L... ";test("-w16L", $example['utf8N'],[$example['u16L']])
-print "UTF8 to U16L0.. ";test("-w16L0", $example['utf8N'],[$example['u16L0']])
-print "UTF8 to U16B... ";test("-w16B", $example['utf8N'],[$example['u16B']])
-print "UTF8 to U16B0.. ";test("-w16B0", $example['utf8N'],[$example['u16B0']])
+print "UTF8 to JIS ... ";test('-j',example['utf'],[example['jis']]);
+print "UTF8 to SJIS... ";test('-s',example['utf'],[example['sjis']]);
+print "UTF8 to EUC ... ";test('-e',example['utf'],[example['euc']]);
+print "UTF8 to UTF8... ";test('-w',example['utf'],[example['utf']]);
# From JIS
-print "JIS to JIS ... ";test("-j",$example['jis1'],[$example['jis1']])
-print "JIS to SJIS... ";test("-s",$example['jis1'],[$example['sjis1']])
-print "JIS to EUC ... ";test("-e",$example['jis1'],[$example['euc1']])
-print "JIS to UTF8... ";test("-w",$example['jis1'],[$example['utf1']])
+print "JIS to JIS ... ";test('-j',example['jis1'],[example['jis1']]);
+print "JIS to SJIS... ";test('-s',example['jis1'],[example['sjis1']]);
+print "JIS to EUC ... ";test('-e',example['jis1'],[example['euc1']]);
+print "JIS to UTF8... ";test('-w',example['jis1'],[example['utf1']]);
# From SJIS
-print "SJIS to JIS ... ";test("-j",$example['sjis1'],[$example['jis1']])
-print "SJIS to SJIS... ";test("-s",$example['sjis1'],[$example['sjis1']])
-print "SJIS to EUC ... ";test("-e",$example['sjis1'],[$example['euc1']])
-print "SJIS to UTF8... ";test("-w",$example['sjis1'],[$example['utf1']])
+print "SJIS to JIS ... ";test('-j',example['sjis1'],[example['jis1']]);
+print "SJIS to SJIS... ";test('-s',example['sjis1'],[example['sjis1']]);
+print "SJIS to EUC ... ";test('-e',example['sjis1'],[example['euc1']]);
+print "SJIS to UTF8... ";test('-w',example['sjis1'],[example['utf1']]);
# From EUC
-print "EUC to JIS ... ";test("-j",$example['euc1'],[$example['jis1']])
-print "EUC to SJIS... ";test("-s",$example['euc1'],[$example['sjis1']])
-print "EUC to EUC ... ";test("-e",$example['euc1'],[$example['euc1']])
-print "EUC to UTF8... ";test("-w",$example['euc1'],[$example['utf1']])
+print "EUC to JIS ... ";test('-j',example['euc1'],[example['jis1']]);
+print "EUC to SJIS... ";test('-s',example['euc1'],[example['sjis1']]);
+print "EUC to EUC ... ";test('-e',example['euc1'],[example['euc1']]);
+print "EUC to UTF8... ";test('-w',example['euc1'],[example['utf1']]);
# From UTF8
-print "UTF8 to JIS ... ";test("-j",$example['utf1'],[$example['jis1']])
-print "UTF8 to SJIS... ";test("-s",$example['utf1'],[$example['sjis1']])
-print "UTF8 to EUC ... ";test("-e",$example['utf1'],[$example['euc1']])
-print "UTF8 to UTF8... ";test("-w",$example['utf1'],[$example['utf1']])
+print "UTF8 to JIS ... ";test('-j',example['utf1'],[example['jis1']]);
+print "UTF8 to SJIS... ";test('-s',example['utf1'],[example['sjis1']]);
+print "UTF8 to EUC ... ";test('-e',example['utf1'],[example['euc1']]);
+print "UTF8 to UTF8... ";test('-w',example['utf1'],[example['utf1']]);
# Ambigous Case
-$example['amb'] = <<'eofeof'.unpack('u')[0]
+example['amb'] = <<'eofeof'.unpack('u')[0]
MI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&E
MPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*P
ML:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&E
@@ -274,7 +220,7 @@ MI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"
ML+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*
eofeof
-$example['amb.euc'] = <<'eofeof'.unpack('u')[0]
+example['amb.euc'] = <<'eofeof'.unpack('u')[0]
M&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25"
M,#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P,25"
M,#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;
@@ -285,7 +231,7 @@ M)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
>)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*
eofeof
-$example['amb.sjis'] = <<'eofeof'.unpack('u')[0]
+example['amb.sjis'] = <<'eofeof'.unpack('u')[0]
M&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25"
M,#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P,25"
M,#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;
@@ -297,78 +243,22 @@ M)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
eofeof
print "Ambiguous Case. ";
- test("-j",$example['amb'],[$example['amb.euc']])
+ test('-j',example['amb'],[example['amb.euc']]);
# Input assumption
print "SJIS Input assumption ";
- test("-jSx",$example['amb'],[$example['amb.sjis']])
+ test('-jSx',example['amb'],[example['amb.sjis']]);
# Broken JIS
print "Broken JIS ";
- $input = $example['jis'];
- $input.gsub!("\033",'')
- test("-Be",$input,[$example['euc']]);
+ $input = example['jis'];
+ $input.gsub("\033",'');
+ test('-Be',$input,[example['euc']]);
print "Broken JIS is safe on Normal JIS? ";
- $input = $example['jis'];
- test("-Be",$input,[$example['euc']]);
-
-# test_data/cp932
-
-$example['test_data/cp932'] = <<'eofeof'.unpack('u')[0]
-%^D`@_$L`
-eofeof
-
-$example['test_data/cp932.ans'] = <<'eofeof'.unpack('u')[0]
-%_/$@_.X`
-eofeof
-
-print "test_data/cp932 ";
- test("-eS",$example['test_data/cp932'],[$example['test_data/cp932.ans']])
-
-# test_data/cp932inv
-print "test_data/cp932inv ";
- test("-sE --cp932inv",$example['test_data/cp932.ans'],[$example['test_data/cp932']])
-
-# test_data/no-cp932inv
-
-$example['test_data/no-cp932inv.ans'] = <<'eofeof'.unpack('u')[0]
-%[N\@[NP`
-eofeof
-
-print "test_data/no-cp932inv ";
-test("-sE --no-cp932",$example['test_data/cp932.ans'],[$example['test_data/no-cp932inv.ans']])
-
-# test_data/irv
-
-# $example['test_data/irv'] = <<'eofeof'.unpack('u')[0]
-# %#B`/(!L`
-# eofeof
-#
-# $example['test_data/irv.ans'] = <<'eofeof'.unpack('u')[0]
-# %#B`/(!L`
-# eofeof
-#
-# print "test_data/irv ";
-# test("-wE",$example['test_data/irv'],[$example['test_data/irv.ans']])
-
-
-# UCS Mapping Test
-print "\n\nUCS Mapping Test\n";
-
-print "Shift_JIS to UTF-16\n";
-$example['ms_ucs_map_1_sjis'] = "\x81\x60\x81\x61\x81\x7C\x81\x91\x81\x92\x81\xCA";
-$example['ms_ucs_map_1_utf16'] = "\x30\x1C\x20\x16\x22\x12\x00\xA2\x00\xA3\x00\xAC";
-$example['ms_ucs_map_1_utf16_ms'] = "\xFF\x5E\x22\x25\xFF\x0D\xFF\xE0\xFF\xE1\xFF\xE2";
-
-print "Normal UCS Mapping : ";
- test("-w16B0 -S",$example['ms_ucs_map_1_sjis'],[$example['ms_ucs_map_1_utf16']])
-
-print "Microsoft UCS Mapping : ";
- test("-w16B0 -S --ms-ucs-map",$example['ms_ucs_map_1_sjis'],[$example['ms_ucs_map_1_utf16_ms']])
-
-print"\n";
+ $input = example['jis'];
+ test('-Be',$input,[example['euc']]);
# X0201 ²¾Ì¾
# X0201->X0208 conversion
@@ -377,7 +267,7 @@ print"\n";
print "\nX0201 test\n\n";
-$example['x0201.sjis'] = <<'eofeof'.unpack('u')[0]
+example['x0201.sjis'] = <<'eofeof'.unpack('u')[0]
MD5.*<(-*@TR#3H-0@U*#2X--@T^#48-3"I%3B7""8()A@F*"8X)D@F6"9H*!
M@H*"@X*$@H6"AH*'"I%3BTR-AH%)@9>!E(&0@9.!3X&5@9:!:8%J@7R!>X&!
M@6V!;H%O@7"!CPJ4O(IPMK>X/;FZMMZWWKC>N=ZZWH+&"I2\BG#*W\O?S-_-
@@ -385,7 +275,7 @@ MW\[?M]^QW@K*W\O?S`IH86YK86MU(,K?R]_,I`K*W\O?S-VA"I2\BG""S(SC
!"@!"
eofeof
-$example['x0201.euc'] = <<'eofeof'.unpack('u')[0]
+example['x0201.euc'] = <<'eofeof'.unpack('u')[0]
MP;2ST:6KI:VEKZ6QI;.EK*6NI;"ELJ6T"L&TL=&CP:/"H\.CQ*/%H\:CQZ/A
MH^*CXZ/DH^6CYJ/G"L&TM:VYYJ&JH?>A]*'PH?.AL*'UH?:ARJ'+H=VAW*'A
MH<ZASZ'0H=&A[PK(OK/1CK:.MXZX/8ZYCKJ.MH[>CK>.WHZXCMZ.N8[>CKJ.
@@ -394,7 +284,7 @@ MCLP*:&%N:V%K=2".RH[?CLN.WX[,CJ0*CLJ.WX[+CM^.S([=CJ$*R+ZST:3.
#N.4*
eofeof
-$example['x0201.utf'] = <<'eofeof'.unpack('u')[0]
+example['x0201.utf'] = <<'eofeof'.unpack('u')[0]
MY86HZ*>2XX*KXX*MXX*OXX*QXX*SXX*LXX*NXX*PXX*RXX*T"N6%J.B+L>^\
MH>^\HN^\H^^\I.^\I>^\IN^\I^^]@>^]@N^]@^^]A.^]A>^]AN^]APKEA:CH
MJ)CEC[?OO('OO*#OO(/OO(3OO(7OO+[OO(;OO(KOO(COO(GBB)+OO(OOO)WO
@@ -405,7 +295,7 @@ M"FAA;FMA:W4@[[Z*[[Z?[[Z+[[Z?[[Z,[[VD"N^^BN^^G^^^B^^^G^^^C.^^
2G>^]H0KEC8KHIY+C@:[EOHP*
eofeof
-$example['x0201.jis'] = <<'eofeof'.unpack('u')[0]
+example['x0201.jis'] = <<'eofeof'.unpack('u')[0]
M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$C02-"(T,C
M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA""ALD0D$T-2TY9B$J(7<A="%P(7,A
M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH0@H;)$)(/C-1&RA)-C<X&RA"
@@ -414,7 +304,7 @@ M-U\Q7ALH0@H;*$E*7TM?3!LH0@IH86YK86MU(!LH24I?2U],)!LH0@H;*$E*
97TM?3%TA&RA""ALD0D@^,U$D3CAE&RA""@``
eofeof
-$example['x0201.sosi'] = <<'eofeof'.unpack('u')[0]
+example['x0201.sosi'] = <<'eofeof'.unpack('u')[0]
M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA*"ALD0D$T,5$C02-"(T,C
M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA*"ALD0D$T-2TY9B$J(7<A="%P(7,A
M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH2@H;)$)(/C-1&RA*#C8W.`\;
@@ -423,7 +313,7 @@ M3E\W7S%>#PH.2E]+7TP/&RA*"FAA;FMA:W4@#DI?2U],)`\;*$H*#DI?2U],
672$/&RA*"ALD0D@^,U$D3CAE&RA""@``
eofeof
-$example['x0201.x0208'] = <<'eofeof'.unpack('u')[0]
+example['x0201.x0208'] = <<'eofeof'.unpack('u')[0]
M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$;*$)!0D-$
M149'86)C9&5F9PH;)$)!-#4M.68;*$(A0",D)5XF*B@I+2L]6UU[?1LD0B%O
M&RA""ALD0D@^,U$E*R4M)2\;*$(]&R1")3$E,R4L)2XE,"4R)30D2!LH0@H;
@@ -435,24 +325,24 @@ eofeof
# -X is necessary to allow X0201 in SJIS
# -Z convert X0208 alphabet to ASCII
print "X0201 conversion: SJIS ";
- test("-jXZ",$example['x0201.sjis'],[$example['x0201.x0208']])
+ test('-jXZ',example['x0201.sjis'],[example['x0201.x0208']]);
print "X0201 conversion: JIS ";
- test("-jZ",$example['x0201.jis'],[$example['x0201.x0208']])
+ test('-jZ',example['x0201.jis'],[example['x0201.x0208']]);
print "X0201 conversion:SI/SO ";
- test("-jZ",$example['x0201.sosi'],[$example['x0201.x0208']])
+ test('-jZ',example['x0201.sosi'],[example['x0201.x0208']]);
print "X0201 conversion: EUC ";
- test("-jZ",$example['x0201.euc'],[$example['x0201.x0208']])
+ test('-jZ',example['x0201.euc'],[example['x0201.x0208']]);
print "X0201 conversion: UTF8 ";
- test("-jZ",$example['x0201.utf'],[$example['x0201.x0208']])
+ test('-jZ',example['x0201.utf'],[example['x0201.x0208']]);
# -x means X0201 output
print "X0201 output: SJIS ";
- test("-xs",$example['x0201.euc'],[$example['x0201.sjis']])
+ test('-xs',example['x0201.euc'],[example['x0201.sjis']]);
print "X0201 output: JIS ";
- test("-xj",$example['x0201.sjis'],[$example['x0201.jis']])
+ test('-xj',example['x0201.sjis'],[example['x0201.jis']]);
print "X0201 output: EUC ";
- test("-xe",$example['x0201.jis'],[$example['x0201.euc']])
+ test('-xe',example['x0201.jis'],[example['x0201.euc']]);
print "X0201 output: UTF8 ";
- test("-xw",$example['x0201.jis'],[$example['x0201.utf']])
+ test('-xw',example['x0201.jis'],[example['x0201.utf']]);
# MIME decode
@@ -460,7 +350,7 @@ print "\nMIME test\n\n";
# MIME ISO-2022-JP
-$example['mime.iso2022'] = <<'eofeof'.unpack('u')[0]
+example['mime.iso2022'] = <<'eofeof'.unpack('u')[0]
M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23TI566Q/4U9)1WEH2S\]"CT_
M:7-O+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3U-624=Y:$L_/0H]/VES
M;RTR,#(R+4I0/U$_/3%")$(D1B11/3%"*$)?96YD/ST*&R1`)#TD)B0K)$H;
@@ -473,7 +363,7 @@ M96E23U!Y:S=D:'-O4V<]/3\]"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I
44D]*55EL3QM;2U-624=Y:$L_/0H_
eofeof
-$example['mime.ans.strict'] = <<'eofeof'.unpack('u')[0]
+example['mime.ans.strict'] = <<'eofeof'.unpack('u')[0]
M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
@@ -482,7 +372,7 @@ M/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]"CT_
L25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3QM;2U-624=Y:$L_/0H_
eofeof
-$example['mime.unbuf.strict'] = <<'eofeof'.unpack('u')[0]
+example['mime.unbuf.strict'] = <<'eofeof'.unpack('u')[0]
M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
@@ -491,7 +381,7 @@ M3D5%-V5I4D]0>6LW9&AS;U-G/3T_/0H;)$(T03MZ)$XE1ALH0EM+4U9)1WEH
$2S\]"F5I
eofeof
-$example['mime.ans'] = <<'eofeof'.unpack('u')[0]
+example['mime.ans'] = <<'eofeof'.unpack('u')[0]
M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
@@ -499,7 +389,7 @@ M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
eofeof
-$example['mime.unbuf'] = <<'eofeof'.unpack('u')[0]
+example['mime.unbuf'] = <<'eofeof'.unpack('u')[0]
M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
@@ -507,13 +397,13 @@ M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
eofeof
-$example['mime.base64'] = <<'eofeof'.unpack('u')[0]
+example['mime.base64'] = <<'eofeof'.unpack('u')[0]
M9W-M5"])3&YG<FU#>$I+-&=Q=4,S24LS9W%Q0E%:3TUI-39,,S0Q-&=S5T)1
M43!+9VUA1%9O3T@*9S)+1%1O3'=K8C)1;$E+;V=Q2T-X24MG9W5M0W%*3EEG
<<T=#>$E+9V=U;4,X64Q&9W)70S592VMG<6U""F=Q
eofeof
-$example['mime.base64.ans'] = <<'eofeof'.unpack('u')[0]
+example['mime.base64.ans'] = <<'eofeof'.unpack('u')[0]
M&R1")$M&?B1I)#LD1D0Z)"TD7B0Y)"PA(D5L-7XV83E9)$<A(ALH0@T*&R1"
M(T<E-R5G)4,E+R1R0C\_="0J)"0D1B0B)&LD*D4Y)$,D1B0B)&LD<R1')#<D
(9R0F)"L;*$(E
@@ -521,16 +411,16 @@ eofeof
# print "Next test is expected to Fail.\n";
print "MIME decode (strict) ";
- $tmp = test("-j -mS",$example['mime.iso2022'],[$example['mime.ans.strict']])
+ $tmp = test('-jmS',example['mime.iso2022'],[example['mime.ans.strict']]);
-$example['mime.ans.alt'] = <<'eofeof'.unpack('u')[0]
+example['mime.ans.alt'] = <<'eofeof'.unpack('u')[0]
M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
eofeof
-$example['mime.unbuf.alt'] = <<'eofeof'.unpack('u')[0]
+example['mime.unbuf.alt'] = <<'eofeof'.unpack('u')[0]
M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
@@ -538,25 +428,25 @@ H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
eofeof
print "MIME decode (nonstrict)";
- $tmp = test("-j -mN",$example['mime.iso2022'],[$example['mime.ans'],$example['mime.ans.alt']])
+ $tmp = test('-jmN',example['mime.iso2022'],[example['mime.ans'],example['mime.ans.alt']]);
# open(OUT,">tmp1");print OUT pack('u',$tmp);close(OUT);
# unbuf mode implies more pessimistic decode
print "MIME decode (unbuf) ";
- $tmp = test("-j -mNu",$example['mime.iso2022'],[$example['mime.unbuf'],$example['mime.unbuf.alt']])
+ $tmp = test('-jmNu',example['mime.iso2022'],[example['mime.unbuf'],example['mime.unbuf.alt']]);
# open(OUT,">tmp2");print OUT pack('u',$tmp);close(OUT);
print "MIME decode (base64) ";
- test("-j -mB",$example['mime.base64'],[$example['mime.base64.ans']])
+ test('-jTmB',example['mime.base64'],[example['mime.base64.ans']]);
# MIME ISO-8859-1
-$example['mime.is8859'] = <<'eofeof'.unpack('u')[0]
+example['mime.is8859'] = <<'eofeof'.unpack('u')[0]
M/3])4T\M.#@U.2TQ/U$_*CU#-V%V83\_/2`*4&5E<B!4]G)N9W)E;@I,87-S
M92!(:6QL97+X92!0971E<G-E;B`@7"`B36EN(&MA97!H97-T(&AA<B!F86%E
M="!E="!F;V5L(2(*06%R:'5S(%5N:79E<G-I='DL($1%3DU!4DL@(%P@(DUI
<;B!KYG!H97-T(&AA<B!FY65T(&5T(&;X;"$B"@!K
eofeof
-$example['mime.is8859.ans'] = <<'eofeof'.unpack('u')[0]
+example['mime.is8859.ans'] = <<'eofeof'.unpack('u')[0]
M*L=A=F$_(`I0965R(%3V<FYG<F5N"DQA<W-E($AI;&QE<OAE(%!E=&5R<V5N
M("!<(")-:6X@:V%E<&AE<W0@:&%R(&9A865T(&5T(&9O96PA(@I!87)H=7,@
M56YI=F5R<VET>2P@1$5.34%22R`@7"`B36EN(&OF<&AE<W0@:&%R(&;E970@
@@ -566,7 +456,7 @@ eofeof
# Without -l, ISO-8859-1 was handled as X0201.
print "MIME ISO-8859-1 (Q) ";
- test("-ml",$example['mime.is8859'],[$example['mime.is8859.ans']])
+ test('-ml',example['mime.is8859'],[example['mime.is8859.ans']]);
# test for -f is not so simple.
@@ -574,32 +464,32 @@ print "\nBug Fixes\n\n";
# test_data/cr
-$example['test_data/cr'] = <<'eofeof'.unpack('u')[0]
+example['test_data/cr'] = <<'eofeof'.unpack('u')[0]
1I,:DN:3(#71E<W0-=&5S=`T`
eofeof
-$example['test_data/cr.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/cr.ans'] = <<'eofeof'.unpack('u')[0]
7&R1")$8D.21(&RA""G1E<W0*=&5S=`H`
eofeof
print "test_data/cr ";
- test("-jd",$example['test_data/cr'],[$example['test_data/cr.ans']])
+ test('-jd',example['test_data/cr'],[example['test_data/cr.ans']]);
# test_data/fixed-qencode
-$example['test_data/fixed-qencode'] = <<'eofeof'.unpack('u')[0]
+example['test_data/fixed-qencode'] = <<'eofeof'.unpack('u')[0]
M("`@("`@("`],4(D0CYE/STS1#TQ0BA""B`@("`@("`@/3%")$(^93TS1CTS
'1#TQ0BA""@``
eofeof
-$example['test_data/fixed-qencode.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/fixed-qencode.ans'] = <<'eofeof'.unpack('u')[0]
F("`@("`@("`;)$(^93\]&RA""B`@("`@("`@&R1"/F4_/1LH0@H`
eofeof
print "test_data/fixed-qencode ";
- test("-jmQ",$example['test_data/fixed-qencode'],[$example['test_data/fixed-qencode.ans']])
+ test('-jmQ',example['test_data/fixed-qencode'],[example['test_data/fixed-qencode.ans']]);
# test_data/long-fold-1
-$example['test_data/long-fold-1'] = <<'eofeof'.unpack('u')[0]
+example['test_data/long-fold-1'] = <<'eofeof'.unpack('u')[0]
MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DSR!#
@@ -607,7 +497,7 @@ M4B],1B"DSKG4H:,-"J2SI+.DSR!#4B"DSKG4H:,-I+.DLZ3/($Q&+T-2(*3.
9N=2AHPH-"J2SI+.DSR!,1B"DSKG4H:,*"@``
eofeof
-$example['test_data/long-fold-1.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/long-fold-1.ans'] = <<'eofeof'.unpack('u')[0]
M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
@@ -618,17 +508,17 @@ M4B`;)$(D3CE4(2,;*$(*"ALD0B0S)#,D3QLH0B!,1B`;)$(D3CE4(2,;*$(*
eofeof
print "test_data/long-fold-1 ";
- test("-jF60",$example['test_data/long-fold-1'],[$example['test_data/long-fold-1.ans']])
+ test('-jTF60',example['test_data/long-fold-1'],[example['test_data/long-fold-1.ans']]);
# test_data/long-fold
-$example['test_data/long-fold'] = <<'eofeof'.unpack('u')[0]
+example['test_data/long-fold'] = <<'eofeof'.unpack('u')[0]
MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DS\.[
'I*2YU*&C"@``
eofeof
-$example['test_data/long-fold.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/long-fold.ans'] = <<'eofeof'.unpack('u')[0]
M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
@@ -636,10 +526,10 @@ M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
eofeof
print "test_data/long-fold ";
- test("-jf60",$example['test_data/long-fold'],[$example['test_data/long-fold.ans']])
+ test('-jTf60',example['test_data/long-fold'],[example['test_data/long-fold.ans']]);
# test_data/mime_out
-$example['test_data/mime_out'] = <<'eofeof'.unpack('u')[0]
+example['test_data/mime_out'] = <<'eofeof'.unpack('u')[0]
M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A86%A"BTM+2T*
M4W5B:F5C=#H@I**DI*2FI*BDJJ2KI*VDKZ2QI+.DM:2WI+FDNZ2]I+^DP:3$
@@ -648,78 +538,31 @@ M+2TM+0I3=6)J96-T.B!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A
I86%A(*2BI*2DIJ2HI*H@86%A82!A86%A(&%A86$@86%A80HM+2TM"@H`
eofeof
-$example['test_data/mime_out.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/mime_out.ans'] = <<'eofeof'.unpack('u')[0]
M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
-M86%A82!A86%A(&%A86$@86%A80H@86%A82!A86%A(&%A86$@86%A82!A86%A
-M"BTM+2T*4W5B:F5C=#H@/3])4T\M,C`R,BU*4#]"/T=Y4D-*0TEK2D-1;4I#
-M9VM+:5%R2D,P:TQY47A*1$UK3E-1,T=Y:$,_/0H@/3])4T\M,C`R,BU*4#]"
-M/T=Y4D-*1&MK3WE1.4I$.&M14U)%2D59:U-#4DM*17-K5$-23DI%-&M4>5)3
-M2D95:U=#4F)'>6A#/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D8T:UAY4F=*
-M1T5K66E2:TI#46M::5%O2D=G8DM%23T_/0HM+2TM"E-U8FIE8W0Z(&%A86$@
-M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$*(#T_25-/+3(P,C(M2E`_
-M0C]'>5)#2D-):TI#46U*0V=K2VAS;U%G/3T_/2!A86%A(&%A86$@86%A82!A
-086%A"B!A86%A"BTM+2T*"@``
+M86%A82!A86%A(&%A86$*(&%A86$@86%A82!A86%A(&%A86$@86%A80HM+2TM
+M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
+M<DI#,&M,>5%X2D1-:TY343-*1&MK3WAS;U%G/3T_/2`*"3T_25-/+3(P,C(M
+M2E`_0C]'>5)#2D0P:U!Y4D)*15%K4FE224I%;VM3>5)-2D4P:U1I4E!*1DEK
+M5E-264=Y:$,_/2`*"3T_25-/+3(P,C(M2E`_0C]'>5)#2D9S:UAI4F9*1T%K
+M65-2:4I'46M*0U)M2D-G:V%"<V]19ST]/ST@"BTM+2T*4W5B:F5C=#H@86%A
+M82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82`]/TE33RTR,#(R+4I0
+M/T(_1WE20TI#26)+14D]/ST@"@D]/TE33RTR,#(R+4I0/T(_1WE20TI#46M*
+J:5%O2D-O8DM%23T_/2`@86%A80H@86%A82!A86%A(&%A86$*+2TM+0H*
eofeof
print "test_data/mime_out ";
- test("-jM",$example['test_data/mime_out'],[$example['test_data/mime_out.ans']])
-# test_data/mime_out2
-
-$example['test_data/mime_out2'] = <<'eofeof'.unpack('u')[0]
-M5&AI<R!M96UO(&1E<V-R:6)E<R!S:6UI;&%R('1E8VAN:7%U97,@=&\@86QL
-M;W<@=&AE(&5N8V]D:6YG(&]F(&YO;BU!4T-)22!T97AT(&EN('9A<FEO=7,@
-M<&]R=&EO;G,@;V8@82!21D,@.#(R(%LR72!M97-S86=E(&AE861E<BP@:6X@
-M82!M86YN97(@=VAI8V@@:7,@=6YL:6ME;'D@=&\@8V]N9G5S92!E>&ES=&EN
-M9R!M97-S86=E(&AA;F1L:6YG('-O9G1W87)E+@H*4W5B:F5C=#H@=&5S=#$@
-M=&5S=#(@@L2"MX+&@J<@=&5S=#,@@L2"MX+&@O$@=&5S=#0*"E-U8FIE8W0Z
-M('1E<W0Q("!T97-T,B""Q"""MR""QB""IR!T97-T,R`@@L2"MX+&@O$@('1E
-M<W0T"@I!4T-)22"3^I9[C.H@05-#24D@05-#24D@D_J6>XSJ()/ZEGN,ZB!!
-M4T-)22!!4T-)29/ZEGN,ZB!!4T-)20H*@J`@@J(@@J0@@J8@@J@@@JD@@JL@
-M@JT@@J\@@K$@@K,@@K4@@K<@@KD@@KL@@KT@@K\@@L(@@L0@@L8@@L@@@LD@
-8@LH@@LL@@LP*"@H*"@H*"@H*"@H*"@H*
-eofeof
-
-$example['test_data/mime_out2.ans'] = <<'eofeof'.unpack('u')[0]
-M5&AI<R!M96UO(&1E<V-R:6)E<R!S:6UI;&%R('1E8VAN:7%U97,@=&\@86QL
-M;W<@=&AE(&5N8V]D:6YG(&5N8V]D:6YG"B!O9B!N;VXM05-#24D@=&5X="!I
-M;B!V87)I;W5S('!O<G1I;VYS(&]F(&$@80H@4D9#(#@R,B!;,ET@;65S<V%G
-M92!H96%D97(L(&EN(&$@;6%N;F5R('=H:6-H(&ES('5N;&EK96QY('5N;&EK
-M96QY"B!T;R!C;VYF=7-E(&5X:7-T:6YG(&UE<W-A9V4@:&%N9&QI;F<@<V]F
-M='=A<F4N"@I3=6)J96-T.B!T97-T,2!T97-T,B`]/TE33RTR,#(R+4I0/T(_
-M1WE20TI%66M/4U))2D-K8DM%23T_/2!T97-T,PH@/3])4T\M,C`R,BU*4#]"
-M/T=Y4D-*15EK3U-224I(36)+14D]/ST@=&5S=#0*"E-U8FIE8W0Z('1E<W0Q
-M("!T97-T,B`]/TE33RTR,#(R+4I0/T(_1WE20TI%66)+14EG1WE20TI$:V)+
-M14EG1WE20TI%9V)+14D]/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#1WEH0TE"
-M<VM1:5%P1WEH0S\]('1E<W0S(`H@/3])4T\M,C`R,BU*4#]"/T=Y4D-*15EK
-M3U-224I(36)+14D]/ST@('1E<W0T"@I!4T-)22`]/TE33RTR,#(R+4I0/T(_
-M1WE20U)N>$Q81&AS1WEH0S\]($%30TE)($%30TE)"B`]/TE33RTR,#(R+4I0
-M/T(_1WE20U)N>$Q81&AS1WEH0TE"<VM1:UHX4S%W-&)"<V]19ST]/ST@05-#
-M24D*(#T_25-/+3(P,C(M2E`_0C]15DY$4U5K8DI%2D=F171C3T=W8DM%23T_
-M/2!!4T-)20H*/3])4T\M,C`R,BU*4#]"/T=Y4D-*0TEB2T5)9T=Y4D-*0U%B
-M2T5)9T=Y4D-*0UEB2T5)9T=Y4D-*0V=B2T5)/3\]"B`]/TE33RTR,#(R+4I0
-M/T(_24)S:U%I47%'>6A#24)S:U%I47)'>6A#24)S:U%I471'>6A#24)S:U%I
-M479'>6A#/ST*(#T_25-/+3(P,C(M2E`_0C])0G-K46E1>$=Y:$-)0G-K46E1
-M>D=Y:$-)0G-K46E1,4=Y:$-)0G-K46E1,T=Y:$,_/0H@/3])4T\M,C`R,BU*
-M4#]"/TE"<VM1:5$U1WEH0TE"<VM1:5$W1WEH0TE"<VM1:5$Y1WEH0TE"<VM1
-M:5$O1WEH0S\]"B`]/TE33RTR,#(R+4I0/T(_24)S:U%I4D)'>6A#24)S:U%I
-M4D5'>6A#24)S:U%I4D='>6A#24)S:U%I4DE'>6A#/ST*(#T_25-/+3(P,C(M
-M2E`_0C])0G-K46E22T=Y:$-)0G-K46E23$=Y:$-)0G-K46E234=Y:$-)0G-K
-M46E23D=Y:$,_/0H@/3])4T\M,C`R,BU*4#]"/TE"<VM1:5)/1WEH0S\]"@H*
--"@H*"@H*"@H*"@H*"@``
-eofeof
-
-print "test_data/mime_out2 ";
- test("-jM",$example['test_data/mime_out2'],[$example['test_data/mime_out2.ans']])
+ test('-jM',example['test_data/mime_out'],[example['test_data/mime_out.ans']]);
# test_data/multi-line
-$example['test_data/multi-line'] = <<'eofeof'.unpack('u')[0]
+example['test_data/multi-line'] = <<'eofeof'.unpack('u')[0]
MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
eofeof
-$example['test_data/multi-line.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/multi-line.ans'] = <<'eofeof'.unpack('u')[0]
MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
@@ -727,73 +570,73 @@ MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
eofeof
print "test_data/multi-line ";
- test("-e",$example['test_data/multi-line'],[$example['test_data/multi-line.ans']])
+ test('-e',example['test_data/multi-line'],[example['test_data/multi-line.ans']]);
# test_data/nkf-19-bug-1
-$example['test_data/nkf-19-bug-1'] = <<'eofeof'.unpack('u')[0]
+example['test_data/nkf-19-bug-1'] = <<'eofeof'.unpack('u')[0]
,I*:DJZ2D"KK8QJ,*
eofeof
-$example['test_data/nkf-19-bug-1.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/nkf-19-bug-1.ans'] = <<'eofeof'.unpack('u')[0]
8&R1")"8D*R0D&RA""ALD0CI81B,;*$(*
eofeof
print "test_data/nkf-19-bug-1 ";
- test("-Ej",$example['test_data/nkf-19-bug-1'],[$example['test_data/nkf-19-bug-1.ans']])
+ test('-Ej',example['test_data/nkf-19-bug-1'],[example['test_data/nkf-19-bug-1.ans']]);
# test_data/nkf-19-bug-2
-$example['test_data/nkf-19-bug-2'] = <<'eofeof'.unpack('u')[0]
+example['test_data/nkf-19-bug-2'] = <<'eofeof'.unpack('u')[0]
%I-NDL@H`
eofeof
-$example['test_data/nkf-19-bug-2.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/nkf-19-bug-2.ans'] = <<'eofeof'.unpack('u')[0]
%I-NDL@H`
eofeof
print "test_data/nkf-19-bug-2 ";
- test("-Ee",$example['test_data/nkf-19-bug-2'],[$example['test_data/nkf-19-bug-2.ans']])
+ test('-Ee',example['test_data/nkf-19-bug-2'],[example['test_data/nkf-19-bug-2.ans']]);
# test_data/nkf-19-bug-3
-$example['test_data/nkf-19-bug-3'] = <<'eofeof'.unpack('u')[0]
+example['test_data/nkf-19-bug-3'] = <<'eofeof'.unpack('u')[0]
8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
eofeof
-$example['test_data/nkf-19-bug-3.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/nkf-19-bug-3.ans'] = <<'eofeof'.unpack('u')[0]
8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
eofeof
print "test_data/nkf-19-bug-3 ";
- test("-e",$example['test_data/nkf-19-bug-3'],[$example['test_data/nkf-19-bug-3.ans']])
+ test('-e',example['test_data/nkf-19-bug-3'],[example['test_data/nkf-19-bug-3.ans']]);
# test_data/non-strict-mime
-$example['test_data/non-strict-mime'] = <<'eofeof'.unpack('u')[0]
+example['test_data/non-strict-mime'] = <<'eofeof'.unpack('u')[0]
M/3])4T\M,C`R,BU*4#]"/PIG<U-#;V]+.6=R-D-O;TQ%9W1Y0W0T1D-$46].
M0V\V16=S,D]N;T999S1Y1%=)3$IG=4-0:UD*2W!G<FU#>$E+:6=R,D-V;TMI
,9W-30V]O3&,*/ST*
eofeof
-$example['test_data/non-strict-mime.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/non-strict-mime.ans'] = <<'eofeof'.unpack('u')[0]
M&R1")$8D)"0_)$`D)"1&)%XD.2$C&RA"#0H-"ALD0CMD)$\[?B$Y)6PE.21+
<)&(]<20K)#LD1B0D)#\D0"0D)$8D)"1>&RA""@``
eofeof
print "test_data/non-strict-mime ";
- test("-jmN",$example['test_data/non-strict-mime'],[$example['test_data/non-strict-mime.ans']])
+ test('-jTmN',example['test_data/non-strict-mime'],[example['test_data/non-strict-mime.ans']]);
# test_data/q-encode-softrap
-$example['test_data/q-encode-softrap'] = <<'eofeof'.unpack('u')[0]
+example['test_data/q-encode-softrap'] = <<'eofeof'.unpack('u')[0]
H/3%")$(T03MZ)3T*,R$\)4DD3CTQ0BA""CTQ0B1"2E$T.3TQ0BA""@``
eofeof
-$example['test_data/q-encode-softrap.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/q-encode-softrap.ans'] = <<'eofeof'.unpack('u')[0]
>&R1"-$$[>B4S(3PE221.&RA""ALD0DI1-#D;*$(*
eofeof
print "test_data/q-encode-softrap ";
- test("-jmQ",$example['test_data/q-encode-softrap'],[$example['test_data/q-encode-softrap.ans']])
+ test('-jTmQ',example['test_data/q-encode-softrap'],[example['test_data/q-encode-softrap.ans']]);
# test_data/rot13
-$example['test_data/rot13'] = <<'eofeof'.unpack('u')[0]
+example['test_data/rot13'] = <<'eofeof'.unpack('u')[0]
MI+.D\Z3+I,&DSZ&BS:W"]*3(I*2DI*3>I+FAHPH*;FMF('9E<BXQ+CDR(*3R
MS?C-T:2UI+NDQJ2DI+^DP*2DI,:DI*3>I+FDK*&B05-#24D@I,O"T*2WI,8@
M4D]4,3,@I*P*P+6DMZ2OQK"DI*3&I*2DRJ2DI.BDIJ3'H:*PRK*\I,ZDZ*2F
@@ -801,7 +644,7 @@ MI,O*T;2YI+6D[*3>I+ND\Z&C"@HE(&5C:&\@)VAO9V4G('P@;FMF("UR"FAO
#9V4*
eofeof
-$example['test_data/rot13.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/rot13.ans'] = <<'eofeof'.unpack('u')[0]
M&R1"4V)31%-Z4W!3?E!1?%QQ15-W4U-34U,O4VA04ALH0@H*87AS(&ER92XQ
M+CDR(!LD0E-#?$E\(E-D4VI3=5-34VY3;U-34W534U,O4VA36U!1&RA"3D90
M5E8@&R1"4WIQ(5-F4W4;*$(@14)',3,@&R1"4UL;*$(*&R1";V139E->=5]3
@@ -810,55 +653,54 @@ A&RA""@HE(')P=6(@)W5B='(G('P@87AS("UE"G5B='(*
eofeof
print "test_data/rot13 ";
- test("-jr",$example['test_data/rot13'],[$example['test_data/rot13.ans']])
+ test('-jr',example['test_data/rot13'],[example['test_data/rot13.ans']]);
# test_data/slash
-$example['test_data/slash'] = <<'eofeof'.unpack('u')[0]
+example['test_data/slash'] = <<'eofeof'.unpack('u')[0]
7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
eofeof
-$example['test_data/slash.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/slash.ans'] = <<'eofeof'.unpack('u')[0]
7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
eofeof
print "test_data/slash ";
- test(" ",$example['test_data/slash'],[$example['test_data/slash.ans']])
+ test(' ',example['test_data/slash'],[example['test_data/slash.ans']]);
# test_data/z1space-0
-$example['test_data/z1space-0'] = <<'eofeof'.unpack('u')[0]
+example['test_data/z1space-0'] = <<'eofeof'.unpack('u')[0]
"H:$`
eofeof
-$example['test_data/z1space-0.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/z1space-0.ans'] = <<'eofeof'.unpack('u')[0]
"H:$`
eofeof
print "test_data/z1space-0 ";
- test("-e -Z",$example['test_data/z1space-0'],[$example['test_data/z1space-0.ans']])
+ test('-e -Z',example['test_data/z1space-0'],[example['test_data/z1space-0.ans']]);
# test_data/z1space-1
-$example['test_data/z1space-1'] = <<'eofeof'.unpack('u')[0]
+example['test_data/z1space-1'] = <<'eofeof'.unpack('u')[0]
"H:$`
eofeof
-$example['test_data/z1space-1.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/z1space-1.ans'] = <<'eofeof'.unpack('u')[0]
!(```
eofeof
print "test_data/z1space-1 ";
- test("-e -Z1",$example['test_data/z1space-1'],[$example['test_data/z1space-1.ans']])
+ test('-e -Z1',example['test_data/z1space-1'],[example['test_data/z1space-1.ans']]);
# test_data/z1space-2
-$example['test_data/z1space-2'] = <<'eofeof'.unpack('u')[0]
+example['test_data/z1space-2'] = <<'eofeof'.unpack('u')[0]
"H:$`
eofeof
-$example['test_data/z1space-2.ans'] = <<'eofeof'.unpack('u')[0]
+example['test_data/z1space-2.ans'] = <<'eofeof'.unpack('u')[0]
"("``
eofeof
print "test_data/z1space-2 ";
- test("-e -Z2",$example['test_data/z1space-2'],[$example['test_data/z1space-2.ans']])
-
+ test('-e -Z2',example['test_data/z1space-2'],[example['test_data/z1space-2.ans']]);
# end
diff --git a/ext/openssl/lib/net/https.rb b/ext/openssl/lib/net/https.rb
index 9d24635f2f..fb7f53c555 100644
--- a/ext/openssl/lib/net/https.rb
+++ b/ext/openssl/lib/net/https.rb
@@ -64,10 +64,16 @@ It can be replaced by follow one:
Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
(This method is appeared in Michal Rokos's OpenSSL extention.)
+: key_file=((|path|))
+ Sets a private key file to use in PEM format.
+
: cert=((|cert|))
Sets an OpenSSL::X509::Certificate object as client certificate.
(This method is appeared in Michal Rokos's OpenSSL extention.)
+: cert_file=((|path|))
+ Sets pathname of a X.509 certification file in PEM format.
+
: ca_file=((|path|))
Sets path of a CA certification file in PEM format.
The file can contrain several CA certificats.
diff --git a/ext/openssl/lib/net/protocols.rb b/ext/openssl/lib/net/protocols.rb
index 6fb270304a..073d4f3027 100644
--- a/ext/openssl/lib/net/protocols.rb
+++ b/ext/openssl/lib/net/protocols.rb
@@ -29,7 +29,8 @@ module Net
extend Forwardable
def_delegators(:@ssl_context,
- :key=, :cert=, :ca_file=, :ca_path=,
+ :key=, :cert=, :key_file=, :cert_file=,
+ :ca_file=, :ca_path=,
:verify_mode=, :verify_callback=, :verify_depth=,
:timeout=, :cert_store=)
diff --git a/ext/openssl/lib/net/telnets.rb b/ext/openssl/lib/net/telnets.rb
index a872f41e6a..c7ecbd717a 100644
--- a/ext/openssl/lib/net/telnets.rb
+++ b/ext/openssl/lib/net/telnets.rb
@@ -124,7 +124,9 @@ module Net
elsif SB[0] == $1[0] # respond to "IAC SB xxx IAC SE"
if OPT_STARTTLS[0] == $1[1] && TLS_FOLLOWS[0] == $2[0]
@sock = OpenSSL::SSL::SSLSocket.new(@sock)
+ @sock.cert_file = @options['CertFile']
@sock.cert = @options['Cert'] unless @sock.cert
+ @sock.key_file = @options['KeyFile']
@sock.key = @options['Key'] unless @sock.key
@sock.ca_cert = @options['CACert']
@sock.ca_file = @options['CAFile']
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
index e711bda39c..6dd469827a 100644
--- a/ext/openssl/lib/openssl/x509.rb
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -62,92 +62,9 @@ module OpenSSL
end
class Name
- module RFC2253DN
- Special = ',=+<>#;'
- HexChar = /[0-9a-fA-F]/
- HexPair = /#{HexChar}#{HexChar}/
- HexString = /#{HexPair}+/
- Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
- StringChar = /[^#{Special}\\"]/
- QuoteChar = /[^\\"]/
- AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
- AttributeValue = /
- (?!["#])((?:#{StringChar}|#{Pair})*)|
- \#(#{HexString})|
- "((?:#{QuoteChar}|#{Pair})*)"
- /x
- TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
-
- module_function
-
- def expand_pair(str)
- return nil unless str
- return str.gsub(Pair){|pair|
- case pair.size
- when 2 then pair[1,1]
- when 3 then Integer("0x#{pair[1,2]}").chr
- else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
- end
- }
- end
-
- def expand_hexstring(str)
- return nil unless str
- der = str.gsub(HexPair){|hex| Integer("0x#{hex}").chr }
- a1 = OpenSSL::ASN1.decode(der)
- return a1.value, a1.tag
- end
-
- def expand_value(str1, str2, str3)
- value = expand_pair(str1)
- value, tag = expand_hexstring(str2) unless value
- value = expand_pair(str3) unless value
- return value, tag
- end
-
- def scan(dn)
- str = dn
- ary = []
- while true
- if md = TypeAndValue.match(str)
- matched = md.to_s
- remain = md.post_match
- type = md[1]
- value, tag = expand_value(md[2], md[3], md[4]) rescue nil
- if value
- type_and_value = [type, value]
- type_and_value.push(tag) if tag
- ary.unshift(type_and_value)
- if remain.length > 2 && remain[0] == ?,
- str = remain[1..-1]
- next
- elsif remain.length > 2 && remain[0] == ?+
- raise OpenSSL::X509::NameError,
- "multi-valued RDN is not supported: #{dn}"
- elsif remain.empty?
- break
- end
- end
- end
- msg_dn = dn[0, dn.length - str.length] + " =>" + str
- raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
- end
- return ary
- end
- end
-
- class <<self
- def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
- ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
- self.new(ary, template)
- end
-
- def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
- ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
- self.new(ary, template)
- end
-
- alias parse parse_openssl
+ def self.parse(str, template=OBJECT_TYPE_TEMPLATE)
+ ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
+ self.new(ary, template)
end
end
end
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 41659f0e81..36a7aa5042 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -285,18 +285,17 @@ ossl_raise(VALUE exc, const char *fmt, ...)
va_start(args, fmt);
len = vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
+ len += snprintf(buf+len, BUFSIZ-len, ": ");
}
- if (len < BUFSIZ && e) {
+ if (e) {
if (dOSSL == Qtrue) /* FULL INFO */
msg = ERR_error_string(e, NULL);
else
msg = ERR_reason_error_string(e);
ERR_clear_error();
- fmt = len ? ": %s" : "%s";
- len += snprintf(buf+len, BUFSIZ-len, fmt, msg);
+ len += snprintf(buf+len, BUFSIZ-len, "%s", msg);
}
- if(len > BUFSIZ) len = strlen(buf);
rb_exc_raise(rb_exc_new(exc, buf, len));
}
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index 1ce5fa50c5..a961c16bc0 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -813,14 +813,13 @@ ossl_asn1_traverse(VALUE self, VALUE obj)
{
unsigned char *p;
long offset = 0;
- volatile VALUE tmp;
obj = ossl_to_der_if_possible(obj);
- tmp = rb_str_new4(StringValue(obj));
- p = RSTRING(tmp)->ptr;
- ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 0, 1);
+ StringValue(obj);
+ p = RSTRING(obj)->ptr;
+ ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 1);
- return Qnil;
+ return obj;
}
static VALUE
@@ -829,12 +828,11 @@ ossl_asn1_decode(VALUE self, VALUE obj)
VALUE ret, ary;
unsigned char *p;
long offset = 0;
- volatile VALUE tmp;
obj = ossl_to_der_if_possible(obj);
- tmp = rb_str_new4(StringValue(obj));
- p = RSTRING(tmp)->ptr;
- ary = ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 1, 0);
+ StringValue(obj);
+ p = RSTRING(obj)->ptr;
+ ary = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 1, 0);
ret = rb_ary_entry(ary, 0);
return ret;
@@ -846,12 +844,11 @@ ossl_asn1_decode_all(VALUE self, VALUE obj)
VALUE ret;
unsigned char *p;
long offset = 0;
- volatile VALUE tmp;
obj = ossl_to_der_if_possible(obj);
- tmp = rb_str_new4(StringValue(obj));
- p = RSTRING(tmp)->ptr;
- ret = ossl_asn1_decode0(&p, RSTRING(tmp)->len, &offset, 0, 0, 0);
+ StringValue(obj);
+ p = RSTRING(obj)->ptr;
+ ret = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 0);
return ret;
}
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c