ReactOS  r76032
fconv.c File Reference
#include <schily/mconfig.h>
#include <schily/stdlib.h>
#include <schily/standard.h>
#include <schily/string.h>
#include <schily/schily.h>
#include <schily/math.h>
#include <schily/nlsdefs.h>
#include <schily/float.h>
#include "cvt.c"
Include dependency graph for fconv.c:

Go to the source code of this file.

Macros

#define isnan(val)   (0)
 
#define NO_ISNAN
 
#define isinf(val)   (0)
 
#define NO_ISINF
 
#define MDOUBLE   double
 
#define abs(i)   ((i) < 0 ? -(i) : (i))
 

Functions

char *ecvt __PR ((double, int, int *, int *))
 
static int _ferr __PR ((char *, double))
 
EXPORT int ftoes (register char *s, MDOUBLE val, register int fieldwidth, register int ndigits)
 
EXPORT int ftofs (register char *s, MDOUBLE val, register int fieldwidth, register int ndigits)
 
LOCAL int _ferr (char *s, double val)
 

Variables

static char _js_nan [] = "(NaN)"
 
static char _js_inf [] = "(Infinity)"
 

Macro Definition Documentation

#define abs (   i)    ((i) < 0 ? -(i) : (i))

Definition at line 206 of file fconv.c.

Referenced by Advanced_LoadTree(), BaseControlVideoImpl_get_VideoHeight(), BezierCheck(), BITMAP_CopyBitmap(), bmi_has_alpha(), BmpFrameDecode_GetSize(), BmpFrameDecode_ReadRLE4(), BmpFrameDecode_ReadRLE8(), BmpFrameDecode_ReadUncompressed(), Brush(), check_exe(), check_file_time(), CheckListWndProc(), cmp_font_metrics(), co_IntProcessMouseMessage(), co_IntSetScrollInfo(), color_match(), colour_match(), compare_float(), compareTime(), ComponentFactory_CreateBitmapFromHICON(), CreateDIBitmap(), DC_vFixIsotropicMapping(), decode_frame_wic(), DIB_BltFromVGA(), DIB_CreateDIBSection(), DIB_XXBPP_StretchBlt(), DRIVER_RestoreDC(), DrvSetPointerShape(), DrvTransparentBlt(), EDIT_EM_ReplaceSel(), EDIT_GetCompositionStr(), EMF_RestoreDC(), Erase(), expand_macro(), ftGdiGetGlyphOutline(), ftoes(), GdiGetBitmapBitsSize(), GdipCreateBitmapFromGdiDib(), GdipCreateBitmapFromHBITMAP(), GdipCreateBitmapFromHICON(), GdipCreateBitmapFromScan0(), get_dib_image_size(), get_dib_size(), get_image_part_size(), get_palette_index(), GetOutlineTextMetricsW(), GraphCtrl_InvalidateCtrl(), GreCreateDIBitmapFromPackedDIB(), HEADER_IsDragDistance(), HexEditWndProc(), ICImageDecompress(), ICO_ExtractIconExW(), ImageList_DragMove(), CMathTest::import_checks(), InitBitmap(), IntArc(), IntCreateCompatibleBitmap(), IntCreateDIBitmap(), IntCreateStockPen(), IntDrawRoundRect(), IntEngGradientFillRect(), IntFillRoundRect(), IntGdiExtCreatePen(), IntGetMonitorsFromRect(), IntRoundRect(), IntSynthesizeDib(), is_equal_rect(), JOY_Timer(), joystick_map_axis(), KeSetBasePriorityThread(), LISTBOX_SetHorizontalPos(), LISTVIEW_ScrollOnInsert(), LISTVIEW_ShiftIndices(), LookupIconIdFromDirectoryEx(), match_off_by_n(), MatrixWndProc(), ME_CalculateClickCount(), ME_RTFSpecialCharHook(), ME_ScrollAbs(), mixer_test_controlA(), mixer_test_controlW(), MSZipCodecUncompress(), near_match(), audio_waveout::nsample(), audio_wavein::nsample(), NtGdiCreateRoundRectRgn(), NtGdiGetBitmapBits(), NtGdiSetDIBitsToDeviceInternal(), NtGdiStretchDIBitsInternal(), CGridView::OnVScroll(), OnVScroll(), PATH_RoundRect(), PlayEnhMetaFileRecord(), POLYGONFILL_MakeEdge(), CardRegion::PrepareDragBitmaps(), CardRegion::PrepareDragBitmapsThreed(), RawCodecUncompress(), REBAR_MouseMove(), REGION_bMakeFrameRegion(), regularize(), CardRegion::Render(), Replace(), roundTo8Directions(), s_sum_L1_norms(), ScreenSaverProc(), ScriptXtoCP(), SetDIBits(), SOFTWARE_GdipDrawThinPath(), stripe_next_unit(), surface_blt_fbo(), surface_is_full_rect(), synthesize_dib(), tanhT(), tanT(), taskdialog_add_buttons(), test_atan2(), test_bitmap_font_metrics(), test_clock(), test_cos(), test_device_caps(), test_dib_info(), Test_ExtCreatePen_Expect(), test_fullscreen(), test_ifont_size(), test_length(), test_rotate(), Test_SetDIBitsToDevice_Params(), test_sin(), test_tan(), test_text_metrics(), test_timers(), test_timers_no_wnd(), test_unit(), TEXT_TabbedTextOut(), TextIntGetTextExtentPoint(), ValarrayTest::transcendentals(), UnsafeSetBitmapBits(), UPDOWN_MouseWheel(), UXTHEME_DrawImageBackground(), UXTHEME_StretchBlt(), vncLookupColour(), wave_out_play(), weld_dec3n(), weld_short2(), weld_short4(), wglUseFontOutlines_common(), wined3d_find_closest_matching_adapter_mode(), and xmlreader_GetValue().

#define isinf (   val)    (0)

Definition at line 129 of file fconv.c.

Referenced by _ferr().

#define isnan (   val)    (0)

Definition at line 124 of file fconv.c.

Referenced by _ferr().

#define MDOUBLE   double

Definition at line 200 of file fconv.c.

#define NO_ISINF

Definition at line 130 of file fconv.c.

#define NO_ISNAN

Definition at line 125 of file fconv.c.

Function Documentation

char* ecvt __PR ( (double, int, int *, int *)  )
static int _ferr __PR ( (char *, double )
static
LOCAL int _ferr ( char s,
double  val 
)

Definition at line 397 of file fconv.c.

Referenced by ftoes(), and ftofs().

400 {
401  if (isnan(val)) {
402  strcpy(s, _js_nan);
403  return (sizeof (_js_nan) - 1);
404  }
405 
406  /*
407  * Check first for NaN because finite() will return 1 on Nan too.
408  */
409  if (isinf(val)) {
410  strcpy(s, _js_inf);
411  return (sizeof (_js_inf) - 1);
412  }
413  return (0);
414 }
#define isnan(val)
Definition: fconv.c:124
static char _js_nan[]
Definition: fconv.c:189
GLuint GLfloat * val
Definition: glext.h:7180
static char _js_inf[]
Definition: fconv.c:190
GLdouble s
Definition: gl.h:2039
#define isinf(val)
Definition: fconv.c:129
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
EXPORT int ftoes ( register char s,
MDOUBLE  val,
register int  fieldwidth,
register int  ndigits 
)

Definition at line 209 of file fconv.c.

Referenced by for().

214 {
215  register char *b;
216  register char *rs;
217  register int len;
218  register int rdecpt;
219  int decpt;
220  int sign;
221 
222 #ifndef __DO_LONG_DOUBLE__
223  if ((len = _ferr(s, val)) > 0)
224  return (len);
225 #endif
226  rs = s;
227 #ifdef V7_FLOATSTYLE
228  b = ecvt(val, ndigits, &decpt, &sign);
229  rdecpt = decpt;
230 #else
231  b = ecvt(val, ndigits+1, &decpt, &sign);
232  rdecpt = decpt-1;
233 #endif
234 #ifdef __DO_LONG_DOUBLE__
235  len = *b;
236  if (len < '0' || len > '9') { /* Inf/NaN */
237  strcpy(s, b);
238  return (strlen(b));
239  }
240 #endif
241  len = ndigits + 6; /* Punkt e +/- nnn */
242  if (sign)
243  len++;
244  if (fieldwidth > len)
245  while (fieldwidth-- > len)
246  *rs++ = ' ';
247  if (sign)
248  *rs++ = '-';
249 #ifndef V7_FLOATSTYLE
250  if (*b)
251  *rs++ = *b++;
252 #endif
253 #if defined(HAVE_LOCALECONV) && defined(USE_LOCALE)
254  *rs++ = *(localeconv()->decimal_point);
255 #else
256  *rs++ = '.';
257 #endif
258  while (*b && ndigits-- > 0)
259  *rs++ = *b++;
260  *rs++ = 'e';
261  *rs++ = rdecpt >= 0 ? '+' : '-';
262  rdecpt = abs(rdecpt);
263 #ifdef __DO_LONG_DOUBLE__
264  if (rdecpt >= 1000) { /* Max-Exp is > 4000 */
265  *rs++ = rdecpt / 1000 + '0';
266  rdecpt %= 1000;
267  }
268 #endif
269 #ifndef V7_FLOATSTYLE
270  if (rdecpt >= 100)
271 #endif
272  {
273  *rs++ = rdecpt / 100 + '0';
274  rdecpt %= 100;
275  }
276  *rs++ = rdecpt / 10 + '0';
277  *rs++ = rdecpt % 10 + '0';
278  *rs = '\0';
279  return (rs - s);
280 }
static size_t double int int int * sign
Definition: printf.c:64
#define abs(i)
Definition: fconv.c:206
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static size_t double int int * decpt
Definition: printf.c:64
static size_t double int ndigits
Definition: printf.c:64
#define b
Definition: ke_i.h:79
GLuint GLfloat * val
Definition: glext.h:7180
_Check_return_ _CRTIMP char *__cdecl ecvt(_In_ double _Val, _In_ int _NumOfDigits, _Out_ int *_PtDec, _Out_ int *_PtSign)
GLdouble s
Definition: gl.h:2039
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP struct lconv *__cdecl localeconv(void)
Definition: locale.c:601
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LOCAL int _ferr(char *s, double val)
Definition: fconv.c:397
EXPORT int ftofs ( register char s,
MDOUBLE  val,
register int  fieldwidth,
register int  ndigits 
)

Definition at line 290 of file fconv.c.

Referenced by for().

295 {
296  register char *b;
297  register char *rs;
298  register int len;
299  register int rdecpt;
300  int decpt;
301  int sign;
302 
303 #ifndef __DO_LONG_DOUBLE__
304  if ((len = _ferr(s, val)) > 0)
305  return (len);
306 #endif
307  rs = s;
308 #ifdef USE_ECVT
309  /*
310  * Needed on systems with broken fcvt() implementation
311  * (e.g. Cygwin32)
312  */
313  b = ecvt(val, ndigits, &decpt, &sign);
314  /*
315  * The next call is needed to force higher precision.
316  */
317  if (decpt > 0)
318  b = ecvt(val, ndigits+decpt, &decpt, &sign);
319 #else
320  b = fcvt(val, ndigits, &decpt, &sign);
321 #endif
322 #ifdef __DO_LONG_DOUBLE__
323  len = *b;
324  if (len < '0' || len > '9') { /* Inf/NaN */
325  strcpy(s, b);
326  return (strlen(b));
327  }
328 #endif
329  rdecpt = decpt;
330  len = rdecpt + ndigits + 1;
331  if (rdecpt < 0)
332  len -= rdecpt;
333  if (sign)
334  len++;
335  if (fieldwidth > len)
336  while (fieldwidth-- > len)
337  *rs++ = ' ';
338  if (sign)
339  *rs++ = '-';
340  if (rdecpt > 0) {
341  len = rdecpt;
342  while (*b && len-- > 0)
343  *rs++ = *b++;
344 #ifdef USE_ECVT
345  while (len-- > 0)
346  *rs++ = '0';
347 #endif
348  }
349 #ifndef V7_FLOATSTYLE
350  else {
351  *rs++ = '0';
352  }
353 #endif
354 #if defined(HAVE_LOCALECONV) && defined(USE_LOCALE)
355  *rs++ = *(localeconv()->decimal_point);
356 #else
357  *rs++ = '.';
358 #endif
359  if (rdecpt < 0) {
360  len = rdecpt;
361  while (len++ < 0 && ndigits-- > 0)
362  *rs++ = '0';
363  }
364  while (*b && ndigits-- > 0)
365  *rs++ = *b++;
366 #ifdef USE_ECVT
367  while (ndigits-- > 0)
368  *rs++ = '0';
369 #endif
370  *rs = '\0';
371  return (rs - s);
372 }
static size_t double int int int * sign
Definition: printf.c:64
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static size_t double int int * decpt
Definition: printf.c:64
_Check_return_ _CRTIMP char *__cdecl fcvt(_In_ double _Val, _In_ int _NumOfDec, _Out_ int *_PtDec, _Out_ int *_PtSign)
static size_t double int ndigits
Definition: printf.c:64
#define b
Definition: ke_i.h:79
GLuint GLfloat * val
Definition: glext.h:7180
_Check_return_ _CRTIMP char *__cdecl ecvt(_In_ double _Val, _In_ int _NumOfDigits, _Out_ int *_PtDec, _Out_ int *_PtSign)
GLdouble s
Definition: gl.h:2039
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP struct lconv *__cdecl localeconv(void)
Definition: locale.c:601
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
LOCAL int _ferr(char *s, double val)
Definition: fconv.c:397

Variable Documentation

char _js_inf[] = "(Infinity)"
static

Definition at line 190 of file fconv.c.

char _js_nan[] = "(NaN)"
static

Definition at line 189 of file fconv.c.