2000-05-01 05:42:38 -04:00
|
|
|
/**********************************************************************
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
util.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Thu Mar 9 11:55:53 JST 1995
|
|
|
|
|
* encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.
* parse.y (pragma_encoding): encoding specification pragma.
* parse.y (rb_intern3): encoding specified symbols.
* string.c (rb_str_length): length based on characters.
for older behavior, bytesize method added.
* string.c (rb_str_index_m): index based on characters. rindex as
well.
* string.c (succ_char): encoding aware succeeding string.
* string.c (rb_str_reverse): reverse based on characters.
* string.c (rb_str_inspect): encoding aware string description.
* string.c (rb_str_upcase_bang): encoding aware case conversion.
downcase, capitalize, swapcase as well.
* string.c (rb_str_tr_bang): tr based on characters. delete,
squeeze, tr_s, count as well.
* string.c (rb_str_split_m): split based on characters.
* string.c (rb_str_each_line): encoding aware each_line.
* string.c (rb_str_each_char): added. iteration based on
characters.
* string.c (rb_str_strip_bang): encoding aware whitespace
stripping. lstrip, rstrip as well.
* string.c (rb_str_justify): encoding aware justifying (ljust,
rjust, center).
* string.c (str_encoding): get encoding attribute from a string.
* re.c (rb_reg_initialize): encoding aware regular expression
* sprintf.c (rb_str_format): formatting (i.e. length count) based
on characters.
* io.c (rb_io_getc): getc to return one-character string.
for older behavior, getbyte method added.
* ext/stringio/stringio.c (strio_getc): ditto.
* io.c (rb_io_ungetc): allow pushing arbitrary string at the
current reading point.
* ext/stringio/stringio.c (strio_ungetc): ditto.
* ext/strscan/strscan.c: encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 23:29:39 -04:00
|
|
|
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-01 05:42:38 -04:00
|
|
|
**********************************************************************/
|
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#ifndef RUBY_UTIL_H
|
|
|
|
#define RUBY_UTIL_H 1
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#if 0
|
|
|
|
} /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
#endif
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2010-07-27 05:33:55 -04:00
|
|
|
#include "ruby/defines.h"
|
|
|
|
#ifdef RUBY_EXTCONF_H
|
|
|
|
#include RUBY_EXTCONF_H
|
|
|
|
#endif
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
#ifndef _
|
2001-12-21 02:20:23 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
# ifndef HAVE_PROTOTYPES
|
|
|
|
# define HAVE_PROTOTYPES 1
|
|
|
|
# endif
|
|
|
|
# ifndef HAVE_STDARG_PROTOTYPES
|
|
|
|
# define HAVE_STDARG_PROTOTYPES 1
|
|
|
|
# endif
|
|
|
|
#endif
|
1999-08-13 01:45:20 -04:00
|
|
|
#ifdef HAVE_PROTOTYPES
|
|
|
|
# define _(args) args
|
|
|
|
#else
|
|
|
|
# define _(args) ()
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STDARG_PROTOTYPES
|
|
|
|
# define __(args) args
|
|
|
|
#else
|
|
|
|
# define __(args) ()
|
|
|
|
#endif
|
1999-01-19 23:59:39 -05:00
|
|
|
#endif
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2014-01-11 19:21:37 -05:00
|
|
|
#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
|
2015-06-03 22:53:11 -04:00
|
|
|
/* an approximation of ceil(n * log10(2)), up to 65536 at least */
|
2014-01-11 19:21:37 -05:00
|
|
|
|
2011-04-09 05:02:03 -04:00
|
|
|
#define scan_oct(s,l,e) ((int)ruby_scan_oct((s),(l),(e)))
|
2009-03-14 05:25:20 -04:00
|
|
|
unsigned long ruby_scan_oct(const char *, size_t, size_t *);
|
2011-04-09 05:02:03 -04:00
|
|
|
#define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e)))
|
2009-03-14 05:25:20 -04:00
|
|
|
unsigned long ruby_scan_hex(const char *, size_t, size_t *);
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2014-02-08 07:50:28 -05:00
|
|
|
#ifdef HAVE_GNU_QSORT_R
|
|
|
|
# define ruby_qsort qsort_r
|
|
|
|
#else
|
2009-03-13 21:56:42 -04:00
|
|
|
void ruby_qsort(void *, const size_t, const size_t,
|
2006-12-31 10:02:22 -05:00
|
|
|
int (*)(const void *, const void *, void *), void *);
|
2014-02-08 07:50:28 -05:00
|
|
|
#endif
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
void ruby_setenv(const char *, const char *);
|
|
|
|
void ruby_unsetenv(const char *);
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
char *ruby_strdup(const char *);
|
2000-07-27 05:49:34 -04:00
|
|
|
#undef strdup
|
2003-08-03 21:27:25 -04:00
|
|
|
#define strdup(s) ruby_strdup(s)
|
2000-07-27 05:49:34 -04:00
|
|
|
|
* bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
util.c, util.h, variable.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 02:32:32 -04:00
|
|
|
char *ruby_getcwd(void);
|
2001-11-08 01:43:14 -05:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
double ruby_strtod(const char *, char **);
|
2005-11-01 08:04:35 -05:00
|
|
|
#undef strtod
|
2011-04-09 05:02:03 -04:00
|
|
|
#define strtod(s,e) ruby_strtod((s),(e))
|
2002-05-14 02:22:31 -04:00
|
|
|
|
2008-02-23 16:13:05 -05:00
|
|
|
void ruby_each_words(const char *, void (*)(const char*, int, void*), void *);
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
#if 0
|
|
|
|
{ /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
} /* extern "C" { */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* RUBY_UTIL_H */
|