/* ** subtest_xmc(test_list, status, ch) ** ** (xmc) magic cookie glitch */ static void subtest_xmc( struct test_list *t, int *state, int *ch) { int i, j; if (enter_standout_mode) { sprintf(temp, "\n(xmc) Magic-cookie-glitch is %d in the data base", magic_cookie_glitch); ptextln(temp); j = magic_cookie_glitch * 8; for (i = 0; i < j; i++) { put_str(" "); } ptextln(" These two lines should line up."); if (j > 0) { char_count += j; } for (i = 0; i < 4; i++) { put_mode(enter_standout_mode); putchp(' '); put_mode(exit_standout_mode); putchp(' '); } ptextln("These two lines should line up."); ptext("If they don't line up then (xmc) magic-cookie-glitch should be greater than zero. "); generic_done_message(t, state, ch); } }
filebuf* filebuf::close() { if (!is_open()) return NULL; // This flushes as well as switching mode. if (pptr() > pbase() || put_mode()) if (switch_to_get_mode()) return NULL; unsave_markers(); int status = sys_close(); // Free buffer. setb(NULL, NULL, 0); setg(NULL, NULL, NULL); setp(NULL, NULL); _un_link(); _flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS; _fb._fileno = EOF; _fb._offset = 0; return status < 0 ? NULL : this; }
/* ** subtest_msgr(test_list, status, ch) ** ** (msgr) move in sgr mode */ static void subtest_msgr( struct test_list *t, int *state, int *ch) { int i; if (cursor_address && ((enter_standout_mode && exit_standout_mode) || (enter_alt_charset_mode && exit_alt_charset_mode))) { put_crlf(); i = line_count + 1; tputs(tparm(cursor_address, i, 0), lines, tc_putch); put_mode(enter_alt_charset_mode); put_crlf(); /* some versions of the wy-120 can not clear lines or screen when in alt charset mode. If (el) and (ed) are defined then I can test them. If they are not defined then they can not break (msgr) */ tc_putp(clr_eos); tc_putp(clr_eol); put_mode(exit_alt_charset_mode); put_mode(enter_standout_mode); putchp('X'); tputs(tparm(cursor_address, i + 2, 1), lines, tc_putch); putchp('X'); tputs(tparm(cursor_address, i + 3, 2), lines, tc_putch); putchp('X'); tputs(tparm(cursor_address, i + 4, 3), lines, tc_putch); putchp('X'); put_mode(exit_standout_mode); put_crlf(); tc_putp(clr_eos); /* OK if missing */ put_crlf(); ptextln("If you see a diagonal line of standout X's then (msgr) should be true. If any of the blanks are standout then (msgr) should be false."); sprintf(temp, "(msgr) Move-in-SGR-mode is %s in the data base", move_standout_mode ? "true" : "false"); ptextln(temp); } else { ptextln("(smso) (rmso) (smacs) (rmacs) missing; (msgr) Move-in-SGR-mode not tested."); } generic_done_message(t, state, ch); }
/* ** subtest_xhp(test_list, status, ch) ** ** (xhp) erase does not clear standout mode */ static void subtest_xhp( struct test_list *t, int *state, int *ch) { if (enter_standout_mode) { put_crlf(); put_mode(enter_standout_mode); put_str("Stand out"); put_mode(exit_standout_mode); put_cr(); ptextln("If any part of this line is standout then (xhp) should be set."); sprintf(temp, "(xhp) Erase-standout-glitch is %s in the data base", ceol_standout_glitch ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); } }
/* ** keys_tested(first-time, show-help, hex-output) ** ** Display a list of the keys not tested. */ static void keys_tested( int first_time, int show_help, int hex_output) { int i, l; char outbuf[256]; alloc_strings(); put_clear(); tty_set(); flush_input(); if (got_labels) { putln("Function key labels:"); for (i = 0; i < key_count; ++i) { if (fk_label[i]) { sprintf(outbuf, "%s %s", fk_name[i] ? fk_name[i] : "??", fk_label[i]); put_columns(outbuf, (int) strlen(outbuf), 16); } } put_newlines(2); } if (funk) { putln("The following keys are not defined:"); for (i = 0; i < funk; ++i) { put_columns(fk_unknown[i], fk_length[i], 16); } put_mode(exit_attribute_mode); put_newlines(2); } if (first_time) { putln("The following keys are defined:"); } else { putln("The following keys have not been tested:"); } if (scan_mode) { for (i = 0; scan_down[i]; i++) { if (!scan_tested[i]) { if (hex_output) { strcpy(outbuf, hex_expand_to(scan_down[i], 3)); } else { strcpy(outbuf, expand(scan_down[i])); } l = expand_chars; if (hex_output) { strcat(outbuf, hex_expand_to(scan_up[i], 3)); } else { strcat(outbuf, expand(scan_up[i])); } expand_chars += l; l = (int) strlen(scan_name[i]); if (((char_count + 16) & ~15) + ((expand_chars + 7) & ~7) + l >= columns) { put_crlf(); } else if (char_count + 24 > columns) { put_crlf(); } else if (char_count) { putchp(' '); } put_columns(outbuf, expand_chars, 16); put_columns(scan_name[i], l, 8); } } } else { for (i = 0; i < key_count; i++) { if (!fk_tested[i] && fk_name[i] != 0) { if (hex_output) { strcpy(outbuf, hex_expand_to(fkval[i], 3)); } else { strcpy(outbuf, expand(fkval[i])); } l = (int) strlen(fk_name[i]); if (((char_count + 16) & ~15) + ((expand_chars + 7) & ~7) + l >= columns) { put_crlf(); } else if (char_count + 24 > columns) { put_crlf(); } else if (char_count) { putchp(' '); } put_columns(outbuf, expand_chars, 16); put_columns(fk_name[i], l, 8); } } } put_newlines(2); if (show_help) { ptextln("Hit any function key. Type 'end' to quit. Type ? to update the display."); put_crlf(); } }
streampos filebuf::seekoff(streamoff offset, _seek_dir dir, int mode) { streampos result, new_offset, delta; _G_ssize_t count; if (mode == 0) // Don't move any pointers. dir = ios::cur, offset = 0; // Flush unwritten characters. // (This may do an unneeded write if we seek within the buffer. // But to be able to switch to reading, we would need to set // egptr to ptr. That can't be done in the current design, // which assumes file_ptr() is eGptr. Anyway, since we probably // end up flushing when we close(), it doesn't make much difference.) if (pptr() > pbase() || put_mode()) if (switch_to_get_mode()) return EOF; if (base() == NULL) { doallocbuf(); setp(base(), base()); setg(base(), base(), base()); } switch (dir) { case ios::cur: if (_fb._offset < 0) { _fb._offset = sys_seek(0, ios::cur); if (_fb._offset < 0) return EOF; } // Make offset absolute, assuming current pointer is file_ptr(). offset += _fb._offset; offset -= _egptr - _gptr; if (in_backup()) offset -= _other_egptr - _other_gbase; dir = ios::beg; break; case ios::beg: break; case ios::end: struct stat st; if (sys_stat(&st) == 0 && S_ISREG(st.st_mode)) { offset += st.st_size; dir = ios::beg; } else goto dumb; } // At this point, dir==ios::beg. // If destination is within current buffer, optimize: if (_fb._offset >= 0 && _eback != NULL) { // Offset relative to start of main get area. fpos_t rel_offset = offset - _fb._offset + (eGptr()-Gbase()); if (rel_offset >= 0) { if (in_backup()) switch_to_main_get_area(); if (rel_offset <= _egptr - _eback) { setg(base(), base() + rel_offset, egptr()); setp(base(), base()); return offset; } // If we have streammarkers, seek forward by reading ahead. if (have_markers()) { int to_skip = rel_offset - (_gptr - _eback); if (ignore(to_skip) != to_skip) goto dumb; return offset; } } if (rel_offset < 0 && rel_offset >= Bbase() - Bptr()) { if (!in_backup()) switch_to_backup_area(); gbump(_egptr + rel_offset - gptr()); return offset; } } unsave_markers(); // Try to seek to a block boundary, to improve kernel page management. new_offset = offset & ~(ebuf() - base() - 1); delta = offset - new_offset; if (delta > ebuf() - base()) { new_offset = offset; delta = 0; } result = sys_seek(new_offset, ios::beg); if (result < 0) return EOF; if (delta == 0) count = 0; else { count = sys_read(base(), ebuf()-base()); if (count < delta) { // We weren't allowed to read, but try to seek the remainder. offset = count == EOF ? delta : delta-count; dir = ios::cur; goto dumb; } } setg(base(), base()+delta, base()+count); setp(base(), base()); _fb._offset = result + count; xflags(xflags() & ~ _S_EOF_SEEN); return offset; dumb: unsave_markers(); result = sys_seek(offset, dir); if (result != EOF) { xflags(xflags() & ~_S_EOF_SEEN); } _fb._offset = result; setg(base(), base(), base()); setp(base(), base()); return result; }