Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-160 Excluding Merge-Ins
This is equivalent to a diff from 67062d71c0 to 5b54e4c576
2019-04-14
| ||
14:15 | Implement TIP 160 check-in: 42f24469aa user: dkf tags: core-8-branch | |
2019-04-08
| ||
13:01 | Fix for [45b9faf103f2], [try] interaction with local variable names produces segmentation fault. check-in: 4100488a3c user: pooryorick tags: core-8-branch | |
2019-04-07
| ||
14:45 | Merge 8.7, and fix test-case set-old-8.6 check-in: f511fa47d2 user: jan.nijtmans tags: tip-224 | |
14:39 | Merge 8.7, and fix build problem on Windows Closed-Leaf check-in: 5b54e4c576 user: jan.nijtmans tags: tip-160 | |
2019-04-06
| ||
20:41 | Merge 8.7. Add checks for libtommath library to configure script (experimental) check-in: b7a7b29452 user: jan.nijtmans tags: digit-bit-60 | |
2019-04-05
| ||
21:29 | Merge 8.7 check-in: a6c2ae2927 user: jan.nijtmans tags: trunk | |
21:15 | Merge 8.6 check-in: 67062d71c0 user: jan.nijtmans tags: core-8-branch | |
20:56 | Take over recent improvements from libtommath after version 1.1.0. check-in: 57da792f43 user: jan.nijtmans tags: core-8-6-branch | |
2019-04-02
| ||
18:23 | merge-mark check-in: 5b3cc9e2a9 user: jan.nijtmans tags: core-8-branch | |
2019-04-01
| ||
16:15 | typos check-in: 43e01869e4 user: dgp tags: tip-160 | |
Changes to doc/open.n.
︙ | |||
162 163 164 165 166 167 168 | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | - - + + + | .SH "SERIAL COMMUNICATIONS" .PP If \fIfileName\fR refers to a serial port, then the specified serial port is opened and initialized in a platform-dependent manner. Acceptable values for the \fIfileName\fR to use to open a serial port are described in the PORTABILITY ISSUES section. .PP |
︙ | |||
244 245 246 247 248 249 250 251 252 253 254 255 256 257 | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | .TP \fB\-xchar\fR \fI{xonChar xoffChar}\fR . (Windows and Unix). This option is used to query or change the software handshake characters. Normally the operating system default should be DC1 (0x11) and DC3 (0x13) representing the ASCII standard XON and XOFF characters. .TP \fB\-closemode\fR \fIcloseMode\fR .VS "8.7, TIP 160" (Windows and Unix). This option is used to query or change the close mode of the serial channel, which defines how pending output in operating system buffers is handled when the channel is closed. The following values for \fIcloseMode\fR are supported: .RS .TP \fBdefault\fR . indicates that a system default operation should be used; all serial channels default to this. .TP \fBdiscard\fR . indicates that the contents of the OS buffers should be discarded. Note that this is \fInot recommended\fR when writing to a POSIX terminal, as it can interact unexpectedly with handling of \fBstderr\fR. .TP \fBdrain\fR . indicates that Tcl should wait when closing the channel until all output has been consumed. This may slow down \fBclose\fR noticeably. .RE .VE "8.7, TIP 160" .TP \fB\-inputmode\fR \fIinputMode\fR .VS "8.7, TIP 160" (Unix only; Windows has the equivalent option on console channels). This option is used to query or change the input mode of the serial channel under the assumption that it is talking to a terminal, which controls how interactive input from users is handled. The following values for \fIinputMode\fR are supported: .RS .TP \fBnormal\fR . indicates that normal line-oriented input should be used, with standard terminal editing capabilities enabled. .TP \fBpassword\fR . indicates that non-echoing input should be used, with standard terminal editing capabilities enabled but no writing of typed characters to the terminal (except for newlines). Some terminals may indicate this specially. .TP \fBraw\fR . indicates that all keyboard input should be given directly to Tcl with the terminal doing no processing at all. It does not echo the keys, leaving it up to the Tcl script to interpret what to do. .TP \fBreset\fR (set only) . indicates that the terminal should be reset to what state it was in when the terminal was opened. .PP Note that setting this option (technically, anything that changes the terminal state from its initial value \fIvia this option\fR) will cause the channel to turn on an automatic reset of the terminal when the channel is closed. .RE .TP \fB\-winsize\fR . (Unix only; Windows has the equivalent option on console channels). This option is query only. It retrieves a two-element list with the the current width and height of the terminal. .VE "8.7, TIP 160" .TP \fB\-pollinterval\fR \fImsec\fR . (Windows only). This option is used to set the maximum time between polling for fileevents. This affects the time interval between checking for events throughout the Tcl interpreter (the smallest value always wins). Use this option only if |
︙ | |||
271 272 273 274 275 276 277 | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | - + | \fB\-lasterror\fR . (Windows only). This option is query only. In case of a serial communication error, \fBread\fR or \fBputs\fR returns a general Tcl file I/O error. \fBfconfigure\fR \fB\-lasterror\fR can be called to get a list of error details. See below for an explanation of the various error codes. |
︙ | |||
312 313 314 315 316 317 318 | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | - + | .IP \fBBREAK\fR A BREAK condition is not a hardware signal line, but a logical zero on the TXD or RXD lines for a long period of time, usually 250 to 500 milliseconds. Normally a receive or transmit data signal stays at the mark (on=1) voltage until the next character is transferred. A BREAK is sometimes used to reset the communications line or change the operating mode of communications hardware. |
︙ | |||
355 356 357 358 359 360 361 | 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | - + | A stop-bit error has been detected by your UART. Wrong mode settings with \fBfconfigure\fR \fB\-mode\fR or a noisy data line (RXD) may cause this error. .TP 10 \fBBREAK\fR . A BREAK condition has been detected by your UART (see above). |
︙ | |||
404 405 406 407 408 409 410 | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + | not accessing the console, or if the command pipeline does not use standard input, but is redirected from a file, then the above problem does not occur. .RE .PP See the \fBPORTABILITY ISSUES\fR section of the \fBexec\fR command for additional information not specific to command pipelines about executing applications on the various platforms .SH "CONSOLE CHANNELS" .VS "8.7, TIP 160" On Windows only, console channels (usually \fBstdin\fR or \fBstdout\fR) support the following options: .TP \fB\-inputmode\fR \fIinputMode\fR . This option is used to query or change the input mode of the console channel, which controls how interactive input from users is handled. The following values for \fIinputMode\fR are supported: .RS .TP \fBnormal\fR . indicates that normal line-oriented input should be used, with standard console editing capabilities enabled. .TP \fBpassword\fR . indicates that non-echoing input should be used, with standard console editing capabilitied enabled but no writing of typed characters to the terminal (except for newlines). .TP \fBraw\fR . indicates that all keyboard input should be given directly to Tcl with the console doing no processing at all. It does not echo the keys, leaving it up to the Tcl script to interpret what to do. .TP \fBreset\fR (set only) . indicates that the console should be reset to what state it was in when the console channel was opened. .PP Note that setting this option (technically, anything that changes the console state from its default \fIvia this option\fR) will cause the channel to turn on an automatic reset of the console when the channel is closed. .RE .TP \fB\-winsize\fR . This option is query only. It retrieves a two-element list with the the current width and height of the console that this channel is talking to. .PP Note that the equivalent options exist on Unix, but are on the serial channel type. .VE "8.7, TIP 160" |
Changes to tests/ioCmd.test.
︙ | |||
202 203 204 205 206 207 208 | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | + + + + + + + + - - - - - - - - - - + + + + + + + + + + + - + + - + - - - - - - - - + + + + + + + + - - + + + - - - + + + + - + - + - - - + + + - - + + + - - - - - + + + + - + - - - + + + + - - + - - - + + + + - - + - - - + + + + - - + | set chan [open [info script] r] } -body { chan close $chan write } -cleanup { close $chan } -returnCodes error -result "Half-close of write-side not possible, side not opened or already closed" proc expectedOpts {got extra} { set basicOpts { -blocking -buffering -buffersize -encoding -eofchar -translation } set opts [list {*}$basicOpts {*}$extra] lset opts end [string cat "or " [lindex $opts end]] return [format {bad option "%s": should be one of %s} $got [join $opts ", "]] } |
︙ | |||
333 334 335 336 337 338 339 | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | - + + + + + + + - + | # might fail if /dev/ttya is unavailable set tty [open /dev/ttya] fconfigure $tty -blah blih } -cleanup { if {$tty ne ""} { close $tty } |
︙ |
Changes to unix/configure.
︙ | |||
9451 9452 9453 9454 9455 9456 9457 | 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 | - + - + | else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $langinfo_ok" >&5 $as_echo "$langinfo_ok" >&6; } fi #-------------------------------------------------------------------- |
︙ |
Changes to unix/configure.ac.
︙ | |||
549 550 551 552 553 554 555 | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | - + - + | #-------------------------------------------------------------------- # Check for support of nl_langinfo function #-------------------------------------------------------------------- SC_ENABLE_LANGINFO #-------------------------------------------------------------------- |
︙ |
Changes to unix/tclUnixChan.c.
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | + + + + + + + + + + - + + + + + + + + + + + + + + - + | # endif /* !CRTSCTS&CNEW_RTSCTS */ # if !defined(PAREXT) && defined(CMSPAR) # define PAREXT CMSPAR # endif /* !PAREXT&&CMSPAR */ #endif /* HAVE_TERMIOS_H */ /* * The bits supported for describing the closeMode field of TtyState. */ enum CloseModeBits { CLOSE_DEFAULT, CLOSE_DRAIN, CLOSE_DISCARD }; /* * Helper macros to make parts of this file clearer. The macros do exactly * what they say on the tin. :-) They also only ever refer to their arguments * once, and so can be used without regard to side effects. */ #define SET_BITS(var, bits) ((var) |= (bits)) #define CLEAR_BITS(var, bits) ((var) &= ~(bits)) /* |
︙ | |||
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | + + | int mode, int *errorCode); static int FileTruncateProc(ClientData instanceData, Tcl_WideInt length); static Tcl_WideInt FileWideSeekProc(ClientData instanceData, Tcl_WideInt offset, int mode, int *errorCode); static void FileWatchProc(ClientData instanceData, int mask); #ifdef SUPPORTS_TTY static int TtyCloseProc(ClientData instanceData, Tcl_Interp *interp); static void TtyGetAttributes(int fd, TtyAttrs *ttyPtr); static int TtyGetOptionProc(ClientData instanceData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); static int TtyGetBaud(speed_t speed); static speed_t TtyGetSpeed(int baud); static void TtyInit(int fd); |
︙ | |||
158 159 160 161 162 163 164 | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | - + | * This structure describes the channel type structure for serial IO. * Note that this type is a subclass of the "file" type. */ static const Tcl_ChannelType ttyChannelType = { "tty", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ |
︙ | |||
306 307 308 309 310 311 312 | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | - + - - + + + | *errorCodePtr = errno; return -1; } /* *---------------------------------------------------------------------- * |
︙ | |||
343 344 345 346 347 348 349 350 351 352 353 354 355 356 | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if (close(fsPtr->fd) < 0) { errorCode = errno; } } ckfree(fsPtr); return errorCode; } #ifdef SUPPORTS_TTY static int TtyCloseProc( ClientData instanceData, Tcl_Interp *interp) { TtyState *ttyPtr = instanceData; /* * If we've been asked by the user to drain or flush, do so now. */ switch (ttyPtr->closeMode) { case CLOSE_DRAIN: tcdrain(ttyPtr->fileState.fd); break; case CLOSE_DISCARD: tcflush(ttyPtr->fileState.fd, TCIOFLUSH); break; default: /* Do nothing */ break; } /* * If we've had our state changed from the default, reset now. */ if (ttyPtr->doReset) { tcsetattr(ttyPtr->fileState.fd, TCSANOW, &ttyPtr->initState); } /* * Delegate to close for files. */ return FileCloseProc(instanceData, interp); } #endif /* SUPPORTS_TTY */ /* *---------------------------------------------------------------------- * * FileSeekProc -- * * This function is called by the generic IO level to move the access |
︙ | |||
574 575 576 577 578 579 580 | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | - + | static int TtySetOptionProc( ClientData instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Which option to set? */ const char *value) /* New value for option. */ { |
︙ | |||
597 598 599 600 601 602 603 | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | - + - + | return TCL_ERROR; } /* * system calls results should be checked there. - dl */ |
︙ | |||
641 642 643 644 645 646 647 | 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | - + | "bad value for -handshake: must be one of" " xonxoff, rtscts, dtrdsr or none", -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "VALUE", NULL); } return TCL_ERROR; } |
︙ | |||
664 665 666 667 668 669 670 | 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 | - + - + - + - + | " two elements with each a single 8-bit character", -1)); Tcl_SetErrorCode(interp, "TCL", "VALUE", "XCHAR", NULL); } ckfree(argv); return TCL_ERROR; } |
︙ | |||
729 730 731 732 733 734 735 | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 | - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "VALUE", NULL); } ckfree(argv); return TCL_ERROR; } |
︙ | |||
809 810 811 812 813 814 815 | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + | static int TtyGetOptionProc( ClientData instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Option to get. */ Tcl_DString *dsPtr) /* Where to store value(s). */ { |
︙ | |||
869 870 871 872 873 874 875 | 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 | - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | * returned by unnamed [fconfigure chan]. */ if ((len > 1) && (strncmp(optionName, "-queue", len) == 0)) { int inQueue=0, outQueue=0, inBuffered, outBuffered; valid = 1; |
︙ | |||
1371 1372 1373 1374 1375 1376 1377 | 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 | - + | * NULL. */ Tcl_Obj *pathPtr, /* Name of file to open. */ int mode, /* POSIX open mode. */ int permissions) /* If the open involves creating a file, with * what modes to create it? */ { int fd, channelPermissions; |
︙ | |||
1427 1428 1429 1430 1431 1432 1433 | 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 | - - + + - - - - - + + + + + + + + + + + + - - - + + + - + | /* * Set close-on-exec flag on the fd so that child processes will not * inherit this fd. */ fcntl(fd, F_SETFD, FD_CLOEXEC); |
︙ | |||
1503 1504 1505 1506 1507 1508 1509 | 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 | - + - - - + + + + - - - - + + + + + + + + + - - + + + + | Tcl_Channel Tcl_MakeFileChannel( ClientData handle, /* OS level handle. */ int mode) /* ORed combination of TCL_READABLE and * TCL_WRITABLE to indicate file mode. */ { |
︙ |
Changes to win/tclWinConsole.c.
︙ | |||
27 28 29 30 31 32 33 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | - - + + + + | TCL_DECLARE_MUTEX(consoleMutex) /* * Bit masks used in the flags field of the ConsoleInfo structure below. */ |
︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | + | int toWrite; /* Current amount to be written. Access is * synchronized with the writable object. */ int readFlags; /* Flags that are shared with the reader * thread. Access is synchronized with the * readable object. */ int bytesRead; /* Number of bytes in the buffer. */ int offset; /* Number of bytes read out of the buffer. */ DWORD initMode; /* Initial console mode. */ char buffer[CONSOLE_BUFFER_SIZE]; /* Data consumed by reader thread. */ } ConsoleInfo; typedef struct { /* * The following pointer refers to the head of the list of consoles that |
︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | + + + + + + | static void ConsoleCheckProc(ClientData clientData, int flags); static int ConsoleCloseProc(ClientData instanceData, Tcl_Interp *interp); static int ConsoleEventProc(Tcl_Event *evPtr, int flags); static void ConsoleExitHandler(ClientData clientData); static int ConsoleGetHandleProc(ClientData instanceData, int direction, ClientData *handlePtr); static int ConsoleGetOptionProc(ClientData instanceData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); static void ConsoleInit(void); static int ConsoleInputProc(ClientData instanceData, char *buf, int toRead, int *errorCode); static int ConsoleOutputProc(ClientData instanceData, const char *buf, int toWrite, int *errorCode); static DWORD WINAPI ConsoleReaderThread(LPVOID arg); static int ConsoleSetOptionProc(ClientData instanceData, Tcl_Interp *interp, const char *optionName, const char *value); static void ConsoleSetupProc(ClientData clientData, int flags); static void ConsoleWatchProc(ClientData instanceData, int mask); static DWORD WINAPI ConsoleWriterThread(LPVOID arg); static void ProcExitHandler(ClientData clientData); static int WaitForRead(ConsoleInfo *infoPtr, int blocking); static void ConsoleThreadActionProc(ClientData instanceData, int action); |
︙ | |||
171 172 173 174 175 176 177 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | - - + + | static const Tcl_ChannelType consoleChannelType = { "console", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ ConsoleCloseProc, /* Close proc. */ ConsoleInputProc, /* Input proc. */ ConsoleOutputProc, /* Output proc. */ NULL, /* Seek proc. */ |
︙ | |||
563 564 565 566 567 568 569 570 571 572 573 574 575 576 | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | + + + + + + + + + + + | TclPipeThreadStop(&consolePtr->writer.TI, consolePtr->writer.thread); CloseHandle(consolePtr->writer.thread); CloseHandle(consolePtr->writer.readyEvent); consolePtr->writer.thread = NULL; } consolePtr->validMask &= ~TCL_WRITABLE; /* * If the user has been tinkering with the mode, reset it now. We ignore * any errors from this; we're quite possibly about to close or exit * anyway. */ if ((consolePtr->flags & CONSOLE_READ_OPS) && (consolePtr->flags & CONSOLE_RESET)) { SetConsoleMode(consolePtr->handle, consolePtr->initMode); } /* * Don't close the Win32 handle if the handle is a standard channel during * the thread exit process. Otherwise, one thread may kill the stdio of * another. */ |
︙ | |||
586 587 588 589 590 591 592 | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | - + | consolePtr->watchMask &= consolePtr->validMask; /* * Remove the file from the list of watched files. */ |
︙ | |||
1328 1329 1330 1331 1332 1333 1334 | 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 | + - + + | if (permissions & TCL_READABLE) { /* * Make sure the console input buffer is ready for only character * input notifications and the buffer is set for line buffering. IOW, * we only want to catch when complete lines are ready for reading. */ infoPtr->flags |= CONSOLE_READ_OPS; |
︙ | |||
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | infoPtr->threadId = Tcl_GetChannelThread(infoPtr->channel); } } else { infoPtr->threadId = NULL; } Tcl_MutexUnlock(&consoleMutex); } /* *---------------------------------------------------------------------- * * ConsoleSetOptionProc -- * * Sets an option on a channel. * * Results: * A standard Tcl result. Also sets the interp's result on error if * interp is not NULL. * * Side effects: * May modify an option on a console. Sets Error message if needed (by * calling Tcl_BadChannelOption). * *---------------------------------------------------------------------- */ static int ConsoleSetOptionProc( ClientData instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Which option to set? */ const char *value) /* New value for option. */ { ConsoleInfo *infoPtr = instanceData; int len = strlen(optionName); int vlen = strlen(value); /* * Option -inputmode normal|password|raw */ if ((infoPtr->flags & CONSOLE_READ_OPS) && (len > 1) && (strncmp(optionName, "-inputmode", len) == 0)) { DWORD mode; if (GetConsoleMode(infoPtr->handle, &mode) == 0) { TclWinConvertError(GetLastError()); if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read console mode: %s", Tcl_PosixError(interp))); } return TCL_ERROR; } if (Tcl_UtfNcasecmp(value, "NORMAL", vlen) == 0) { mode |= ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT; } else if (Tcl_UtfNcasecmp(value, "PASSWORD", vlen) == 0) { mode |= ENABLE_LINE_INPUT; mode &= ~ENABLE_ECHO_INPUT; } else if (Tcl_UtfNcasecmp(value, "RAW", vlen) == 0) { mode &= ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT); } else if (Tcl_UtfNcasecmp(value, "RESET", vlen) == 0) { /* * Reset to the initial mode, whatever that is. */ mode = infoPtr->initMode; } else { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad mode \"%s\" for -inputmode: must be" " normal, password, raw, or reset", value)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "VALUE", NULL); } return TCL_ERROR; } if (SetConsoleMode(infoPtr->handle, mode) == 0) { TclWinConvertError(GetLastError()); if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't set console mode: %s", Tcl_PosixError(interp))); } return TCL_ERROR; } /* * If we've changed the mode from default, schedule a reset later. */ if (mode == infoPtr->initMode) { infoPtr->flags &= ~CONSOLE_RESET; } else { infoPtr->flags |= CONSOLE_RESET; } return TCL_OK; } if (infoPtr->flags & CONSOLE_READ_OPS) { return Tcl_BadChannelOption(interp, optionName, "inputmode"); } else { return Tcl_BadChannelOption(interp, optionName, ""); } } /* *---------------------------------------------------------------------- * * ConsoleGetOptionProc -- * * Gets a mode associated with an IO channel. If the optionName arg is * non-NULL, retrieves the value of that option. If the optionName arg is * NULL, retrieves a list of alternating option names and values for the * given channel. * * Results: * A standard Tcl result. Also sets the supplied DString to the string * value of the option(s) returned. Sets error message if needed * (by calling Tcl_BadChannelOption). * *---------------------------------------------------------------------- */ static int ConsoleGetOptionProc( ClientData instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Option to get. */ Tcl_DString *dsPtr) /* Where to store value(s). */ { ConsoleInfo *infoPtr = instanceData; int valid = 0; /* Flag if valid option parsed. */ unsigned int len; char buf[TCL_INTEGER_SPACE]; if (optionName == NULL) { len = 0; } else { len = strlen(optionName); } /* * Get option -inputmode * * This is a great simplification of the underlying reality, but actually * represents what almost all scripts really want to know. */ if (infoPtr->flags & CONSOLE_READ_OPS) { if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-inputmode"); } if (len==0 || (len>1 && strncmp(optionName, "-inputmode", len)==0)) { DWORD mode; valid = 1; if (GetConsoleMode(infoPtr->handle, &mode) == 0) { TclWinConvertError(GetLastError()); if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read console mode: %s", Tcl_PosixError(interp))); } return TCL_ERROR; } if (mode & ENABLE_LINE_INPUT) { if (mode & ENABLE_ECHO_INPUT) { Tcl_DStringAppendElement(dsPtr, "normal"); } else { Tcl_DStringAppendElement(dsPtr, "password"); } } else { Tcl_DStringAppendElement(dsPtr, "raw"); } } } /* * Get option -winsize * Option is readonly and returned by [fconfigure chan -winsize] but not * returned by [fconfigure chan] without explicit option name. */ if ((len > 1) && (strncmp(optionName, "-winsize", len) == 0)) { CONSOLE_SCREEN_BUFFER_INFO consoleInfo; valid = 1; if (!GetConsoleScreenBufferInfo(infoPtr->handle, &consoleInfo)) { TclWinConvertError(GetLastError()); if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read console size: %s", Tcl_PosixError(interp))); } return TCL_ERROR; } sprintf(buf, "%d", consoleInfo.srWindow.Right - consoleInfo.srWindow.Left + 1); Tcl_DStringAppendElement(dsPtr, buf); sprintf(buf, "%d", consoleInfo.srWindow.Bottom - consoleInfo.srWindow.Top + 1); Tcl_DStringAppendElement(dsPtr, buf); } if (valid) { return TCL_OK; } if (infoPtr->flags & CONSOLE_READ_OPS) { return Tcl_BadChannelOption(interp, optionName, "inputmode winsize"); } else { return Tcl_BadChannelOption(interp, optionName, ""); } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to win/tclWinSerial.c.
︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | + + + + + + + + + | /* * Bit masks used in the sharedFlags field of the SerialInfo structure below. */ #define SERIAL_EOF (1<<2) /* Serial has reached EOF. */ #define SERIAL_ERROR (1<<4) /* * Bit masks used for noting whether to drain or discard output on close. They * are disjoint from each other; at most one may be set at a time. */ #define SERIAL_CLOSE_DRAIN (1<<6) /* Drain all output on close. */ #define SERIAL_CLOSE_DISCARD (1<<7) /* Discard all output on close. */ #define SERIAL_CLOSE_MASK (3<<6) /* Both two bits above. */ /* * Default time to block between checking status on the serial port. */ #define SERIAL_DEFAULT_BLOCKTIME 10 /* 10 msec */ /* |
︙ | |||
600 601 602 603 604 605 606 | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | - | if (serialPtr->validMask & TCL_READABLE) { PurgeComm(serialPtr->handle, PURGE_RXABORT | PURGE_RXCLEAR); CloseHandle(serialPtr->osRead.hEvent); } serialPtr->validMask &= ~TCL_READABLE; if (serialPtr->writeThread) { |
︙ | |||
1274 1275 1276 1277 1278 1279 1280 | 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 | - + | /* * Wait for the main thread to signal before attempting to write. */ if (!TclPipeThreadWaitForSignal(&pipeTI)) { /* exit */ break; } |
︙ | |||
1338 1339 1340 1341 1342 1343 1344 | 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 | + + + + + + + + + + + + + + + + - + + + | */ Tcl_ThreadAlert(infoPtr->threadId); } Tcl_MutexUnlock(&serialMutex); } /* * We're about to close, so do any drain or discard required. */ if (infoPtr) { switch (infoPtr->flags & SERIAL_CLOSE_MASK) { case SERIAL_CLOSE_DRAIN: FlushFileBuffers(infoPtr->handle); break; case SERIAL_CLOSE_DISCARD: PurgeComm(infoPtr->handle, PURGE_TXABORT | PURGE_TXCLEAR); break; } } /* |
︙ | |||
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 | 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 | + + + + + + + + + + + + + + + + + + + + + + + + + + | /* * Parse options. This would be far easier if we had Tcl_Objs to work with * as that would let us use Tcl_GetIndexFromObj()... */ len = strlen(optionName); vlen = strlen(value); /* * Option -closemode drain|discard|default */ if ((len > 2) && (strncmp(optionName, "-closemode", len) == 0)) { if (Tcl_UtfNcasecmp(value, "DEFAULT", vlen) == 0) { infoPtr->flags &= ~SERIAL_CLOSE_MASK; } else if (Tcl_UtfNcasecmp(value, "DRAIN", vlen) == 0) { infoPtr->flags &= ~SERIAL_CLOSE_MASK; infoPtr->flags |= SERIAL_CLOSE_DRAIN; } else if (Tcl_UtfNcasecmp(value, "DISCARD", vlen) == 0) { infoPtr->flags &= ~SERIAL_CLOSE_MASK; infoPtr->flags |= SERIAL_CLOSE_DISCARD; } else { if (interp) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad mode \"%s\" for -closemode: must be" " default, discard, or drain", value)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "FCONFIGURE", "VALUE", NULL); } return TCL_ERROR; } return TCL_OK; } /* * Option -mode baud,parity,databits,stopbits */ if ((len > 2) && (strncmp(optionName, "-mode", len) == 0)) { if (!GetCommState(infoPtr->handle, &dcb)) { |
︙ | |||
1934 1935 1936 1937 1938 1939 1940 | 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 | - + + | return TCL_ERROR; } return TCL_OK; } return Tcl_BadChannelOption(interp, optionName, |
︙ | |||
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 | 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 | + + + + + + + + + + + + + + + + + + + + + | infoPtr = (SerialInfo *) instanceData; if (optionName == NULL) { len = 0; } else { len = strlen(optionName); } /* * Get option -closemode */ if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-closemode"); } if (len==0 || (len>1 && strncmp(optionName, "-closemode", len)==0)) { switch (infoPtr->flags & SERIAL_CLOSE_MASK) { case SERIAL_CLOSE_DRAIN: Tcl_DStringAppendElement(dsPtr, "drain"); break; case SERIAL_CLOSE_DISCARD: Tcl_DStringAppendElement(dsPtr, "discard"); break; default: Tcl_DStringAppendElement(dsPtr, "default"); break; } } /* * Get option -mode */ if (len == 0) { Tcl_DStringAppendElement(dsPtr, "-mode"); |
︙ | |||
2170 2171 2172 2173 2174 2175 2176 | 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 | - + + | SerialModemStatusStr(status, dsPtr); } if (valid) { return TCL_OK; } return Tcl_BadChannelOption(interp, optionName, |
︙ |