Skip to content

Commit

Permalink
botlib: print long int correctly
Browse files Browse the repository at this point in the history
value has type long, or equivalently signed long int. In C,
abs(some_long) returns int (to get a long result you would have to use
labs(some_long) due to lack of overloading), but in C++ it returns long.
  • Loading branch information
smcv committed Sep 24, 2016
1 parent 712627a commit 8ea096c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codemp/botlib/l_precomp.cpp
Expand Up @@ -2510,7 +2510,7 @@ int PC_Directive_eval(source_t *source)
token.whitespace_p = source->scriptstack->script_p;
token.endwhitespace_p = source->scriptstack->script_p;
token.linescrossed = 0;
sprintf(token.string, "%d", abs(value));
sprintf(token.string, "%ld", abs(value));
token.type = TT_NUMBER;
token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;
PC_UnreadSourceToken(source, &token);
Expand Down Expand Up @@ -2615,7 +2615,7 @@ int PC_DollarDirective_evalint(source_t *source)
token.whitespace_p = source->scriptstack->script_p;
token.endwhitespace_p = source->scriptstack->script_p;
token.linescrossed = 0;
sprintf(token.string, "%d", abs(value));
sprintf(token.string, "%ld", abs(value));
token.type = TT_NUMBER;
token.subtype = TT_INTEGER|TT_LONG|TT_DECIMAL;

Expand Down

2 comments on commit 8ea096c

@ensiform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is %ld valid msvc printf formatting?

@smcv
Copy link
Contributor Author

@smcv smcv commented on 8ea096c Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.