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
commitfd1d8cdc09ed86e4a0812120a17ff0d7b04adcaf (patch)
tree341289a84a427f1e92425c7ebf82d2f1733e9a40 /sprintf.c
parentf12baed5df6d3c213dd75d2f0d9f36bb179fb843 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@11 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);