summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-10-16 10:33:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-10-16 10:33:06 +0000
commit40a3f601e43a137e56b2c28454ffb6ce79d7ec7e (patch)
treecf4e94cab7bee1f0e15d9ab8d1885fb0739fb408 /error.c
parent3196645aee3add70a33f3d926d1d6e3820d39377 (diff)
ruby -v
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/error.c b/error.c
index 6a48210b4e..393603ff7a 100644
--- a/error.c
+++ b/error.c
@@ -34,14 +34,20 @@ err_snprintf(buf, len, fmt, args)
int len;
va_list args;
{
+ int n;
+
if (!ruby_sourcefile) {
vsnprintf(buf, len, fmt, args);
+ return;
+ }
+ else if (ruby_sourceline == 0) {
+ n = snprintf(buf, len, "%s: ", ruby_sourcefile);
}
else {
- int n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
- if (len > n) {
- vsnprintf((char*)buf+n, len-n, fmt, args);
- }
+ n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
+ }
+ if (len > n) {
+ vsnprintf((char*)buf+n, len-n, fmt, args);
}
}