diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-17 18:52:25 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-17 18:52:25 (GMT) |
| commit | aca8bd20f146c0567d43ae35f64ecb7e30c13aa4 (patch) | |
| tree | fce9ef422ba072a202e6b50152ec8557aec480a9 /generic/tclScan.c | |
| parent | 3013ff330e1917f7d543a69bbbc50e19ac4e8090 (diff) | |
| parent | 8afc6eacf92cf29e37c07ccf08890f85b5dc1f5a (diff) | |
| download | tcl-aca8bd20f146c0567d43ae35f64ecb7e30c13aa4.zip tcl-aca8bd20f146c0567d43ae35f64ecb7e30c13aa4.tar.gz tcl-aca8bd20f146c0567d43ae35f64ecb7e30c13aa4.tar.bz2 | |
Implement %z/%t/%q/%j size modifiers for 'scan'. Part of TIP #697
Diffstat (limited to 'generic/tclScan.c')
| -rw-r--r-- | generic/tclScan.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c index b53b29c..c143efa 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -378,6 +378,13 @@ ValidateFormat( */ switch (ch) { + case 'z': + case 't': + if (sizeof(void *) > sizeof(int)) { + flags |= SCAN_LONGER; + } + format += TclUtfToUniChar(format, &ch); + break; case 'l': if (*format == 'l') { flags |= SCAN_BIG; @@ -387,6 +394,8 @@ ValidateFormat( } /* FALLTHRU */ case 'L': + case 'j': + case 'q': flags |= SCAN_LONGER; /* FALLTHRU */ case 'h': @@ -1095,9 +1104,7 @@ Tcl_ScanObjCmd( * We create an empty Tcl_Obj to fill missing values rather than * allocating a new Tcl_Obj every time. See test scan-bigdata-XX. */ - Tcl_Obj *emptyObj; - TclNewObj(emptyObj); - Tcl_IncrRefCount(emptyObj); + Tcl_Obj *emptyObj = NULL; TclNewObj(objPtr); for (i = 0; code == TCL_OK && i < totalVars; i++) { if (objs[i] != NULL) { @@ -1108,11 +1115,12 @@ Tcl_ScanObjCmd( * More %-specifiers than matching chars, so we just spit out * empty strings for these. */ - + if (!emptyObj) { + TclNewObj(emptyObj); + } code = Tcl_ListObjAppendElement(interp, objPtr, emptyObj); } } - Tcl_DecrRefCount(emptyObj); if (code != TCL_OK) { /* If error'ed out, free up remaining. i contains last index freed */ while (++i < totalVars) { |
