Ruby: include/ruby/util.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Functions
util.h File Reference
`#include "ruby/internal/config.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/defines.h"`

Go to the source code of this file.

## Macros
#define | DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
#define | scan_oct(s, l, e) ((int)ruby_scan_oct((s),(l),(e)))
#define | scan_hex(s, l, e) ((int)ruby_scan_hex((s),(l),(e)))
#define | strdup(s) ruby_strdup(s)
#define | strtod(s, e) ruby_strtod((s),(e))

## Functions
unsigned long | ruby_scan_oct (const char *, size_t, size_t *)
unsigned long | ruby_scan_hex (const char *, size_t, size_t *)
void | ruby_qsort (void *, const size_t, const size_t, int(*)(const void *, const void *, void *), void *)
void | ruby_setenv (const char *, const char *)
void | ruby_unsetenv (const char *)
char * | ruby_strdup (const char *)
char * | ruby_getcwd (void)
double | ruby_strtod (const char *, char **)
void | ruby_each_words (const char *, void(*)(const char *, int, void *), void *)

## Detailed Description

Author
  $Author$

Date
  Thu Mar 9 11:55:53 JST 1995

Copyright
  Copyright (C) 1993-2007 Yukihiro Matsumoto
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition in file util.h.

## Macro Definition Documentation

## ◆ DECIMAL_SIZE_OF_BITS

#define DECIMAL_SIZE_OF_BITS | ( |  | n | ) | (((n) * 3010 + 9998) / 9999)

Definition at line 19 of file util.h.

## ◆ scan_hex

#define scan_hex | ( |  | s,
|  |  | l,
|  |  | e
| ) |  | ((int)ruby_scan_hex((s),(l),(e)))

Definition at line 24 of file util.h.

## ◆ scan_oct

#define scan_oct | ( |  | s,
|  |  | l,
|  |  | e
| ) |  | ((int)ruby_scan_oct((s),(l),(e)))

Definition at line 22 of file util.h.

## ◆ strdup

#define strdup | ( |  | s | ) | ruby_strdup(s)

Definition at line 39 of file util.h.

## ◆ strtod

#define strtod | ( |  | s,
|  |  | e
| ) |  | ruby_strtod((s),(e))

Definition at line 45 of file util.h.

## Function Documentation

## ◆ ruby_each_words()

void ruby_each_words | ( | const char * | str,
|  | void(*)(const char *, int, void *) | func,
|  | void * | arg
| ) |  |

Definition at line 589 of file util.c.

References int(), ISSPACE, len, and str.

Referenced by ruby_set_debug_option().

## ◆ ruby_getcwd()

char * ruby_getcwd | ( | void |  | ) |

Definition at line 543 of file util.c.

References DATA_PTR, Data_Wrap_Struct, free, getcwd, NULL, PATH_MAX, RB_GC_GUARD, rb_sys_fail(), rb_syserr_fail(), RUBY_DEFAULT_FREE, ruby_strdup(), xfree, xmalloc, and xrealloc.

Referenced by rb_dir_getwd_ospath(), and rb_file_expand_path_internal().

## ◆ ruby_qsort()

void ruby_qsort | ( | void * | ,
|  | const | size_t,
|  | const | size_t,
|  | int(*)(const void *, const void *, void *) | ,
|  | void * |
| ) |  |

Referenced by rb_ary_sort_bang(), and rb_nmin_run().

## ◆ ruby_scan_hex()

unsigned long ruby_scan_hex | ( | const char * | start,
|  | size_t | len,
|  | size_t * | retlen
| ) |  |

Definition at line 56 of file util.c.

References hexdigit, int(), len, and strchr().

## ◆ ruby_scan_oct()

unsigned long ruby_scan_oct | ( | const char * | start,
|  | size_t | len,
|  | size_t * | retlen
| ) |  |

Definition at line 38 of file util.c.

References int(), and len.

## ◆ ruby_setenv()

void ruby_setenv | ( | const char * | name,
|  | const char * | value
| ) |  |

Definition at line 5145 of file hash.c.

References ALLOC_N, ALLOCV_END, ALLOCV_N, environ, fail, free, GET_ENVIRON, L, len, malloc, max, name, NULL, PRIuSIZE, rb_sprintf(), rb_sys_fail_str(), REALLOC_N, ruby_strdup(), snprintf, str, strlen(), and xfree.

Referenced by rb_env_clear(), rb_execarg_run_options(), and ruby_unsetenv().

## ◆ ruby_strdup()

char * ruby_strdup | ( | const char * | str | ) |

Definition at line 531 of file util.c.

References len, memcpy, str, strlen(), and xmalloc.

Referenced by compat_init_setproctitle(), getifaddrs(), ruby_getcwd(), and ruby_setenv().

## ◆ ruby_strtod()

double ruby_strtod | ( | const char * | ,
|  | char ** |
| ) |  |

## ◆ ruby_unsetenv()

void ruby_unsetenv | ( | const char * | name | ) |

Definition at line 5284 of file hash.c.

References name, and ruby_setenv().