Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
Use snprintf instead of fcvt()
Browse files Browse the repository at this point in the history
fcvt is deprecated (from gcvt(3)):

    Marked as LEGACY in POSIX.1-2001.  POSIX.1-2008 removes the
    specification of gcvt(), recommending the use of sprintf(3)
    instead (though snprintf(3) may be preferable)

and does not exist on e.g. FreeBSD.
  • Loading branch information
AMDmi3 committed May 20, 2015
1 parent 75e9dc0 commit 1bcd0fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/common/OMISC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <math.h>

#include <ALL.h>
#include <OSTR.h>
Expand Down Expand Up @@ -755,10 +756,13 @@ char* Misc::format(double inNum, int formatType)

static char outBuf[35];
char *outPtr=outBuf;
char floatBuf[35];
char *floatStr;
int i, intDigit, sign; // intDigit = no. of integer digits

floatStr = fcvt( inNum, MONEY_DEC_PLACE, &intDigit, &sign );
intDigit = snprintf(floatBuf, sizeof(floatBuf), "%.0lf", fabs(inNum) * 100.0);
intDigit -= 2;
floatStr = floatBuf;

#ifdef DEBUG
if( intDigit > 29 ) // integer digits can't exceed 29
Expand Down

0 comments on commit 1bcd0fc

Please sign in to comment.