1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* util.[hc] (ruby_add_suffix): constified.

* util.[hc] (ruby_scan_{oct,hex}): fixed typo. (renamed from
  scan_{oct,hex})

* util.c: almostly ANSI styled. (except for functions depending on
  macro and K&R tecknique)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ocean 2005-10-22 05:26:44 +00:00
parent 0cfe16bc21
commit eb82473a39
3 changed files with 25 additions and 27 deletions

View file

@ -1,3 +1,13 @@
Sat Oct 22 14:25:43 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* util.[hc] (ruby_add_suffix): constified.
* util.[hc] (ruby_scan_{oct,hex}): fixed typo. (renamed from
scan_{oct,hex})
* util.c: almostly ANSI styled. (except for functions depending on
macro and K&R tecknique)
Sat Oct 22 13:26:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* object.c (sym_inspect), parse.y (parser_yylex, rb_symname_p): check

36
util.c
View file

@ -21,15 +21,9 @@
#endif
#include "util.h"
#ifndef HAVE_STRING_H
char *strchr(char*,char);
#endif
unsigned long
scan_oct(start, len, retlen)
const char *start;
int len;
int *retlen;
ruby_scan_oct(const char *start, int len, int *retlen)
{
register const char *s = start;
register unsigned long retval = 0;
@ -43,10 +37,7 @@ scan_oct(start, len, retlen)
}
unsigned long
scan_hex(start, len, retlen)
const char *start;
int len;
int *retlen;
ruby_scan_hex(const char *start, int len, int *retlen)
{
static char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
register const char *s = start;
@ -145,19 +136,17 @@ scan_hex(start, len, retlen)
*/
static int valid_filename(char *s);
static int valid_filename(const char *s);
static char suffix1[] = ".$$$";
static char suffix2[] = ".~~~";
static const char suffix1[] = ".$$$";
static const char suffix2[] = ".~~~";
#define ext (&buf[1000])
#define strEQ(s1,s2) (strcmp(s1,s2) == 0)
void
ruby_add_suffix(str, suffix)
VALUE str;
char *suffix;
ruby_add_suffix(VALUE str, const char *suffix)
{
int baselen;
int extlen = strlen(suffix);
@ -227,7 +216,7 @@ fallback:
#if defined(__CYGWIN32__) || defined(_WIN32)
static int
valid_filename(char *s)
valid_filename(const char *s)
{
int fd;
@ -620,8 +609,7 @@ ruby_qsort(void* base, const int nel, const int size,
}
char *
ruby_strdup(str)
const char *str;
ruby_strdup(const char *str)
{
char *tmp;
int len = strlen(str) + 1;
@ -633,7 +621,7 @@ ruby_strdup(str)
}
char *
ruby_getcwd()
ruby_getcwd(void)
{
#ifdef HAVE_GETCWD
int size = 200;
@ -715,8 +703,8 @@ static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
*/
double
ruby_strtod(string, endPtr)
const char *string; /* A decimal ASCII floating-point number,
ruby_strtod(
const char *string, /* A decimal ASCII floating-point number,
* optionally preceded by white space.
* Must have form "-I.FE-X", where I is the
* integer part of the mantissa, F is the
@ -729,7 +717,7 @@ ruby_strtod(string, endPtr)
* The "E" may actually be an "e". E and X
* may both be omitted (but not just one).
*/
char **endPtr; /* If non-NULL, store terminating character's
char **endPtr) /* If non-NULL, store terminating character's
* address here. */
{
int sign, expSign = FALSE;

6
util.h
View file

@ -35,12 +35,12 @@
#endif
#define scan_oct ruby_scan_oct
unsigned long scan_oct(const char*, int, int*);
unsigned long ruby_scan_oct(const char*, int, int*);
#define scan_hex ruby_scan_hex
unsigned long scan_hex(const char*, int, int*);
unsigned long ruby_scan_hex(const char*, int, int*);
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(_WIN32)
void ruby_add_suffix(VALUE str, char *suffix);
void ruby_add_suffix(VALUE str, const char *suffix);
#endif
void ruby_qsort(void*, const int, const int, int (*)(const void*,const void*,void*), void*);