Sun Jul 16 17:43:50 2023 UTC ()
Avoid overflow with too many ';' (David Leadbeater)
Prefix all messages with the method name


(christos)
diff -r1.50 -r1.51 src/sys/dev/wscons/wsemul_vt100.c

cvs diff -r1.50 -r1.51 src/sys/dev/wscons/wsemul_vt100.c (expand / switch to unified diff)

--- src/sys/dev/wscons/wsemul_vt100.c 2023/02/23 02:48:06 1.50
+++ src/sys/dev/wscons/wsemul_vt100.c 2023/07/16 17:43:50 1.51
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: wsemul_vt100.c,v 1.50 2023/02/23 02:48:06 riastradh Exp $ */ 1/* $NetBSD: wsemul_vt100.c,v 1.51 2023/07/16 17:43:50 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 4 * Copyright (c) 1998
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.50 2023/02/23 02:48:06 riastradh Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.51 2023/07/16 17:43:50 christos Exp $");
31 31
32#ifdef _KERNEL_OPT 32#ifdef _KERNEL_OPT
33#include "opt_wsmsgattrs.h" 33#include "opt_wsmsgattrs.h"
34#endif 34#endif
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38#include <sys/time.h> 38#include <sys/time.h>
39#include <sys/malloc.h> 39#include <sys/malloc.h>
40#include <sys/fcntl.h> 40#include <sys/fcntl.h>
41 41
42#include <dev/wscons/wsconsio.h> 42#include <dev/wscons/wsconsio.h>
43#include <dev/wscons/wsdisplayvar.h> 43#include <dev/wscons/wsdisplayvar.h>
@@ -618,27 +618,27 @@ wsemul_vt100_output_esc(struct wsemul_vt @@ -618,27 +618,27 @@ wsemul_vt100_output_esc(struct wsemul_vt
618 case '#': 618 case '#':
619 return VT100_EMUL_STATE_ESC_HASH; 619 return VT100_EMUL_STATE_ESC_HASH;
620 case ' ': /* 7/8 bit */ 620 case ' ': /* 7/8 bit */
621 return VT100_EMUL_STATE_ESC_SPC; 621 return VT100_EMUL_STATE_ESC_SPC;
622 case ']': /* OSC operating system command */ 622 case ']': /* OSC operating system command */
623 case '^': /* PM privacy message */ 623 case '^': /* PM privacy message */
624 case '_': /* APC application program command */ 624 case '_': /* APC application program command */
625 /* ignored */ 625 /* ignored */
626 return VT100_EMUL_STATE_STRING; 626 return VT100_EMUL_STATE_STRING;
627 case '<': /* exit VT52 mode - ignored */ 627 case '<': /* exit VT52 mode - ignored */
628 break; 628 break;
629 default: 629 default:
630#ifdef VT100_PRINTUNKNOWN 630#ifdef VT100_PRINTUNKNOWN
631 printf("ESC%c unknown\n", c); 631 printf("%s: ESC%c unknown\n", __func__, c);
632#endif 632#endif
633 break; 633 break;
634 } 634 }
635 return VT100_EMUL_STATE_NORMAL; 635 return VT100_EMUL_STATE_NORMAL;
636} 636}
637 637
638static u_int 638static u_int
639wsemul_vt100_output_scs94(struct wsemul_vt100_emuldata *edp, u_char c) 639wsemul_vt100_output_scs94(struct wsemul_vt100_emuldata *edp, u_char c)
640{ 640{
641 switch (c) { 641 switch (c) {
642 case '%': /* probably DEC supplemental graphic */ 642 case '%': /* probably DEC supplemental graphic */
643 return VT100_EMUL_STATE_SCS94_PERCENT; 643 return VT100_EMUL_STATE_SCS94_PERCENT;
644 case 'A': /* british / national */ 644 case 'A': /* british / national */
@@ -649,44 +649,46 @@ wsemul_vt100_output_scs94(struct wsemul_ @@ -649,44 +649,46 @@ wsemul_vt100_output_scs94(struct wsemul_
649 break; 649 break;
650 case '<': /* user preferred supplemental */ 650 case '<': /* user preferred supplemental */
651 /* XXX not really "user" preferred */ 651 /* XXX not really "user" preferred */
652 edp->chartab_G[edp->designating] = edp->isolatin1tab; 652 edp->chartab_G[edp->designating] = edp->isolatin1tab;
653 break; 653 break;
654 case '0': /* DEC special graphic */ 654 case '0': /* DEC special graphic */
655 edp->chartab_G[edp->designating] = edp->decgraphtab; 655 edp->chartab_G[edp->designating] = edp->decgraphtab;
656 break; 656 break;
657 case '>': /* DEC tech */ 657 case '>': /* DEC tech */
658 edp->chartab_G[edp->designating] = edp->dectechtab; 658 edp->chartab_G[edp->designating] = edp->dectechtab;
659 break; 659 break;
660 default: 660 default:
661#ifdef VT100_PRINTUNKNOWN 661#ifdef VT100_PRINTUNKNOWN
662 printf("ESC%c%c unknown\n", edp->designating + '(', c); 662 printf("%s: ESC%c%c unknown\n", __func__,
 663 edp->designating + '(', c);
663#endif 664#endif
664 break; 665 break;
665 } 666 }
666 return VT100_EMUL_STATE_NORMAL; 667 return VT100_EMUL_STATE_NORMAL;
667} 668}
668 669
669static u_int 670static u_int
670wsemul_vt100_output_scs94_percent(struct wsemul_vt100_emuldata *edp, u_char c) 671wsemul_vt100_output_scs94_percent(struct wsemul_vt100_emuldata *edp, u_char c)
671{ 672{
672 switch (c) { 673 switch (c) {
673 case '5': /* DEC supplemental graphic */ 674 case '5': /* DEC supplemental graphic */
674 /* XXX there are differences */ 675 /* XXX there are differences */
675 edp->chartab_G[edp->designating] = edp->isolatin1tab; 676 edp->chartab_G[edp->designating] = edp->isolatin1tab;
676 break; 677 break;
677 default: 678 default:
678#ifdef VT100_PRINTUNKNOWN 679#ifdef VT100_PRINTUNKNOWN
679 printf("ESC%c%%%c unknown\n", edp->designating + '(', c); 680 printf("%s: ESC%c%%%c unknown\n",
 681 __func__, edp->designating + '(', c);
680#endif 682#endif
681 break; 683 break;
682 } 684 }
683 return VT100_EMUL_STATE_NORMAL; 685 return VT100_EMUL_STATE_NORMAL;
684} 686}
685 687
686static u_int 688static u_int
687wsemul_vt100_output_scs96(struct wsemul_vt100_emuldata *edp, u_char c) 689wsemul_vt100_output_scs96(struct wsemul_vt100_emuldata *edp, u_char c)
688{ 690{
689 int nrc; 691 int nrc;
690 692
691 switch (c) { 693 switch (c) {
692 case '%': /* probably portuguese */ 694 case '%': /* probably portuguese */
@@ -718,63 +720,65 @@ wsemul_vt100_output_scs96(struct wsemul_ @@ -718,63 +720,65 @@ wsemul_vt100_output_scs96(struct wsemul_
718 case 'Z': /* spanish */ 720 case 'Z': /* spanish */
719 nrc = 9; 721 nrc = 9;
720 goto setnrc; 722 goto setnrc;
721 case '7': case 'H': /* swedish */ 723 case '7': case 'H': /* swedish */
722 nrc = 10; 724 nrc = 10;
723 goto setnrc; 725 goto setnrc;
724 case '=': /* swiss */ 726 case '=': /* swiss */
725 nrc = 11; 727 nrc = 11;
726setnrc: 728setnrc:
727 vt100_setnrc(edp, nrc); /* what table ??? */ 729 vt100_setnrc(edp, nrc); /* what table ??? */
728 break; 730 break;
729 default: 731 default:
730#ifdef VT100_PRINTUNKNOWN 732#ifdef VT100_PRINTUNKNOWN
731 printf("ESC%c%c unknown\n", edp->designating + '-' - 1, c); 733 printf("%s: ESC%c%c unknown\n",
 734 __func__, edp->designating + '-' - 1, c);
732#endif 735#endif
733 break; 736 break;
734 } 737 }
735 return VT100_EMUL_STATE_NORMAL; 738 return VT100_EMUL_STATE_NORMAL;
736} 739}
737 740
738static u_int 741static u_int
739wsemul_vt100_output_scs96_percent(struct wsemul_vt100_emuldata *edp, u_char c) 742wsemul_vt100_output_scs96_percent(struct wsemul_vt100_emuldata *edp, u_char c)
740{ 743{
741 switch (c) { 744 switch (c) {
742 case '6': /* portuguese */ 745 case '6': /* portuguese */
743 vt100_setnrc(edp, 8); 746 vt100_setnrc(edp, 8);
744 break; 747 break;
745 default: 748 default:
746#ifdef VT100_PRINTUNKNOWN 749#ifdef VT100_PRINTUNKNOWN
747 printf("ESC%c%%%c unknown\n", edp->designating + '-', c); 750 printf("%s: ESC%c%%%c unknown\n",
 751 __func__, edp->designating + '-', c);
748#endif 752#endif
749 break; 753 break;
750 } 754 }
751 return VT100_EMUL_STATE_NORMAL; 755 return VT100_EMUL_STATE_NORMAL;
752} 756}
753 757
754static u_int 758static u_int
755wsemul_vt100_output_esc_spc(struct wsemul_vt100_emuldata *edp, 759wsemul_vt100_output_esc_spc(struct wsemul_vt100_emuldata *edp,
756 u_char c) 760 u_char c)
757{ 761{
758 switch (c) { 762 switch (c) {
759 case 'F': /* 7-bit controls */ 763 case 'F': /* 7-bit controls */
760 case 'G': /* 8-bit controls */ 764 case 'G': /* 8-bit controls */
761#ifdef VT100_PRINTNOTIMPL 765#ifdef VT100_PRINTNOTIMPL
762 printf("ESC<SPC>%c ignored\n", c); 766 printf("%s: ESC<SPC>%c ignored\n", __func__, c);
763#endif 767#endif
764 break; 768 break;
765 default: 769 default:
766#ifdef VT100_PRINTUNKNOWN 770#ifdef VT100_PRINTUNKNOWN
767 printf("ESC<SPC>%c unknown\n", c); 771 printf("%s: ESC<SPC>%c unknown\n", __func__, c);
768#endif 772#endif
769 break; 773 break;
770 } 774 }
771 return VT100_EMUL_STATE_NORMAL; 775 return VT100_EMUL_STATE_NORMAL;
772} 776}
773 777
774static u_int 778static u_int
775wsemul_vt100_output_string(struct wsemul_vt100_emuldata *edp, u_char c) 779wsemul_vt100_output_string(struct wsemul_vt100_emuldata *edp, u_char c)
776{ 780{
777 struct vt100base_data *vd = &edp->bd; 781 struct vt100base_data *vd = &edp->bd;
778 782
779 if (vd->dcstype && vd->dcspos < DCS_MAXLEN) 783 if (vd->dcstype && vd->dcspos < DCS_MAXLEN)
780 vd->dcsarg[vd->dcspos++] = c; 784 vd->dcsarg[vd->dcspos++] = c;
@@ -797,95 +801,96 @@ static u_int @@ -797,95 +801,96 @@ static u_int
797wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c) 801wsemul_vt100_output_dcs(struct wsemul_vt100_emuldata *edp, u_char c)
798{ 802{
799 struct vt100base_data *vd = &edp->bd; 803 struct vt100base_data *vd = &edp->bd;
800 804
801 switch (c) { 805 switch (c) {
802 case '0': case '1': case '2': case '3': case '4': 806 case '0': case '1': case '2': case '3': case '4':
803 case '5': case '6': case '7': case '8': case '9': 807 case '5': case '6': case '7': case '8': case '9':
804 /* argument digit */ 808 /* argument digit */
805 if (vd->nargs > VT100_EMUL_NARGS - 1) 809 if (vd->nargs > VT100_EMUL_NARGS - 1)
806 break; 810 break;
807 vd->args[vd->nargs] = (vd->args[vd->nargs] * 10) + 811 vd->args[vd->nargs] = (vd->args[vd->nargs] * 10) +
808 (c - '0'); 812 (c - '0');
809 break; 813 break;
810 case ';': /* argument terminator */ 
811 vd->nargs++; 
812 break; 
813 default: 814 default:
814 vd->nargs++; 815 vd->nargs++;
815 if (vd->nargs > VT100_EMUL_NARGS) { 816 if (vd->nargs > VT100_EMUL_NARGS) {
816#ifdef VT100_DEBUG 817#ifdef VT100_DEBUG
817 printf("vt100: too many arguments\n"); 818 printf("%s: too many arguments\n", __func__);
818#endif 819#endif
819 vd->nargs = VT100_EMUL_NARGS; 820 vd->nargs = VT100_EMUL_NARGS;
820 } 821 }
 822 if (c == ';') /* argument terminator */
 823 break;
821 switch (c) { 824 switch (c) {
822 case '$': 825 case '$':
823 return VT100_EMUL_STATE_DCS_DOLLAR; 826 return VT100_EMUL_STATE_DCS_DOLLAR;
824 case '{': /* DECDLD soft charset */ 827 case '{': /* DECDLD soft charset */
825 case '!': /* DECRQUPSS user preferred supplemental set */ 828 case '!': /* DECRQUPSS user preferred supplemental set */
826 /* 'u' must follow - need another state */ 829 /* 'u' must follow - need another state */
827 case '|': /* DECUDK program F6..F20 */ 830 case '|': /* DECUDK program F6..F20 */
828#ifdef VT100_PRINTNOTIMPL 831#ifdef VT100_PRINTNOTIMPL
829 printf("DCS%c ignored\n", c); 832 printf("%s: DCS%c ignored\n", __func__, c);
830#endif 833#endif
831 break; 834 break;
832 default: 835 default:
833#ifdef VT100_PRINTUNKNOWN 836#ifdef VT100_PRINTUNKNOWN
834 printf("DCS%c (%d, %d) unknown\n", c, ARG(vd, 0), ARG(vd, 1)); 837 printf("%s: DCS%c (%d, %d) unknown\n",
 838 __func__, c, ARG(vd, 0), ARG(vd, 1));
835#endif 839#endif
836 break; 840 break;
837 } 841 }
838 return VT100_EMUL_STATE_STRING; 842 return VT100_EMUL_STATE_STRING;
839 } 843 }
840 844
841 return VT100_EMUL_STATE_DCS; 845 return VT100_EMUL_STATE_DCS;
842} 846}
843 847
844static u_int 848static u_int
845wsemul_vt100_output_dcs_dollar(struct wsemul_vt100_emuldata *edp, u_char c) 849wsemul_vt100_output_dcs_dollar(struct wsemul_vt100_emuldata *edp, u_char c)
846{ 850{
847 struct vt100base_data *vd = &edp->bd; 851 struct vt100base_data *vd = &edp->bd;
848 852
849 switch (c) { 853 switch (c) {
850 case 'p': /* DECRSTS terminal state restore */ 854 case 'p': /* DECRSTS terminal state restore */
851 case 'q': /* DECRQSS control function request */ 855 case 'q': /* DECRQSS control function request */
852#ifdef VT100_PRINTNOTIMPL 856#ifdef VT100_PRINTNOTIMPL
853 printf("DCS$%c ignored\n", c); 857 printf("%s: DCS$%c ignored\n", __func__, c);
854#endif 858#endif
855 break; 859 break;
856 case 't': /* DECRSPS restore presentation state */ 860 case 't': /* DECRSPS restore presentation state */
857 switch (ARG(vd, 0)) { 861 switch (ARG(vd, 0)) {
858 case 0: /* error */ 862 case 0: /* error */
859 break; 863 break;
860 case 1: /* cursor information restore */ 864 case 1: /* cursor information restore */
861#ifdef VT100_PRINTNOTIMPL 865#ifdef VT100_PRINTNOTIMPL
862 printf("DCS1$t ignored\n"); 866 printf("%s: DCS1$t ignored\n", __func__);
863#endif 867#endif
864 break; 868 break;
865 case 2: /* tab stop restore */ 869 case 2: /* tab stop restore */
866 vd->dcspos = 0; 870 vd->dcspos = 0;
867 vd->dcstype = DCSTYPE_TABRESTORE; 871 vd->dcstype = DCSTYPE_TABRESTORE;
868 break; 872 break;
869 default: 873 default:
870#ifdef VT100_PRINTUNKNOWN 874#ifdef VT100_PRINTUNKNOWN
871 printf("DCS%d$t unknown\n", ARG(vd, 0)); 875 printf("%s: DCS%d$t unknown\n", __func__, ARG(vd, 0));
872#endif 876#endif
873 break; 877 break;
874 } 878 }
875 break; 879 break;
876 default: 880 default:
877#ifdef VT100_PRINTUNKNOWN 881#ifdef VT100_PRINTUNKNOWN
878 printf("DCS$%c (%d, %d) unknown\n", c, ARG(vd, 0), ARG(vd, 1)); 882 printf("%s: DCS$%c (%d, %d) unknown\n",
 883 __func__, c, ARG(vd, 0), ARG(vd, 1));
879#endif 884#endif
880 break; 885 break;
881 } 886 }
882 return VT100_EMUL_STATE_STRING; 887 return VT100_EMUL_STATE_STRING;
883} 888}
884 889
885static u_int 890static u_int
886wsemul_vt100_output_esc_hash(struct wsemul_vt100_emuldata *edp, u_char c) 891wsemul_vt100_output_esc_hash(struct wsemul_vt100_emuldata *edp, u_char c)
887{ 892{
888 struct vt100base_data *vd = &edp->bd; 893 struct vt100base_data *vd = &edp->bd;
889 int i, j; 894 int i, j;
890 895
891 switch (c) { 896 switch (c) {
@@ -921,68 +926,67 @@ wsemul_vt100_output_esc_hash(struct wsem @@ -921,68 +926,67 @@ wsemul_vt100_output_esc_hash(struct wsem
921 vd->ccol = (vd->ncols >> 1) - 1; 926 vd->ccol = (vd->ncols >> 1) - 1;
922 } 927 }
923 break; 928 break;
924 case '8': /* DECALN */ 929 case '8': /* DECALN */
925 for (i = 0; i < vd->nrows; i++) 930 for (i = 0; i < vd->nrows; i++)
926 for (j = 0; j < vd->ncols; j++) 931 for (j = 0; j < vd->ncols; j++)
927 (*vd->emulops->putchar)(vd->emulcookie, i, j, 932 (*vd->emulops->putchar)(vd->emulcookie, i, j,
928 'E', vd->curattr); 933 'E', vd->curattr);
929 vd->ccol = 0; 934 vd->ccol = 0;
930 vd->crow = 0; 935 vd->crow = 0;
931 break; 936 break;
932 default: 937 default:
933#ifdef VT100_PRINTUNKNOWN 938#ifdef VT100_PRINTUNKNOWN
934 printf("ESC#%c unknown\n", c); 939 printf("%s: ESC#%c unknown\n", __func__, c);
935#endif 940#endif
936 break; 941 break;
937 } 942 }
938 return VT100_EMUL_STATE_NORMAL; 943 return VT100_EMUL_STATE_NORMAL;
939} 944}
940 945
941static u_int 946static u_int
942wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, u_char c) 947wsemul_vt100_output_csi(struct wsemul_vt100_emuldata *edp, u_char c)
943{ 948{
944 struct vt100base_data *vd = &edp->bd; 949 struct vt100base_data *vd = &edp->bd;
945 950
946 switch (c) { 951 switch (c) {
947 case '0': case '1': case '2': case '3': case '4': 952 case '0': case '1': case '2': case '3': case '4':
948 case '5': case '6': case '7': case '8': case '9': 953 case '5': case '6': case '7': case '8': case '9':
949 /* argument digit */ 954 /* argument digit */
950 if (vd->nargs > VT100_EMUL_NARGS - 1) 955 if (vd->nargs > VT100_EMUL_NARGS - 1)
951 break; 956 break;
952 vd->args[vd->nargs] = (vd->args[vd->nargs] * 10) + 957 vd->args[vd->nargs] = (vd->args[vd->nargs] * 10) +
953 (c - '0'); 958 (c - '0');
954 break; 959 break;
955 case ';': /* argument terminator */ 
956 vd->nargs++; 
957 break; 
958 case '?': /* DEC specific */ 960 case '?': /* DEC specific */
959 case '>': /* DA query */ 961 case '>': /* DA query */
960 vd->modif1 = c; 962 vd->modif1 = c;
961 break; 963 break;
962 case '!': 964 case '!':
963 case '"': 965 case '"':
964 case '$': 966 case '$':
965 case '&': 967 case '&':
966 vd->modif2 = c; 968 vd->modif2 = c;
967 break; 969 break;
968 default: /* end of escape sequence */ 970 default: /* end of escape sequence, argument terminator */
969 vd->nargs++; 971 vd->nargs++;
970 if (vd->nargs > VT100_EMUL_NARGS) { 972 if (vd->nargs > VT100_EMUL_NARGS) {
971#ifdef VT100_DEBUG 973#ifdef VT100_DEBUG
972 printf("vt100: too many arguments\n"); 974 printf("%s: too many arguments\n", __func__);
973#endif 975#endif
974 vd->nargs = VT100_EMUL_NARGS; 976 vd->nargs = VT100_EMUL_NARGS;
975 } 977 }
 978 if (c == ';') /* argument terminator */
 979 break;
976 wsemul_vt100_handle_csi(vd, c); 980 wsemul_vt100_handle_csi(vd, c);
977 return VT100_EMUL_STATE_NORMAL; 981 return VT100_EMUL_STATE_NORMAL;
978 } 982 }
979 return VT100_EMUL_STATE_CSI; 983 return VT100_EMUL_STATE_CSI;
980} 984}
981 985
982static void 986static void
983wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel) 987wsemul_vt100_output(void *cookie, const u_char *data, u_int count, int kernel)
984{ 988{
985 struct wsemul_vt100_emuldata *edp = cookie; 989 struct wsemul_vt100_emuldata *edp = cookie;
986 struct vt100base_data *vd = &edp->bd; 990 struct vt100base_data *vd = &edp->bd;
987 991
988#ifdef DIAGNOSTIC 992#ifdef DIAGNOSTIC
@@ -1038,28 +1042,28 @@ wsemul_vt100_setmsgattrs(void *cookie, c @@ -1038,28 +1042,28 @@ wsemul_vt100_setmsgattrs(void *cookie, c
1038 vd->msgattrs.default_bg = vd->msgattrs.kernel_bg = 0; 1042 vd->msgattrs.default_bg = vd->msgattrs.kernel_bg = 0;
1039 vd->msgattrs.default_fg = vd->msgattrs.kernel_fg = 0; 1043 vd->msgattrs.default_fg = vd->msgattrs.kernel_fg = 0;
1040 } 1044 }
1041 1045
1042 error = (*vd->emulops->allocattr)(vd->emulcookie, 1046 error = (*vd->emulops->allocattr)(vd->emulcookie,
1043 vd->msgattrs.default_fg, 1047 vd->msgattrs.default_fg,
1044 vd->msgattrs.default_bg, 1048 vd->msgattrs.default_bg,
1045 vd->msgattrs.default_attrs, 1049 vd->msgattrs.default_attrs,
1046 &tmp); 1050 &tmp);
1047#ifndef VT100_DEBUG 1051#ifndef VT100_DEBUG
1048 __USE(error); 1052 __USE(error);
1049#else 1053#else
1050 if (error) 1054 if (error)
1051 printf("vt100: failed to allocate attribute for default " 1055 printf("%s: failed to allocate attribute for default "
1052 "messages\n"); 1056 "messages\n", __func__);
1053 else 1057 else
1054#endif 1058#endif
1055 { 1059 {
1056 if (vd->curattr == vd->defattr) { 1060 if (vd->curattr == vd->defattr) {
1057 vd->bkgdattr = vd->curattr = tmp; 1061 vd->bkgdattr = vd->curattr = tmp;
1058 vd->attrflags = vd->msgattrs.default_attrs; 1062 vd->attrflags = vd->msgattrs.default_attrs;
1059 vd->bgcol = vd->msgattrs.default_bg; 1063 vd->bgcol = vd->msgattrs.default_bg;
1060 vd->fgcol = vd->msgattrs.default_fg; 1064 vd->fgcol = vd->msgattrs.default_fg;
1061 } else { 1065 } else {
1062 edp->savedbkgdattr = edp->savedattr = tmp; 1066 edp->savedbkgdattr = edp->savedattr = tmp;
1063 edp->savedattrflags = vd->msgattrs.default_attrs; 1067 edp->savedattrflags = vd->msgattrs.default_attrs;
1064 edp->savedbgcol = vd->msgattrs.default_bg; 1068 edp->savedbgcol = vd->msgattrs.default_bg;
1065 edp->savedfgcol = vd->msgattrs.default_fg; 1069 edp->savedfgcol = vd->msgattrs.default_fg;
@@ -1067,25 +1071,25 @@ wsemul_vt100_setmsgattrs(void *cookie, c @@ -1067,25 +1071,25 @@ wsemul_vt100_setmsgattrs(void *cookie, c
1067 if (vd->emulops->replaceattr != NULL) 1071 if (vd->emulops->replaceattr != NULL)
1068 (*vd->emulops->replaceattr)(vd->emulcookie, 1072 (*vd->emulops->replaceattr)(vd->emulcookie,
1069 vd->defattr, tmp); 1073 vd->defattr, tmp);
1070 vd->defattr = tmp; 1074 vd->defattr = tmp;
1071 } 1075 }
1072 1076
1073 error = (*vd->emulops->allocattr)(vd->emulcookie, 1077 error = (*vd->emulops->allocattr)(vd->emulcookie,
1074 vd->msgattrs.kernel_fg, 1078 vd->msgattrs.kernel_fg,
1075 vd->msgattrs.kernel_bg, 1079 vd->msgattrs.kernel_bg,
1076 vd->msgattrs.kernel_attrs, 1080 vd->msgattrs.kernel_attrs,
1077 &tmp); 1081 &tmp);
1078#ifdef VT100_DEBUG 1082#ifdef VT100_DEBUG
1079 if (error) 1083 if (error)
1080 printf("vt100: failed to allocate attribute for kernel " 1084 printf("%s: failed to allocate attribute for kernel "
1081 "messages\n"); 1085 "messages\n", __func__);
1082 else 1086 else
1083#endif 1087#endif
1084 { 1088 {
1085 if (vd->emulops->replaceattr != NULL) 1089 if (vd->emulops->replaceattr != NULL)
1086 (*vd->emulops->replaceattr)(vd->emulcookie, 1090 (*vd->emulops->replaceattr)(vd->emulcookie,
1087 edp->kernattr, tmp); 1091 edp->kernattr, tmp);
1088 edp->kernattr = tmp; 1092 edp->kernattr = tmp;
1089 } 1093 }
1090} 1094}
1091#endif /* WSDISPLAY_CUSTOM_OUTPUT */ 1095#endif /* WSDISPLAY_CUSTOM_OUTPUT */