ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.414 by ayin, Tue Feb 19 10:47:03 2008 UTC vs.
Revision 1.418 by root, Fri Oct 10 00:11:44 2008 UTC

2179 wchar_t ch = NOCHAR; 2179 wchar_t ch = NOCHAR;
2180 char *seq_begin; // remember start of esc-sequence here 2180 char *seq_begin; // remember start of esc-sequence here
2181 2181
2182 for (;;) 2182 for (;;)
2183 { 2183 {
2184 if (ch == NOCHAR) 2184 if (expect_false (ch == NOCHAR))
2185 { 2185 {
2186 seq_begin = cmdbuf_ptr; 2186 seq_begin = cmdbuf_ptr;
2187 ch = next_char (); 2187 ch = next_char ();
2188 2188
2189 if (ch == NOCHAR) 2189 if (ch == NOCHAR)
2190 break; 2190 break;
2191 } 2191 }
2192 2192
2193 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2193 if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
2194 { 2194 {
2195 if (!seen_input) 2195 if (expect_false (!seen_input))
2196 { 2196 {
2197 seen_input = 1; 2197 seen_input = 1;
2198 // many badly-written programs (e.g. jed) contain a race condition: 2198 // many badly-written programs (e.g. jed) contain a race condition:
2199 // they first read the screensize and then install a SIGWINCH handler. 2199 // they first read the screensize and then install a SIGWINCH handler.
2200 // some window managers resize the window early, and these programs 2200 // some window managers resize the window early, and these programs
2213 wchar_t *str = buf; 2213 wchar_t *str = buf;
2214 wchar_t *eol = str + min (ncol, UBUFSIZ); 2214 wchar_t *eol = str + min (ncol, UBUFSIZ);
2215 2215
2216 for (;;) 2216 for (;;)
2217 { 2217 {
2218 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2218 if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
2219 break; 2219 break;
2220 2220
2221 *str++ = ch; 2221 *str++ = ch;
2222 2222
2223 if (ch == C0_LF || str >= eol) 2223 if (expect_false (ch == C0_LF || str >= eol))
2224 { 2224 {
2225 if (ch == C0_LF) 2225 if (ch == C0_LF)
2226 nlines++; 2226 nlines++;
2227 2227
2228 refresh_count++; 2228 refresh_count++;
2310rxvt_term::next_char () NOTHROW 2310rxvt_term::next_char () NOTHROW
2311{ 2311{
2312 while (cmdbuf_ptr < cmdbuf_endp) 2312 while (cmdbuf_ptr < cmdbuf_endp)
2313 { 2313 {
2314 // assume 7-bit to be ascii ALWAYS 2314 // assume 7-bit to be ascii ALWAYS
2315 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2315 if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
2316 return *cmdbuf_ptr++; 2316 return *cmdbuf_ptr++;
2317 2317
2318 wchar_t wc; 2318 wchar_t wc;
2319 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 2319 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
2320 2320
2324 cmdbuf_ptr = cmdbuf_endp; 2324 cmdbuf_ptr = cmdbuf_endp;
2325 break; 2325 break;
2326 } 2326 }
2327 2327
2328 if (len == (size_t)-1) 2328 if (len == (size_t)-1)
2329 {
2330 mbrtowc (0, 0, 0, mbstate); // reset now undefined conversion state
2329 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2331 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2332 }
2330 2333
2331 // assume wchar == unicode 2334 // assume wchar == unicode
2332 cmdbuf_ptr += len; 2335 cmdbuf_ptr += len;
2333 return wc & UNICODE_MASK; 2336 return wc & UNICODE_MASK;
2334 } 2337 }
2378/*----------------------------------------------------------------------*/ 2381/*----------------------------------------------------------------------*/
2379#ifdef PRINTPIPE 2382#ifdef PRINTPIPE
2380FILE * 2383FILE *
2381rxvt_term::popen_printer () 2384rxvt_term::popen_printer ()
2382{ 2385{
2383 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2386 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w");
2384 2387
2385 if (stream == NULL) 2388 if (stream == NULL)
2386 rxvt_warn ("can't open printer pipe, not printing.\n"); 2389 rxvt_warn ("can't open printer pipe, not printing.\n");
2387 2390
2388 return stream; 2391 return stream;
2399 * simulate attached vt100 printer 2402 * simulate attached vt100 printer
2400 */ 2403 */
2401void 2404void
2402rxvt_term::process_print_pipe () 2405rxvt_term::process_print_pipe ()
2403{ 2406{
2404 int done; 2407 FILE *fd = popen_printer ();
2405 FILE *fd;
2406 2408
2407 if ((fd = popen_printer ()) == NULL) 2409 if (!fd)
2408 return; 2410 return;
2409 2411
2410 /* 2412 /*
2411 * Send all input to the printer until either ESC[4i or ESC[?4i 2413 * Send all input to the printer until either ESC[4i or ESC[?4i
2412 * is received. 2414 * is received.
2413 */ 2415 */
2414 for (done = 0; !done;) 2416 for (int done = 0; !done; )
2415 { 2417 {
2416 unsigned char buf[8]; 2418 unsigned char buf[8];
2417 unicode_t ch; 2419 unicode_t ch;
2418 unsigned int i, len; 2420 unsigned int i, len;
2419 2421
3270 3272
3271 assert (str != NULL); 3273 assert (str != NULL);
3272 3274
3273 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) 3275 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3274 return; 3276 return;
3277 fprintf (stderr, "op %d<%s>\n", op, str);//D
3275 3278
3276 switch (op) 3279 switch (op)
3277 { 3280 {
3278 case XTerm_name: 3281 case XTerm_name:
3279 set_title (str); 3282 set_title (str);
3507 break; 3510 break;
3508#endif 3511#endif
3509 3512
3510#if ENABLE_PERL 3513#if ENABLE_PERL
3511 case URxvt_perl: 3514 case URxvt_perl:
3512 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) 3515 HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END));
3513 ; // no responses yet
3514 break; 3516 break;
3515#endif 3517#endif
3516 } 3518 }
3517} 3519}
3518/*----------------------------------------------------------------------*/ 3520/*----------------------------------------------------------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines