mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 17:14:01 +02:00

ALLOCA_N() to prevent modification. [ruby-dev:24438] * io.c (rb_io_mode_flags): preserve append mode flag. [ruby-dev:24436] * io.c (rb_io_modenum_mode): do not use external output buffer. * string.c (rb_str_justify): differ pointer retrieval to prevent padding string modification. [ruby-dev:24434] * range.c (range_each_func): allow func to terminate loop by returning RANGE_EACH_BREAK. * range.c (member_i): use RANGE_EACH_BREAK. [ruby-talk:114959] * marshal.c (r_byte): retrieve pointer from string value for each time. [ruby-dev:24404] * marshal.c (r_bytes0): ditto. * enum.c (sort_by_i): re-entrance check added. [ruby-dev:24399] * io.c (io_read): should freeze all reading buffer. [ruby-dev:24400] * string.c (rb_str_sum): should use bignums when bits is greater than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395] * eval.c (specific_eval): defer pointer retrieval to prevent unsafe sourcefile string modification. [ruby-dev:24382] * eval.c (specific_eval): defer pointer retrieval to prevent unsafe sourcefile string modification. [ruby-dev:24382] * string.c (rb_str_sum): wrong cast caused wrong result. [ruby-dev:24385] * enum.c (enum_sort_by): hide temporary array from ObjectSpace.each_object. [ruby-dev:24386] * string.c (rb_str_sum): check was done with false pointer. [ruby-dev:24383] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
78 lines
2.1 KiB
C
78 lines
2.1 KiB
C
/**********************************************************************
|
|
|
|
rubyio.h -
|
|
|
|
$Author$
|
|
$Date$
|
|
created at: Fri Nov 12 16:47:09 JST 1993
|
|
|
|
Copyright (C) 1993-2003 Yukihiro Matsumoto
|
|
|
|
**********************************************************************/
|
|
|
|
#ifndef RUBYIO_H
|
|
#define RUBYIO_H
|
|
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
|
|
typedef struct OpenFile {
|
|
FILE *f; /* stdio ptr for read/write */
|
|
FILE *f2; /* additional ptr for rw pipes */
|
|
int mode; /* mode flags */
|
|
int pid; /* child's pid (for pipes) */
|
|
int lineno; /* number of lines read */
|
|
char *path; /* pathname for file */
|
|
void (*finalize) _((struct OpenFile*,int)); /* finalize proc */
|
|
} OpenFile;
|
|
|
|
#define FMODE_READABLE 1
|
|
#define FMODE_WRITABLE 2
|
|
#define FMODE_READWRITE 3
|
|
#define FMODE_APPEND 64
|
|
#define FMODE_BINMODE 4
|
|
#define FMODE_SYNC 8
|
|
#define FMODE_WBUF 16
|
|
#define FMODE_RBUF 32
|
|
|
|
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
|
|
|
|
#define MakeOpenFile(obj, fp) do {\
|
|
if (RFILE(obj)->fptr) {\
|
|
rb_io_close(obj);\
|
|
free(RFILE(obj)->fptr);\
|
|
RFILE(obj)->fptr = 0;\
|
|
}\
|
|
fp = 0;\
|
|
fp = RFILE(obj)->fptr = ALLOC(OpenFile);\
|
|
fp->f = fp->f2 = NULL;\
|
|
fp->mode = 0;\
|
|
fp->pid = 0;\
|
|
fp->lineno = 0;\
|
|
fp->path = NULL;\
|
|
fp->finalize = 0;\
|
|
} while (0)
|
|
|
|
#define GetReadFile(fptr) ((fptr)->f)
|
|
#define GetWriteFile(fptr) (((fptr)->f2) ? (fptr)->f2 : (fptr)->f)
|
|
|
|
FILE *rb_fopen _((const char*, const char*));
|
|
FILE *rb_fdopen _((int, const char*));
|
|
int rb_getc _((FILE*));
|
|
long rb_io_fread _((char *, long, FILE *));
|
|
long rb_io_fwrite _((const char *, long, FILE *));
|
|
int rb_io_mode_flags _((const char*));
|
|
void rb_io_check_writable _((OpenFile*));
|
|
void rb_io_check_readable _((OpenFile*));
|
|
void rb_io_fptr_finalize _((OpenFile*));
|
|
void rb_io_synchronized _((OpenFile*));
|
|
void rb_io_check_closed _((OpenFile*));
|
|
int rb_io_wait_readable _((int));
|
|
int rb_io_wait_writable _((int));
|
|
|
|
VALUE rb_io_taint_check _((VALUE));
|
|
void rb_eof_error _((void));
|
|
|
|
void rb_read_check _((FILE*));
|
|
int rb_read_pending _((FILE*));
|
|
#endif
|