summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-03-24 15:52:42 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-03-24 15:52:42 (GMT)
commite30a832a0e2040dd682f2e77c6d26043e0829d80 (patch)
tree422f4d2326d1d9efae447878c3a465fe4c449779 /generic
parent1749f80a0818eb09d3657e5d1c9038c031d9e30e (diff)
downloadtcl-e30a832a0e2040dd682f2e77c6d26043e0829d80.zip
tcl-e30a832a0e2040dd682f2e77c6d26043e0829d80.tar.gz
tcl-e30a832a0e2040dd682f2e77c6d26043e0829d80.tar.bz2
Supply more C99-compatible (and MSVC) format options: '%p' for pointers, 'z'/'j'/'I' for size_t/intptr_diff, 'j'/'q' for long long. Also add "I32" froom MSVC.
Remove TCL_LL_MODIFIER specified as "L" for Borland: This must be wrong as "L" is meant for long double. Just assume that later Borland compilers are MSVC-compatible.
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h6
-rw-r--r--generic/tclStringObj.c39
-rw-r--r--generic/tclTest.c4
3 files changed, 37 insertions, 12 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 1491745..bdb4035 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -393,11 +393,7 @@ typedef long LONG;
#if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
# if defined(_WIN32)
# define TCL_WIDE_INT_TYPE __int64
-# ifdef __BORLANDC__
-# define TCL_LL_MODIFIER "L"
-# else /* __BORLANDC__ */
-# define TCL_LL_MODIFIER "I64"
-# endif /* __BORLANDC__ */
+# define TCL_LL_MODIFIER "I64"
# elif defined(__GNUC__)
# define TCL_WIDE_INT_TYPE long long
# define TCL_LL_MODIFIER "ll"
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index c45baa1..b8b64d4 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -1865,11 +1865,22 @@ Tcl_AppendFormatToObj(
useWide = 1;
#endif
}
- } else if ((ch == 'I') && (format[1] == '6') && (format[2] == '4')) {
- format += (step + 2);
+ } else if (ch == 'I') {
+ if ((format[1] == '6') && (format[2] == '4')) {
+ format += (step + 2);
+ step = Tcl_UtfToUniChar(format, &ch);
+ useBig = 1;
+ } else if ((format[1] == '3') && (format[2] == '2')) {
+ format += (step + 2);
+ step = Tcl_UtfToUniChar(format, &ch);
+ } else {
+ format += step;
+ step = Tcl_UtfToUniChar(format, &ch);
+ }
+ } else if ((ch == 't') || (ch == 'z')) {
+ format += step;
step = Tcl_UtfToUniChar(format, &ch);
- useBig = 1;
- } else if (ch == 'L') {
+ } else if ((ch == 'q') ||(ch == 'j')) {
format += step;
step = Tcl_UtfToUniChar(format, &ch);
useBig = 1;
@@ -1925,6 +1936,7 @@ Tcl_AppendFormatToObj(
}
case 'd':
case 'o':
+ case 'p':
case 'x':
case 'X':
case 'b': {
@@ -1993,13 +2005,14 @@ Tcl_AppendFormatToObj(
segmentLimit -= 1;
}
- if (gotHash) {
+ if (gotHash || (ch == 'p')) {
switch (ch) {
case 'o':
Tcl_AppendToObj(segment, "0", 1);
segmentLimit -= 1;
precision--;
break;
+ case 'p':
case 'x':
case 'X':
Tcl_AppendToObj(segment, "0x", 2);
@@ -2078,6 +2091,7 @@ Tcl_AppendFormatToObj(
case 'u':
case 'o':
+ case 'p':
case 'x':
case 'X':
case 'b': {
@@ -2467,6 +2481,7 @@ AppendPrintfToObjVA(
case 'u':
case 'd':
case 'o':
+ case 'p':
case 'x':
case 'X':
seekingConversion = 0;
@@ -2517,7 +2532,15 @@ AppendPrintfToObjVA(
++size;
p++;
break;
- case 'L':
+ case 't':
+ case 'z':
+ if (sizeof(size_t) == sizeof(Tcl_WideInt)) {
+ size = 2;
+ }
+ p++;
+ break;
+ case 'j':
+ case 'q':
size = 2;
p++;
break;
@@ -2525,6 +2548,10 @@ AppendPrintfToObjVA(
if (p[1]=='6' && p[2]=='4') {
p += 2;
size = 2;
+ } else if (p[1]=='3' && p[2]=='2') {
+ p += 2;
+ } else if (sizeof(size_t) == sizeof(Tcl_WideInt)) {
+ size = 2;
}
p++;
break;
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 84d4ea1..0f019bb 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -3847,6 +3847,7 @@ TestprintObjCmd(
Tcl_Obj *const objv[]) /* The argument objects. */
{
Tcl_WideInt argv1 = 0;
+ size_t argv2;
if (objc < 2 || objc > 3) {
Tcl_WrongNumArgs(interp, 1, objv, "format wideint");
@@ -3855,7 +3856,8 @@ TestprintObjCmd(
if (objc > 1) {
Tcl_GetWideIntFromObj(interp, objv[2], &argv1);
}
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(Tcl_GetString(objv[1]), argv1));
+ argv2 = (size_t)argv1;
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(Tcl_GetString(objv[1]), argv1, argv2, argv2));
return TCL_OK;
}