Drop _t suffix from struct names. (#7886)

POSIX reserves `_t` suffix in types.
This commit is contained in:
Samuel Williams 2023-06-01 21:46:10 +09:00 committed by GitHub
parent a5e1d549b5
commit 47a8de6095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-06-01 12:46:30 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
3 changed files with 32 additions and 34 deletions

View File

@ -25,7 +25,7 @@
/* rb_io_t is in ruby/io.h. The header file has historically not been included /* rb_io_t is in ruby/io.h. The header file has historically not been included
* into ruby/ruby.h. We follow that tradition. */ * into ruby/ruby.h. We follow that tradition. */
struct rb_io_t; struct rb_io;
/** /**
* Ruby's File and IO. Ruby's IO are not just file descriptors. They have * Ruby's File and IO. Ruby's IO are not just file descriptors. They have
@ -38,7 +38,7 @@ struct RFile {
struct RBasic basic; struct RBasic basic;
/** IO's specific fields. */ /** IO's specific fields. */
struct rb_io_t *fptr; struct rb_io *fptr;
}; };
/** /**

View File

@ -89,7 +89,7 @@ typedef enum {
* ::rb_io_t::rbuf. People don't manipulate it directly. * ::rb_io_t::rbuf. People don't manipulate it directly.
*/ */
RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
struct rb_io_buffer_t { struct rb_io_internal_buffer {
/** Pointer to the underlying memory region, of at least `capa` bytes. */ /** Pointer to the underlying memory region, of at least `capa` bytes. */
char *ptr; /* off + len <= capa */ char *ptr; /* off + len <= capa */
@ -105,7 +105,7 @@ struct rb_io_buffer_t {
} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END(); } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
/** @alias{rb_io_buffer_t} */ /** @alias{rb_io_buffer_t} */
typedef struct rb_io_buffer_t rb_io_buffer_t; typedef struct rb_io_internal_buffer rb_io_buffer_t;
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */ /** Decomposed encoding flags (e.g. `"enc:enc2""`). */
/* /*
@ -114,7 +114,7 @@ typedef struct rb_io_buffer_t rb_io_buffer_t;
* e1 NULL force_encoding(e1) convert str.encoding to e1 * e1 NULL force_encoding(e1) convert str.encoding to e1
* e1 e2 convert from e2 to e1 convert str.encoding to e2 * e1 e2 convert from e2 to e1 convert str.encoding to e2
*/ */
struct rb_io_enc_t { struct rb_io_encoding {
/** Internal encoding. */ /** Internal encoding. */
rb_encoding *enc; rb_encoding *enc;
/** External encoding. */ /** External encoding. */
@ -136,7 +136,7 @@ struct rb_io_enc_t {
}; };
/** Ruby's IO, metadata and buffers. */ /** Ruby's IO, metadata and buffers. */
typedef struct rb_io_t { typedef struct rb_io {
/** The IO's Ruby level counterpart. */ /** The IO's Ruby level counterpart. */
VALUE self; VALUE self;
@ -160,7 +160,7 @@ typedef struct rb_io_t {
VALUE pathv; VALUE pathv;
/** finalize proc */ /** finalize proc */
void (*finalize)(struct rb_io_t*,int); void (*finalize)(struct rb_io*,int);
/** Write buffer. */ /** Write buffer. */
rb_io_buffer_t wbuf; rb_io_buffer_t wbuf;
@ -178,7 +178,7 @@ typedef struct rb_io_t {
*/ */
VALUE tied_io_for_writing; VALUE tied_io_for_writing;
struct rb_io_enc_t encs; /**< Decomposed encoding flags. */ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
/** Encoding converter used when reading from this IO. */ /** Encoding converter used when reading from this IO. */
rb_econv_t *readconv; rb_econv_t *readconv;
@ -231,7 +231,7 @@ typedef struct rb_io_t {
} rb_io_t; } rb_io_t;
/** @alias{rb_io_enc_t} */ /** @alias{rb_io_enc_t} */
typedef struct rb_io_enc_t rb_io_enc_t; typedef struct rb_io_encoding rb_io_enc_t;
/** /**
* @private * @private
@ -357,7 +357,7 @@ typedef struct rb_io_enc_t rb_io_enc_t;
/** /**
* Allocate a new IO object, with the given file descriptor. * Allocate a new IO object, with the given file descriptor.
*/ */
VALUE rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_enc_t *encoding); VALUE rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_encoding *encoding);
/** /**
* Returns whether or not the underlying IO is closed. * Returns whether or not the underlying IO is closed.
@ -436,14 +436,14 @@ rb_io_t *rb_io_make_open_file(VALUE obj);
* like this: * like this:
* *
* ```CXX * ```CXX
* typedef struct rb_io_t { * typedef struct rb_io {
* FILE *f; // stdio ptr for read/write * FILE *f; // stdio ptr for read/write
* FILE *f2; // additional ptr for rw pipes * FILE *f2; // additional ptr for rw pipes
* int mode; // mode flags * int mode; // mode flags
* int pid; // child's pid (for pipes) * int pid; // child's pid (for pipes)
* int lineno; // number of lines read * int lineno; // number of lines read
* char *path; // pathname for file * char *path; // pathname for file
* void (*finalize) _((struct rb_io_t*,int)); // finalize proc * void (*finalize) _((struct rb_io*,int)); // finalize proc
* } rb_io_t; * } rb_io_t;
*``` *```
* *

42
io.c
View File

@ -216,7 +216,7 @@ struct argf {
long lineno; long lineno;
VALUE argv; VALUE argv;
VALUE inplace; VALUE inplace;
struct rb_io_enc_t encs; struct rb_io_encoding encs;
int8_t init_p, next_p, binmode; int8_t init_p, next_p, binmode;
}; };
@ -6715,8 +6715,6 @@ rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2
return extracted; return extracted;
} }
typedef struct rb_io_enc_t convconfig_t;
static void static void
validate_enc_binmode(int *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *enc2) validate_enc_binmode(int *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *enc2)
{ {
@ -6775,7 +6773,7 @@ extract_binmode(VALUE opthash, int *fmode)
void void
rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
int *oflags_p, int *fmode_p, convconfig_t *convconfig_p) int *oflags_p, int *fmode_p, struct rb_io_encoding *convconfig_p)
{ {
VALUE vmode; VALUE vmode;
int oflags, fmode; int oflags, fmode;
@ -7103,11 +7101,11 @@ io_set_encoding_by_bom(VALUE io)
static VALUE static VALUE
rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode, rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode,
const convconfig_t *convconfig, mode_t perm) const struct rb_io_encoding *convconfig, mode_t perm)
{ {
VALUE pathv; VALUE pathv;
rb_io_t *fptr; rb_io_t *fptr;
convconfig_t cc; struct rb_io_encoding cc;
if (!convconfig) { if (!convconfig) {
/* Set to default encodings */ /* Set to default encodings */
rb_io_ext_int_to_encs(NULL, NULL, &cc.enc, &cc.enc2, fmode); rb_io_ext_int_to_encs(NULL, NULL, &cc.enc, &cc.enc2, fmode);
@ -7141,7 +7139,7 @@ rb_file_open_internal(VALUE io, VALUE filename, const char *modestr)
{ {
int fmode = rb_io_modestr_fmode(modestr); int fmode = rb_io_modestr_fmode(modestr);
const char *p = strchr(modestr, ':'); const char *p = strchr(modestr, ':');
convconfig_t convconfig; struct rb_io_encoding convconfig;
if (p) { if (p) {
parse_mode_enc(p+1, rb_usascii_encoding(), parse_mode_enc(p+1, rb_usascii_encoding(),
@ -7249,7 +7247,7 @@ static void
fptr_copy_finalizer(rb_io_t *fptr, const rb_io_t *orig) fptr_copy_finalizer(rb_io_t *fptr, const rb_io_t *orig)
{ {
#if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK) #if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK)
void (*const old_finalize)(struct rb_io_t*,int) = fptr->finalize; void (*const old_finalize)(struct rb_io*,int) = fptr->finalize;
if (old_finalize == orig->finalize) return; if (old_finalize == orig->finalize) return;
#endif #endif
@ -7454,7 +7452,7 @@ char *rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog);
#ifndef __EMSCRIPTEN__ #ifndef __EMSCRIPTEN__
static VALUE static VALUE
pipe_open(VALUE execarg_obj, const char *modestr, int fmode, pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
const convconfig_t *convconfig) const struct rb_io_encoding *convconfig)
{ {
struct rb_execarg *eargp = NIL_P(execarg_obj) ? NULL : rb_execarg_get(execarg_obj); struct rb_execarg *eargp = NIL_P(execarg_obj) ? NULL : rb_execarg_get(execarg_obj);
VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ; VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ;
@ -7683,7 +7681,7 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
#else #else
static VALUE static VALUE
pipe_open(VALUE execarg_obj, const char *modestr, int fmode, pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
const convconfig_t *convconfig) const struct rb_io_encoding *convconfig)
{ {
rb_raise(rb_eNotImpError, "popen() is not available"); rb_raise(rb_eNotImpError, "popen() is not available");
} }
@ -7705,7 +7703,7 @@ is_popen_fork(VALUE prog)
static VALUE static VALUE
pipe_open_s(VALUE prog, const char *modestr, int fmode, pipe_open_s(VALUE prog, const char *modestr, int fmode,
const convconfig_t *convconfig) const struct rb_io_encoding *convconfig)
{ {
int argc = 1; int argc = 1;
VALUE *argv = &prog; VALUE *argv = &prog;
@ -7914,7 +7912,7 @@ rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt)
const char *modestr; const char *modestr;
VALUE tmp, execarg_obj = Qnil; VALUE tmp, execarg_obj = Qnil;
int oflags, fmode; int oflags, fmode;
convconfig_t convconfig; struct rb_io_encoding convconfig;
tmp = rb_check_array_type(pname); tmp = rb_check_array_type(pname);
if (!NIL_P(tmp)) { if (!NIL_P(tmp)) {
@ -7968,7 +7966,7 @@ popen_finish(VALUE port, VALUE klass)
static void static void
rb_scan_open_args(int argc, const VALUE *argv, rb_scan_open_args(int argc, const VALUE *argv,
VALUE *fname_p, int *oflags_p, int *fmode_p, VALUE *fname_p, int *oflags_p, int *fmode_p,
convconfig_t *convconfig_p, mode_t *perm_p) struct rb_io_encoding *convconfig_p, mode_t *perm_p)
{ {
VALUE opt, fname, vmode, vperm; VALUE opt, fname, vmode, vperm;
int oflags, fmode; int oflags, fmode;
@ -7992,7 +7990,7 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
{ {
VALUE fname; VALUE fname;
int oflags, fmode; int oflags, fmode;
convconfig_t convconfig; struct rb_io_encoding convconfig;
mode_t perm; mode_t perm;
rb_scan_open_args(argc, argv, &fname, &oflags, &fmode, &convconfig, &perm); rb_scan_open_args(argc, argv, &fname, &oflags, &fmode, &convconfig, &perm);
@ -8240,13 +8238,13 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
return rb_io_s_open(argc, argv, rb_cFile); return rb_io_s_open(argc, argv, rb_cFile);
} }
static VALUE rb_io_open_generic(VALUE, VALUE, int, int, const convconfig_t *, mode_t); static VALUE rb_io_open_generic(VALUE, VALUE, int, int, const struct rb_io_encoding *, mode_t);
static VALUE static VALUE
rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt) rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt)
{ {
int oflags, fmode; int oflags, fmode;
convconfig_t convconfig; struct rb_io_encoding convconfig;
mode_t perm; mode_t perm;
rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, &convconfig); rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, &convconfig);
@ -8256,7 +8254,7 @@ rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt)
static VALUE static VALUE
rb_io_open_generic(VALUE klass, VALUE filename, int oflags, int fmode, rb_io_open_generic(VALUE klass, VALUE filename, int oflags, int fmode,
const convconfig_t *convconfig, mode_t perm) const struct rb_io_encoding *convconfig, mode_t perm)
{ {
VALUE cmd; VALUE cmd;
if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) { if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
@ -8421,7 +8419,7 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
if (!NIL_P(nmode) || !NIL_P(opt)) { if (!NIL_P(nmode) || !NIL_P(opt)) {
int fmode; int fmode;
convconfig_t convconfig; struct rb_io_encoding convconfig;
rb_io_extract_modeenc(&nmode, 0, opt, &oflags, &fmode, &convconfig); rb_io_extract_modeenc(&nmode, 0, opt, &oflags, &fmode, &convconfig);
if (RUBY_IO_EXTERNAL_P(fptr) && if (RUBY_IO_EXTERNAL_P(fptr) &&
@ -9186,7 +9184,7 @@ allocate_and_open_new_file(VALUE klass)
} }
VALUE VALUE
rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_enc_t *encoding) rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_encoding *encoding)
{ {
int state; int state;
VALUE self = rb_protect(allocate_and_open_new_file, klass, &state); VALUE self = rb_protect(allocate_and_open_new_file, klass, &state);
@ -9309,7 +9307,7 @@ rb_io_stdio_file(rb_io_t *fptr)
} }
static inline void static inline void
rb_io_buffer_init(struct rb_io_buffer_t *buf) rb_io_buffer_init(struct rb_io_internal_buffer *buf)
{ {
buf->ptr = NULL; buf->ptr = NULL;
buf->off = 0; buf->off = 0;
@ -9412,7 +9410,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
VALUE fnum, vmode; VALUE fnum, vmode;
rb_io_t *fp; rb_io_t *fp;
int fd, fmode, oflags = O_RDONLY; int fd, fmode, oflags = O_RDONLY;
convconfig_t convconfig; struct rb_io_encoding convconfig;
VALUE opt; VALUE opt;
#if defined(HAVE_FCNTL) && defined(F_GETFL) #if defined(HAVE_FCNTL) && defined(F_GETFL)
int ofmode; int ofmode;
@ -12246,7 +12244,7 @@ rb_io_s_binread(int argc, VALUE *argv, VALUE io)
|O_BINARY |O_BINARY
#endif #endif
}; };
convconfig_t convconfig = {NULL, NULL, 0, Qnil}; struct rb_io_encoding convconfig = {NULL, NULL, 0, Qnil};
rb_scan_args(argc, argv, "12", NULL, NULL, &offset); rb_scan_args(argc, argv, "12", NULL, NULL, &offset);
FilePathValue(argv[0]); FilePathValue(argv[0]);