summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
commit7ea2ceddb832b9973694fecac9fe3c30400735ba (patch)
treea9b60dec20fa5f7f52ca7c8113195f2d65728a22 /sprintf.c
parent62e41d3f2e48422bbdf1bb2db83ae60b255b1a1a (diff)
This commit was generated by cvs2svn to compensate for changes in r11,
which included commits to RCS files with non-trunk default branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sprintf.c b/sprintf.c
index 0dd998b..7862a46 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -109,7 +109,7 @@ f_sprintf(argc, argv)
int argc;
VALUE *argv;
{
- struct RString *fmt;
+ VALUE fmt;
char *buf, *p, *end;
int blen, bsiz;
VALUE result;
@@ -122,7 +122,7 @@ f_sprintf(argc, argv)
#define FWIDTH 16
#define FPREC 32
- int width, prec, flags = FNONE;
+ int width = 0, prec = 0, flags = FNONE;
VALUE str;
@@ -142,15 +142,15 @@ f_sprintf(argc, argv)
#define GETARG() \
((argc == 0)?(ArgError("too few argument."),0):(argc--,((argv++)[0])))
- fmt = (struct RString*)GETARG();
+ fmt = GETARG();
Check_Type(fmt, T_STRING);
blen = 0;
bsiz = 120;
buf = ALLOC_N(char, bsiz);
- end = fmt->ptr + fmt->len;
+ end = RSTRING(fmt)->ptr + RSTRING(fmt)->len;
- for (p = fmt->ptr; p < end; p++) {
+ for (p = RSTRING(fmt)->ptr; p < end; p++) {
char *t;
for (t = p; t < end && *t != '%'; t++) ;
@@ -597,7 +597,7 @@ f_sprintf(argc, argv)
}
sprint_exit:
- if (verbose && argc > 1) {
+ if (RTEST(verbose) && argc > 1) {
ArgError("too many argument for format string");
}
result = str_new(buf, blen);