@@ -83,7 +83,7 @@ typedef struct TtyAttrs {
83
83
int stop ;
84
84
} TtyAttrs ;
85
85
86
- #endif /* ! SUPPORTS_TTY */
86
+ #endif /* SUPPORTS_TTY */
87
87
88
88
#define UNSUPPORTED_OPTION (detail ) \
89
89
if (interp) { \
@@ -137,22 +137,22 @@ static int TtySetOptionProc(ClientData instanceData,
137
137
138
138
static const Tcl_ChannelType fileChannelType = {
139
139
"file" , /* Type name. */
140
- TCL_CHANNEL_VERSION_5 , /* v5 channel */
141
- FileCloseProc , /* Close proc. */
142
- FileInputProc , /* Input proc. */
143
- FileOutputProc , /* Output proc. */
144
- FileSeekProc , /* Seek proc. */
140
+ TCL_CHANNEL_VERSION_5 ,
141
+ FileCloseProc ,
142
+ FileInputProc ,
143
+ FileOutputProc ,
144
+ FileSeekProc ,
145
145
NULL , /* Set option proc. */
146
146
NULL , /* Get option proc. */
147
- FileWatchProc , /* Initialize notifier. */
148
- FileGetHandleProc , /* Get OS handles out of channel. */
149
- FileClose2Proc , /* close2proc. */
150
- FileBlockModeProc , /* Set blocking or non-blocking mode.*/
151
- NULL , /* flush proc. */
152
- NULL , /* handler proc. */
153
- FileWideSeekProc , /* wide seek proc. */
154
- NULL ,
155
- FileTruncateProc /* truncate proc. */
147
+ FileWatchProc ,
148
+ FileGetHandleProc ,
149
+ FileClose2Proc ,
150
+ FileBlockModeProc ,
151
+ NULL , /* Flush proc. */
152
+ NULL , /* Bubbled event handler proc. */
153
+ FileWideSeekProc ,
154
+ NULL , /* Thread action proc. */
155
+ FileTruncateProc
156
156
};
157
157
158
158
#ifdef SUPPORTS_TTY
@@ -162,23 +162,23 @@ static const Tcl_ChannelType fileChannelType = {
162
162
*/
163
163
164
164
static const Tcl_ChannelType ttyChannelType = {
165
- "tty" , /* Type name. */
166
- TCL_CHANNEL_VERSION_5 , /* v5 channel */
167
- FileCloseProc , /* Close proc. */
168
- FileInputProc , /* Input proc. */
169
- FileOutputProc , /* Output proc. */
165
+ "tty" ,
166
+ TCL_CHANNEL_VERSION_5 ,
167
+ FileCloseProc ,
168
+ FileInputProc ,
169
+ FileOutputProc ,
170
+ NULL , /* Seek proc. */
171
+ TtySetOptionProc ,
172
+ TtyGetOptionProc ,
173
+ FileWatchProc ,
174
+ FileGetHandleProc ,
175
+ FileClose2Proc ,
176
+ FileBlockModeProc ,
177
+ NULL , /* Flush proc. */
178
+ NULL , /* Bubbled event handler proc. */
170
179
NULL , /* Seek proc. */
171
- TtySetOptionProc , /* Set option proc. */
172
- TtyGetOptionProc , /* Get option proc. */
173
- FileWatchProc , /* Initialize notifier. */
174
- FileGetHandleProc , /* Get OS handles out of channel. */
175
- FileClose2Proc , /* close2proc. */
176
- FileBlockModeProc , /* Set blocking or non-blocking mode.*/
177
- NULL , /* flush proc. */
178
- NULL , /* handler proc. */
179
- NULL , /* wide seek proc. */
180
- NULL , /* thread action proc. */
181
- NULL /* truncate proc. */
180
+ NULL , /* Thread action proc. */
181
+ NULL /* Truncate proc. */
182
182
};
183
183
#endif /* SUPPORTS_TTY */
184
184
@@ -390,7 +390,7 @@ FileSeekProc(
390
390
* one of SEEK_START, SEEK_SET or SEEK_END. */
391
391
int * errorCodePtr ) /* To store error code. */
392
392
{
393
- FileState * fsPtr = instanceData ;
393
+ FileState * fsPtr = ( FileState * ) instanceData ;
394
394
Tcl_WideInt oldLoc , newLoc ;
395
395
396
396
/*
@@ -871,11 +871,11 @@ TtyGetOptionProc(
871
871
tcgetattr (fsPtr -> fd , & iostate );
872
872
Tcl_DStringInit (& ds );
873
873
874
- Tcl_ExternalToUtfDString (NULL , (char * ) & iostate .c_cc [VSTART ], 1 , & ds );
874
+ Tcl_ExternalToUtfDString (NULL , (char * )& iostate .c_cc [VSTART ], 1 , & ds );
875
875
Tcl_DStringAppendElement (dsPtr , Tcl_DStringValue (& ds ));
876
876
TclDStringClear (& ds );
877
877
878
- Tcl_ExternalToUtfDString (NULL , (char * ) & iostate .c_cc [VSTOP ], 1 , & ds );
878
+ Tcl_ExternalToUtfDString (NULL , (char * )& iostate .c_cc [VSTOP ], 1 , & ds );
879
879
Tcl_DStringAppendElement (dsPtr , Tcl_DStringValue (& ds ));
880
880
Tcl_DStringFree (& ds );
881
881
}
@@ -1284,22 +1284,18 @@ TtyParseMode(
1284
1284
* not allow preprocessor directives in their arguments.
1285
1285
*/
1286
1286
1287
- if (
1288
- #if defined( PAREXT )
1289
- strchr ( "noems" , parity )
1287
+ #ifdef PAREXT
1288
+ #define PARITY_CHARS "noems"
1289
+ #define PARITY_MSG "n, o, e, m, or s"
1290
1290
#else
1291
- strchr ("noe" , parity )
1291
+ #define PARITY_CHARS "noe"
1292
+ #define PARITY_MSG "n, o, or e"
1292
1293
#endif /* PAREXT */
1293
- == NULL ) {
1294
+
1295
+ if (strchr (PARITY_CHARS , parity ) == NULL ) {
1294
1296
if (interp != NULL ) {
1295
1297
Tcl_SetObjResult (interp , Tcl_ObjPrintf (
1296
- "%s parity: should be %s" , bad ,
1297
- #if defined(PAREXT )
1298
- "n, o, e, m, or s"
1299
- #else
1300
- "n, o, or e"
1301
- #endif /* PAREXT */
1302
- ));
1298
+ "%s parity: should be %s" , bad , PARITY_MSG ));
1303
1299
Tcl_SetErrorCode (interp , "TCL" , "VALUE" , "SERIALMODE" , (char * )NULL );
1304
1300
}
1305
1301
return TCL_ERROR ;
@@ -1598,12 +1594,11 @@ TclpGetDefaultStdChannel(
1598
1594
* Some #def's to make the code a little clearer!
1599
1595
*/
1600
1596
1601
- #define ZERO_OFFSET ((Tcl_SeekOffset) 0)
1602
1597
#define ERROR_OFFSET ((Tcl_SeekOffset) -1)
1603
1598
1604
1599
switch (type ) {
1605
1600
case TCL_STDIN :
1606
- if ((TclOSseek (0 , ZERO_OFFSET , SEEK_CUR ) == ERROR_OFFSET )
1601
+ if ((TclOSseek (0 , 0 , SEEK_CUR ) == ERROR_OFFSET )
1607
1602
&& (errno == EBADF )) {
1608
1603
return NULL ;
1609
1604
}
@@ -1612,7 +1607,7 @@ TclpGetDefaultStdChannel(
1612
1607
bufMode = "line" ;
1613
1608
break ;
1614
1609
case TCL_STDOUT :
1615
- if ((TclOSseek (1 , ZERO_OFFSET , SEEK_CUR ) == ERROR_OFFSET )
1610
+ if ((TclOSseek (1 , 0 , SEEK_CUR ) == ERROR_OFFSET )
1616
1611
&& (errno == EBADF )) {
1617
1612
return NULL ;
1618
1613
}
@@ -1621,7 +1616,7 @@ TclpGetDefaultStdChannel(
1621
1616
bufMode = "line" ;
1622
1617
break ;
1623
1618
case TCL_STDERR :
1624
- if ((TclOSseek (2 , ZERO_OFFSET , SEEK_CUR ) == ERROR_OFFSET )
1619
+ if ((TclOSseek (2 , 0 , SEEK_CUR ) == ERROR_OFFSET )
1625
1620
&& (errno == EBADF )) {
1626
1621
return NULL ;
1627
1622
}
@@ -1634,7 +1629,6 @@ TclpGetDefaultStdChannel(
1634
1629
break ;
1635
1630
}
1636
1631
1637
- #undef ZERO_OFFSET
1638
1632
#undef ERROR_OFFSET
1639
1633
1640
1634
channel = Tcl_MakeFileChannel (INT2PTR (fd ), mode );
0 commit comments