Calc: TCHAR-izing, formatting and const-correctness
Modified: trunk/reactos/subsys/system/calc/dialog.c
Modified: trunk/reactos/subsys/system/calc/winecalc.c
Modified: trunk/reactos/subsys/system/calc/winecalc.h
_____
Modified: trunk/reactos/subsys/system/calc/dialog.c
--- trunk/reactos/subsys/system/calc/dialog.c 2005-10-05 23:52:43 UTC
(rev 18287)
+++ trunk/reactos/subsys/system/calc/dialog.c 2005-10-05 23:59:13 UTC
(rev 18288)
@@ -72,11 +72,11 @@
SetBkMode(hdc, TRANSPARENT);
- TextOut(hdc, 10, 10, c1, _tcslen(c1));
+ TextOut(hdc, 10, 10, c1, _tcslen(c1));
TextOut(hdc, 10, 35, c2, _tcslen(c2));
TextOut(hdc, 10, 50, c3, _tcslen(c3));
TextOut(hdc, 10, 75, c4, _tcslen(c4));
- TextOut(hdc, 10, 90, c5, _tcslen(c5));
+ TextOut(hdc, 10, 90, c5, _tcslen(c5));
SelectObject(hdc, hFontOrg);
_____
Modified: trunk/reactos/subsys/system/calc/winecalc.c
--- trunk/reactos/subsys/system/calc/winecalc.c 2005-10-05 23:52:43 UTC
(rev 18287)
+++ trunk/reactos/subsys/system/calc/winecalc.c 2005-10-05 23:59:13 UTC
(rev 18288)
@@ -124,9 +124,6 @@
WNDCLASS wc;
HWND hWnd;
HACCEL haccel;
-#ifdef UNICODE
- CHAR s_ansi[CALC_BUF_SIZE];
-#endif
TCHAR s[CALC_BUF_SIZE];
int r;
@@ -139,12 +136,7 @@
CALC_BUF_SIZE
);
-#ifdef UNICODE
- wcstombs(s_ansi, s, sizeof(s_ansi));
- calc.sciMode = atoi(s_ansi);
-#else
- calc.sciMode = atoi(s);
-#endif
+ calc.sciMode = _ttoi(s);
if (calc.sciMode != 0 &&
calc.sciMode != 1)
@@ -157,12 +149,7 @@
CALC_BUF_SIZE
);
-#ifdef UNICODE
- wcstombs(s_ansi, s, sizeof(s_ansi));
- calc.digitGrouping = atoi(s_ansi);
-#else
- calc.digitGrouping = atoi(s);
-#endif
+ calc.digitGrouping = _ttoi(s);
if (calc.digitGrouping != 0 &&
calc.digitGrouping != 1)
@@ -3198,38 +3185,26 @@
MessageBox(calc->hWnd, s, title, MB_OK);
}
-calcfloat calc_atof(TCHAR *s, int base)
+calcfloat calc_atof(const TCHAR *s, int base)
{
- // converts from another base to decimal calcfloat
#ifdef UNICODE
char s_ansi[128];
- wcstombs(s_ansi, s, sizeof(s_ansi));
+#endif
+
+ // converts from another base to decimal calcfloat
switch (base) {
case NBASE_DECIMAL:
+ wcstombs(s_ansi, s, sizeof(s_ansi));
return CALC_ATOF(s_ansi);
case NBASE_HEX:
- return (calcfloat)strtol(s_ansi, NULL, 16);
+ return (calcfloat)_tcstol(s, NULL, 16);
case NBASE_OCTAL:
- return (calcfloat)strtol(s_ansi, NULL, 8);
+ return (calcfloat)_tcstol(s, NULL, 8);
case NBASE_BINARY:
- return (calcfloat)strtol(s_ansi, NULL, 2);
+ return (calcfloat)_tcstol(s, NULL, 2);
default:
break;
}
-#else
- switch (base) {
- case NBASE_DECIMAL:
- return CALC_ATOF(s);
- case NBASE_HEX:
- return (calcfloat)strtol(s, NULL, 16);
- case NBASE_OCTAL:
- return (calcfloat)strtol(s, NULL, 8);
- case NBASE_BINARY:
- return (calcfloat)strtol(s, NULL, 2);
- default:
- break;
- }
-#endif
return 0L;
}
_____
Modified: trunk/reactos/subsys/system/calc/winecalc.h
--- trunk/reactos/subsys/system/calc/winecalc.h 2005-10-05 23:52:43 UTC
(rev 18287)
+++ trunk/reactos/subsys/system/calc/winecalc.h 2005-10-05 23:59:13 UTC
(rev 18288)
@@ -355,7 +355,7 @@
void show_debug(CALC *calc, TCHAR *title, long wParam, long lParam);
-calcfloat calc_atof(TCHAR *s, int base);
+calcfloat calc_atof(const TCHAR *s, int base);
void calc_ftoa(CALC *calc, calcfloat r, TCHAR *buf);
long factorial(long n);