sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // STDIO functions implemented over EPOC32 sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include <_ansi.h> sl@0: #include sl@0: sl@0: #define UNUSED_VAR(a) a = a sl@0: sl@0: extern "C" { sl@0: int e32cvt (char *buf, int buflen, double d, int width, int prec, int /*flags*/, int fchar) sl@0: { sl@0: TPtr8 res((TText8*)buf, buflen); sl@0: TBuf8<0x50> fmt; sl@0: TBool capitalE=EFalse; sl@0: switch(fchar) sl@0: { sl@0: case 'f': sl@0: fchar='f'; sl@0: break; sl@0: sl@0: case 'E': sl@0: capitalE=ETrue; // and fallthrough sl@0: case 'e': sl@0: fchar='e'; sl@0: break; sl@0: sl@0: case 'G': sl@0: capitalE=ETrue; // and fallthrough sl@0: case 'g': sl@0: fchar='g'; sl@0: break; sl@0: default: sl@0: return 0; sl@0: } sl@0: // construct a format string for use with TDes::Format - we can't use the sl@0: // VFPRINTF original because it doesn't quite match and it might involve '*' sl@0: // to read field widths from VFPRINTF arguments. sl@0: fmt.Zero(); sl@0: fmt.Append('%'); sl@0: // flags? sl@0: if (width) sl@0: fmt.AppendNum(width); sl@0: if (prec>=0) sl@0: { sl@0: fmt.Append('.'); sl@0: fmt.AppendNum(prec); sl@0: } sl@0: fmt.Append(fchar); sl@0: TRAPD(r,res.Format(fmt,d)); sl@0: UNUSED_VAR(r); sl@0: if (capitalE) sl@0: { sl@0: TInt pos=res.Locate('e'); sl@0: if (pos!=KErrNotFound) sl@0: res[pos]='E'; sl@0: } sl@0: return res.Length(); sl@0: } sl@0: }