Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/teraterm/teraterm/vtterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5907 by doda, Thu Jul 9 11:07:17 2015 UTC revision 5911 by doda, Tue Jul 14 01:51:16 2015 UTC
# Line 43  void ParseFirst(BYTE b); Line 43  void ParseFirst(BYTE b);
43  #define ModeXS    6  #define ModeXS    6
44  #define ModeDLE   7  #define ModeDLE   7
45  #define ModeCAN   8  #define ModeCAN   8
46    #define ModeIgnore 9
47    
48  #define NParamMax  16  #define NParamMax  16
49  #define NSParamMax 16  #define NSParamMax 16
# Line 168  static DWORD BeepStartTime = 0; Line 169  static DWORD BeepStartTime = 0;
169  static DWORD BeepSuppressTime = 0;  static DWORD BeepSuppressTime = 0;
170  static DWORD BeepOverUsedCount = 0;  static DWORD BeepOverUsedCount = 0;
171    
 /* OSC String buffer */  
 static char *OSCStrBuff;  
 static unsigned int OSCStrBuffSize;  
   
172  static _locale_t CLocale = NULL;  static _locale_t CLocale = NULL;
173    
174  void ClearParams()  void ClearParams()
# Line 432  void SendCSIstr(char *str, int len) { Line 429  void SendCSIstr(char *str, int len) {
429          CommBinaryOut(&cv, str, l);          CommBinaryOut(&cv, str, l);
430  }  }
431    
432  void SendOSCstr(char *str, int len) {  void SendOSCstr(char *str, int len, char TermChar) {
433          int l;          int l;
434    
435          if (str == NULL || len < 0)          if (str == NULL || len < 0)
# Line 445  void SendOSCstr(char *str, int len) { Line 442  void SendOSCstr(char *str, int len) {
442                  l = len;                  l = len;
443          }          }
444    
445          if (Send8BitMode) {          if (TermChar == BEL) {
446                    CommBinaryOut(&cv,"\033]", 2);
447                    CommBinaryOut(&cv, str, l);
448                    CommBinaryOut(&cv,"\007", 1);
449            }
450            else if (Send8BitMode) {
451                  CommBinaryOut(&cv,"\235", 1);                  CommBinaryOut(&cv,"\235", 1);
452                  CommBinaryOut(&cv, str, l);                  CommBinaryOut(&cv, str, l);
453                  CommBinaryOut(&cv,"\234", 1);                  CommBinaryOut(&cv,"\234", 1);
# Line 1025  void ParseControl(BYTE b) Line 1027  void ParseControl(BYTE b)
1027        break;        break;
1028      case SOS:      case SOS:
1029        ESCFlag = FALSE;        ESCFlag = FALSE;
1030        ParseMode = ModeSOS;        ParseMode = ModeIgnore;
1031        break;        break;
1032      case CSI:      case CSI:
1033        ClearParams();        ClearParams();
# Line 1039  void ParseControl(BYTE b) Line 1041  void ParseControl(BYTE b)
1041      case PM:      case PM:
1042      case APC:      case APC:
1043        ESCFlag = FALSE;        ESCFlag = FALSE;
1044        ParseMode = ModeSOS;        ParseMode = ModeIgnore;
1045        break;        break;
1046    }    }
1047  }  }
# Line 1368  void ParseEscape(BYTE b) /* b is the fin Line 1370  void ParseEscape(BYTE b) /* b is the fin
1370            ParseMode = ModeDCS;            ParseMode = ModeDCS;
1371            return;            return;
1372          case 'X': /* SOS */          case 'X': /* SOS */
1373            case '^': /* APC */
1374            case '_': /* PM  */
1375            ESCFlag = FALSE;            ESCFlag = FALSE;
1376            ParseMode = ModeSOS;            ParseMode = ModeIgnore;
1377            return;            return;
1378          case 'Z': /* DECID */          case 'Z': /* DECID */
1379            AnswerTerminalType();            AnswerTerminalType();
# Line 1384  void ParseEscape(BYTE b) /* b is the fin Line 1388  void ParseEscape(BYTE b) /* b is the fin
1388            ClearParams();            ClearParams();
1389            ParseMode = ModeXS;            ParseMode = ModeXS;
1390            return;            return;
         case '^':  
         case '_': /* PM, APC */  
           ESCFlag = FALSE;  
           ParseMode = ModeSOS;  
           return;  
1391          case 'c': /* Hardware reset */          case 'c': /* Hardware reset */
1392            HideStatusLine();            HideStatusLine();
1393            ResetTerminal();            ResetTerminal();
# Line 2386  void CSSetLRScrollRegion()     // DECSLRM Line 2385  void CSSetLRScrollRegion()     // DECSLRM
2385                    len = _snprintf_s_l(Report, sizeof(Report), _TRUNCATE, "L%s", CLocale, cv.TitleRemote);                    len = _snprintf_s_l(Report, sizeof(Report), _TRUNCATE, "L%s", CLocale, cv.TitleRemote);
2386                  }                  }
2387              }              }
2388              SendOSCstr(Report, len);              SendOSCstr(Report, len, ST);
2389              break;              break;
2390            default: // IdTitleReportEmpty:            default: // IdTitleReportEmpty:
2391              SendOSCstr("L", 0);              SendOSCstr("L", 0, ST);
2392              break;              break;
2393          }          }
2394          break;          break;
# Line 2417  void CSSetLRScrollRegion()     // DECSLRM Line 2416  void CSSetLRScrollRegion()     // DECSLRM
2416                    len = _snprintf_s_l(Report, sizeof(Report), _TRUNCATE, "l%s", CLocale, cv.TitleRemote);                    len = _snprintf_s_l(Report, sizeof(Report), _TRUNCATE, "l%s", CLocale, cv.TitleRemote);
2417                  }                  }
2418              }              }
2419              SendOSCstr(Report, len);              SendOSCstr(Report, len, ST);
2420              break;              break;
2421            default: // IdTitleReportEmpty:            default: // IdTitleReportEmpty:
2422              SendOSCstr("l", 0);              SendOSCstr("l", 0, ST);
2423              break;              break;
2424          }          }
2425          break;          break;
# Line 4165  void DeviceControl(BYTE b) Line 4164  void DeviceControl(BYTE b)
4164                          }                          }
4165                  }                  }
4166                  else {                  else {
4167                          ParseMode = ModeSOS;                          ParseMode = ModeIgnore;
4168                          utf8_stat = 0;                          utf8_stat = 0;
4169                          IgnoreString(b);                          IgnoreString(b);
4170                  }                  }
# Line 4324  BOOL XsParseColor(char *colspec, COLORRE Line 4323  BOOL XsParseColor(char *colspec, COLORRE
4323  unsigned int XtColor2TTColor(int mode, unsigned int xt_color) {  unsigned int XtColor2TTColor(int mode, unsigned int xt_color) {
4324          unsigned int colornum = CS_UNSPEC;          unsigned int colornum = CS_UNSPEC;
4325    
4326          if (mode > 100) {          switch ((mode>=100) ? mode-100 : mode) {
                 mode -= 100;  
         }  
         switch (mode) {  
4327          case 4:          case 4:
4328                  switch (xt_color) {                  switch (xt_color) {
4329                  case 256:                  case 256:
# Line 4343  unsigned int XtColor2TTColor(int mode, u Line 4339  unsigned int XtColor2TTColor(int mode, u
4339                  case 259:                  case 259:
4340                          colornum = CS_VT_REVERSEBG;                          colornum = CS_VT_REVERSEBG;
4341                          break;                          break;
4342                    case CS_UNSPEC:
4343                            if (mode == 104) {
4344                                    colornum = CS_ANSICOLOR_ALL;
4345                            }
4346                            break;
4347                  default:                  default:
4348                          if (xt_color <= 255) {                          if (xt_color <= 255) {
4349                                  colornum = xt_color;                                  colornum = xt_color;
# Line 4364  unsigned int XtColor2TTColor(int mode, u Line 4365  unsigned int XtColor2TTColor(int mode, u
4365                  case 3:                  case 3:
4366                          colornum = CS_VT_REVERSEBG;                          colornum = CS_VT_REVERSEBG;
4367                          break;                          break;
4368                    case CS_UNSPEC:
4369                            if (mode == 105) {
4370                                    colornum = CS_SP_ALL;
4371                            }
4372                            break;
4373                  }                  }
4374                  break;                  break;
4375          case 10:          case 10:
# Line 4382  unsigned int XtColor2TTColor(int mode, u Line 4388  unsigned int XtColor2TTColor(int mode, u
4388          return colornum;          return colornum;
4389  }  }
4390    
4391  void XsProcColor(int mode, unsigned int ColorNumber, char *ColorSpec) {  void XsProcColor(int mode, unsigned int ColorNumber, char *ColorSpec, BYTE TermChar) {
4392          COLORREF color;          COLORREF color;
4393          char StrBuff[256];          char StrBuff[256];
4394          unsigned int colornum = CS_UNSPEC;          unsigned int colornum;
4395          int len;          int len;
4396    
4397          colornum = XtColor2TTColor(mode, ColorNumber);          colornum = XtColor2TTColor(mode, ColorNumber);
# Line 4403  void XsProcColor(int mode, unsigned int Line 4409  void XsProcColor(int mode, unsigned int
4409                                          "%d;rgb:%04x/%04x/%04x", CLocale, mode,                                          "%d;rgb:%04x/%04x/%04x", CLocale, mode,
4410                                          GetRValue(color)*257, GetGValue(color)*257, GetBValue(color)*257);                                          GetRValue(color)*257, GetGValue(color)*257, GetBValue(color)*257);
4411                          }                          }
4412                          SendOSCstr(StrBuff, len);                          SendOSCstr(StrBuff, len, TermChar);
4413                  }                  }
4414                  else if (XsParseColor(ColorSpec, &color)) {                  else if (XsParseColor(ColorSpec, &color)) {
4415                          DispSetColor(colornum, color);                          DispSetColor(colornum, color);
# Line 4477  void XsProcClipboard(PCHAR buff) Line 4483  void XsProcClipboard(PCHAR buff)
4483          }          }
4484  }  }
4485    
 #define ModeXsFirst     1  
 #define ModeXsString    2  
 #define ModeXsColorNum  3  
 #define ModeXsColorSpec 4  
 #define ModeXsEsc       5  
 #define ModeXsIgnore    6  
   
 #define CheckST(b,uf)   (((b)==ST && Accept8BitCtrl && !(ts.Language==IdJapanese && ts.KanjiCode==IdSJIS) && (uf)==0) || (b)==BEL)  
   
4486  void XSequence(BYTE b)  void XSequence(BYTE b)
4487  {  {
4488          static BYTE XsParseMode = ModeXsFirst, PrevMode;          static char *StrBuff = NULL;
4489          static char StrBuff[sizeof(ts.Title)];          static unsigned int StrLen = 0, StrBuffSize = 0;
         static unsigned int ColorNumber, StrLen;  
4490          static int utf8_stat = 0;          static int utf8_stat = 0;
4491          static char realloc_failed = FALSE;          static char realloc_failed = FALSE;
4492          char *p;          static BOOL ESCflag = FALSE, HasParamStr = FALSE;
4493            char *p, *color_spec;
4494          unsigned int new_size;          unsigned int new_size;
4495            int color_num;
4496            BYTE TermChar;
4497    
4498          switch (XsParseMode) {          TermChar = 0;
4499            case ModeXsFirst:  
4500                  if (CheckST(b, utf8_stat)) {          if (ESCflag) {
4501                          switch (Param[1]) {                  ESCflag = FALSE;
4502                          case 104:                  if (b == '\\') {
4503                                  DispResetColor(CS_ANSICOLOR_ALL);                          TermChar = ST;
4504                                  break;                  }
4505                          case 110:                  else {  // Invalid Sequence
4506                          case 111:                          ParseMode = ModeIgnore;
4507                          case 115:                          HasParamStr = FALSE;
4508                          case 116:                          IgnoreString(b);
4509                                  DispResetColor(XtColor2TTColor(Param[1], 0));                          return;
                                 break;  
                         }  
                         ParseMode = ModeFirst;  
                         XsParseMode = ModeXsFirst;  
                         utf8_stat = 0;  
                 }  
                 else if (b == ESC) { /* Escape */  
                         PrevMode = ModeXsFirst;  
                         XsParseMode = ModeXsEsc;  
                         utf8_stat = 0;  
                 }  
                 else if (b <= US) { /* Other control character -- invalid sequence */  
                         ParseMode = ModeFirst;  
                         XsParseMode = ModeXsFirst;  
                         utf8_stat = 0;  
4510                  }                  }
4511                  else if (isdigit(b)) {          }
4512                          Param[1] = Param[1]*10 + b - '0';          else if (b == BEL) {
4513                    TermChar = BEL;
4514            }
4515            else if (b==ST && Accept8BitCtrl && !(ts.Language==IdJapanese && ts.KanjiCode==IdSJIS) && utf8_stat==0) {
4516                    TermChar = ST;
4517            }
4518    
4519            if (TermChar) {
4520                    if (StrBuff) {
4521                            if (StrLen < StrBuffSize) {
4522                                    StrBuff[StrLen] = '\0';
4523                            }
4524                            else {
4525                                    StrBuff[StrBuffSize-1] = '\0';
4526                            }
4527                  }                  }
4528                  else if (b == ';') {                  switch (Param[1]) {
4529                          StrBuff[0] = '\0';                  case 0: /* Change window title and icon name */
4530                          StrLen = 0;                  case 1: /* Change icon name */
4531                          switch (Param[1]) {                  case 2: /* Change window title */
4532                          case 4:                          if (StrBuff && ts.AcceptTitleChangeRequest) {
4533                          case 5:                                  strncpy_s(cv.TitleRemote, sizeof(cv.TitleRemote), StrBuff, _TRUNCATE);
4534                          case 104:                                  // (2006.6.15 maya) タイトルに渡す文字列をSJISに変換
4535                          case 105:                                  ConvertToCP932(cv.TitleRemote, sizeof(cv.TitleRemote));
4536                                  ColorNumber = 0;                                  ChangeTitle();
4537                                  XsParseMode = ModeXsColorNum;                          }
4538                                  break;                          break;
4539                          case 10:                  case 4: /* Change/Query color palette */
4540                          case 11:                  case 5: /* Change/Query special color */
4541                          case 15:                          if (StrBuff) {
4542                          case 16:                                  color_num = 0;
4543                                  ColorNumber = 0;                                  color_spec = NULL;
4544                                  XsParseMode = ModeXsColorSpec;                                  for (p = StrBuff; *p; p++) {
4545                                  break;                                          if (color_spec == NULL) {
4546                          case 52:                                                  if (isdigit(*p)) {
4547                                  if ((ts.CtrlFlag & CSF_CBRW) == 0 || ts.MaxOSCBufferSize == 0) {                                                          color_num = color_num * 10 + *p - '0';
4548                                          XsParseMode = ModeXsIgnore;                                                  }
4549                                          break;                                                  else if (*p == ';') {
4550                                  }                                                          color_spec = p+1;
4551                                  if (OSCStrBuff == NULL) {                                                  }
4552                                          new_size = sizeof(ts.Title);                                                  else {
4553                                          if (new_size > ts.MaxOSCBufferSize) {                                                          break;
4554                                                  new_size = ts.MaxOSCBufferSize;                                                  }
4555                                          }                                          }
4556                                          OSCStrBuff = malloc(new_size);                                          else {
4557                                          if (OSCStrBuff == NULL) {                                                  if (*p == ';') {
4558                                                  XsParseMode = ModeXsIgnore;                                                          *p = '\0';
4559                                                  break;                                                          XsProcColor(Param[1], color_num, color_spec, TermChar);
4560                                                            color_num = 0;
4561                                                            color_spec = NULL;
4562                                                    }
4563                                          }                                          }
                                         OSCStrBuffSize = new_size;  
4564                                  }                                  }
4565                                  XsParseMode = ModeXsString;                                  if (color_spec) {
4566                                  break;                                          XsProcColor(Param[1], color_num, color_spec, TermChar);
4567                          case 110:                                  }
                         case 111:  
                         case 115:  
                         case 116:  
                                 DispResetColor(XtColor2TTColor(Param[1], 0));  
                                 break;  
                         default:  
                                 XsParseMode = ModeXsString;  
4568                          }                          }
4569                  }                          break;
4570                  else {                  case 10: /* Change/Query VT-Window foreground color */
4571                          XsParseMode = ModeXsIgnore;                  case 11: /* Change/Query VT-Window background color */
4572                          XSequence(b);                  case 12: /* Change/Query VT-Window cursor color */
4573                  }                  case 13: /* Change/Query mouse cursor foreground color */
4574                  break;                  case 14: /* Change/Query mouse cursor background color */
4575            case ModeXsString:                  case 15: /* Change/Query Tek-Window foreground color */
4576                  if (CheckST(b, utf8_stat)) {                  case 16: /* Change/Query Tek-Window foreground color */
4577                          switch (Param[1]) {                  case 17: /* Change/Query highlight background color */
4578                            case 0: /* Change window title and icon name */                  case 18: /* Change/Query Tek-Window cursor color */
4579                            case 1: /* Change icon name */                  case 19: /* Change/Query highlight foreground color */
4580                            case 2: /* Change window title */                          if (StrBuff) {
4581                                  StrBuff[StrLen] = '\0';                                  color_num = Param[1];
4582                                  if (ts.AcceptTitleChangeRequest) {                                  color_spec = StrBuff;
4583                                          strncpy_s(cv.TitleRemote, sizeof(cv.TitleRemote), StrBuff, _TRUNCATE);                                  for (p = StrBuff; *p; p++) {
4584                                          // (2006.6.15 maya) タイトルに渡す文字列をSJISに変換                                          if (*p == ';') {
4585                                          ConvertToCP932(cv.TitleRemote, sizeof(cv.TitleRemote));                                                  *p = '\0';
4586                                          ChangeTitle();                                                  XsProcColor(color_num, 0, color_spec, TermChar);
4587                                                    color_num++;
4588                                                    color_spec = p+1;
4589                                            }
4590                                  }                                  }
4591                                  break;                                  XsProcColor(color_num, 0, color_spec, TermChar);
                           case 52: /* Clipboard access */  
                                 OSCStrBuff[StrLen] = '\0';  
                                 XsProcClipboard(OSCStrBuff);  
   
                                 break;  
                           default:  
                                 /* nothing to do */;  
4592                          }                          }
4593                          ParseMode = ModeFirst;                          break;
4594                          XsParseMode = ModeXsFirst;                  case 52: /* Manipulate Clipboard data */
4595                          utf8_stat = 0;                          if (StrBuff) {
4596                  }                                  XsProcClipboard(StrBuff);
4597                  else if (b == ESC) { /* Escape */                          }
4598                          PrevMode = ModeXsString;                          break;
4599                          XsParseMode = ModeXsEsc;                  case 104: /* Reset color palette */
4600                          utf8_stat = 0;                  case 105: /* Reset special color */
4601                  }                          if (HasParamStr) {
4602                  else if (b <= US) { /* Other control character -- invalid sequence */                                  if (StrBuff) {
4603                          ParseMode = ModeFirst;                                          color_num = 0;
4604                          XsParseMode = ModeXsFirst;                                          for (p = StrBuff; *p; p++) {
4605                          utf8_stat = 0;                                                  if (isdigit(*p)) {
4606                  }                                                          color_num = color_num * 10 + *p - '0';
4607                  else {                                                  }
4608                          utf8_stat = CheckUTF8Seq(b, utf8_stat);                                                  else if (*p == ';') {
4609                          if (Param[1] == 52) {                                                          DispResetColor(XtColor2TTColor(Param[1], color_num));
4610                                  if (StrLen < OSCStrBuffSize - 1) {                                                          color_num = 0;
4611                                          OSCStrBuff[StrLen++] = b;                                                  }
4612                                                    else {
4613                                                            color_num = CS_UNSPEC;
4614                                                    }
4615                                            }
4616                                            if (color_num != CS_UNSPEC) {
4617                                                    DispResetColor(XtColor2TTColor(Param[1], color_num));
4618                                            }
4619                                  }                                  }
4620                                  else if (!realloc_failed && OSCStrBuffSize < ts.MaxOSCBufferSize) {                          }
4621                                          new_size = OSCStrBuffSize * 2;                          else {
4622                                          if (new_size > ts.MaxOSCBufferSize) {                                  DispResetColor(XtColor2TTColor(Param[1], CS_UNSPEC));
4623                                                  new_size = ts.MaxOSCBufferSize;                          }
4624                            break;
4625                    case 110: /* Reset VT-Window foreground color */
4626                    case 111: /* Reset VT-Window background color */
4627                    case 112: /* Reset VT-Window cursor color */
4628                    case 113: /* Reset mouse cursor foreground color */
4629                    case 114: /* Reset mouse cursor background color */
4630                    case 115: /* Reset Tek-Window foreground color */
4631                    case 116: /* Reset Tek-Window foreground color */
4632                    case 117: /* Reset highlight background color */
4633                    case 118: /* Reset Tek-Window cursor color */
4634                    case 119: /* Reset highlight foreground color */
4635                            DispResetColor(XtColor2TTColor(Param[1], CS_UNSPEC));
4636                            if (HasParamStr && StrBuff) {
4637                                    color_num = 0;
4638                                    for (p = StrBuff; *p; p++) {
4639                                            if (isdigit(*p)) {
4640                                                    color_num = color_num * 10 + *p - '0';
4641                                          }                                          }
4642                                            else if (*p == ';') {
4643                                          p = realloc(OSCStrBuff, new_size);                                                  DispResetColor(XtColor2TTColor(color_num, CS_UNSPEC));
4644                                          if (p == NULL) {                                                  color_num = 0;
                                                 realloc_failed = TRUE;  
4645                                          }                                          }
4646                                          else {                                          else {
4647                                                  OSCStrBuff = p;                                                  color_num = CS_UNSPEC;
4648                                                  OSCStrBuffSize = new_size;                                                  break;
                                                 if (StrLen < OSCStrBuffSize - 1) {  
                                                         OSCStrBuff[StrLen++] = b;  
                                                 }  
4649                                          }                                          }
4650                                  }                                  }
4651                                    if (color_num != CS_UNSPEC) {
4652                                            DispResetColor(XtColor2TTColor(color_num, CS_UNSPEC));
4653                                    }
4654                          }                          }
4655                          else if (StrLen < sizeof(StrBuff) - 1) {                          break;
                                 StrBuff[StrLen++] = b;  
                         }  
                 }  
                 break;  
           case ModeXsColorNum:  
                 if (CheckST(b, utf8_stat)) {  
                         if (Param[1] == 104 || Param[1] == 105) {  
                                 DispResetColor(XtColor2TTColor(Param[1], ColorNumber));  
                         }  
                         ColorNumber = 0;  
                         ParseMode = ModeFirst;  
                         XsParseMode = ModeXsFirst;  
                         utf8_stat = 0;  
                 }  
                 else if (b == ESC) { /* Escape */  
                         PrevMode = ModeXsColorNum;  
                         XsParseMode = ModeXsEsc;  
                         utf8_stat = 0;  
4656                  }                  }
4657                  else if (b <= US) { /* Other control character -- invalid sequence */                  if (StrBuff) {
4658                          ParseMode = ModeFirst;                          StrBuff[0] = '\0';
4659                          XsParseMode = ModeXsFirst;                          StrLen = 0;
                         utf8_stat = 0;  
4660                  }                  }
4661                  else if (isdigit(b)) {                  ParseMode = ModeFirst;
4662                          ColorNumber = ColorNumber*10 + b - '0';                  HasParamStr = FALSE;
4663                    utf8_stat = 0;
4664            }
4665            else if (b == ESC) {
4666                    ESCflag = TRUE;
4667                    utf8_stat = 0;
4668            }
4669            else if (b <= US) { // Invalid Character
4670                    ParseMode = ModeFirst;
4671                    HasParamStr = FALSE;
4672                    utf8_stat = 0;
4673            }
4674            else if (HasParamStr) {
4675                    utf8_stat = CheckUTF8Seq(b, utf8_stat);
4676                    if (StrLen + 1 < StrBuffSize) {
4677                            StrBuff[StrLen++] = b;
4678                  }                  }
4679                  else if (b == ';') {                  else if (!realloc_failed && StrBuffSize < ts.MaxOSCBufferSize) {
4680                          if (Param[1] == 104 || Param[1] == 105) {                          if (StrBuff == NULL || StrBuffSize == 0) {
4681                                  DispResetColor(XtColor2TTColor(Param[1], ColorNumber));                                  new_size = sizeof(ts.Title);
                                 ColorNumber = 0;  
4682                          }                          }
4683                          else {                          else {
4684                                  XsParseMode = ModeXsColorSpec;                                  new_size = StrBuffSize * 2;
4685                            }
4686                            if (new_size > ts.MaxOSCBufferSize) {
4687                                    new_size = ts.MaxOSCBufferSize;
4688                          }                          }
                 }  
                 else {  
                         XsParseMode = ModeXsIgnore;  
                         XSequence(b);  
                 }  
                 break;  
           case ModeXsColorSpec:  
                 if (CheckST(b, utf8_stat)) {  
                         StrBuff[StrLen] = '\0';  
                         XsProcColor(Param[1], ColorNumber, StrBuff);  
                         ParseMode = ModeFirst;  
                         XsParseMode = ModeXsFirst;  
                 }  
                 else if (b == ESC) {  
                         PrevMode = ModeXsColorSpec;  
                         XsParseMode = ModeXsEsc;  
                 }  
                 else if (b <= US) { /* Other control character -- invalid sequence */  
                         ParseMode = ModeFirst;  
                         XsParseMode = ModeXsFirst;  
                 }  
                 else if (b == ';') {  
                         StrBuff[StrLen] = '\0';  
                         XsProcColor(Param[1], ColorNumber, StrBuff);  
   
                         ColorNumber = 0;  
                         StrBuff[0] = '\0';  
                         StrLen = 0;  
4689    
4690                          switch (Param[1]) {                          p = realloc(StrBuff, new_size);
4691                          case 4:                          if (p == NULL) {
4692                          case 5:                                  if (StrBuff==NULL) {
4693                                  XsParseMode = ModeXsColorNum;                                          StrBuffSize = 0;
4694                                  break;                                          ParseMode = ModeIgnore;
4695                          case 10:                                          HasParamStr = FALSE;
4696                          case 11:                                          IgnoreString(b);
4697                          case 12:                                          return;
4698                          case 13:                                  }
4699                          case 14:                                  realloc_failed = TRUE;
4700                          case 15:                          }
4701                          case 16:                          else {
4702                          case 17:                                  StrBuff = p;
4703                                  XsParseMode = ModeXsColorSpec;                                  StrBuffSize = new_size;
4704                                  Param[1]++;                                  if (StrLen + 1 < StrBuffSize) {
4705                                  break;                                          StrBuff[StrLen++] = b;
4706                          default:                                  }
                                 XsParseMode = ModeXsIgnore;  
                                 break;  
4707                          }                          }
4708                  }                  }
4709                  else if (b >= 0x80) {          }
4710                  }          else if (isdigit(b)) {
4711                  else if (StrLen < sizeof(StrBuff) - 1) {                  Param[1] = Param[1] * 10 + b - '0';
4712                          StrBuff[StrLen++] = b;          }
4713                  }          else if (b == ';') {
4714                  break;                  HasParamStr = TRUE;
4715            case ModeXsEsc:          }
4716                  if (b == '\\') { /* String Terminator */          else {
4717                          XsParseMode = PrevMode;                  ParseMode = ModeIgnore;
4718                          XSequence(BEL);                  HasParamStr = FALSE;
4719                  }                  IgnoreString(b);
                 else { /* Other character -- invalid sequence */  
                         ICount = 0;  
                         JustAfterESC = TRUE;  
                         ParseMode = ModeESC;  
                         XsParseMode = ModeXsFirst;  
                         utf8_stat = 0;  
                         EscapeSequence(b);  
                 }  
                 break;  
           case ModeXsIgnore:  
                 if (CheckST(b, utf8_stat)) {  
                         ParseMode = ModeFirst;  
                         XsParseMode = ModeXsFirst;  
                 }  
                 else if (b == ESC) {  
                         utf8_stat = 0;  
                         PrevMode = ModeXsIgnore;  
                         XsParseMode = ModeXsEsc;  
                 }  
                 else {  
                         utf8_stat = CheckUTF8Seq(b, utf8_stat);  
                 }  
                 break;  
4720          }          }
4721  }  }
4722    
# Line 5416  int VTParse() Line 5373  int VTParse()
5373          case ModeXS:  XSequence(b); break;          case ModeXS:  XSequence(b); break;
5374          case ModeDLE: DLESeen(b); break;          case ModeDLE: DLESeen(b); break;
5375          case ModeCAN: CANSeen(b); break;          case ModeCAN: CANSeen(b); break;
5376            case ModeIgnore: IgnoreString(b); break;
5377          default:          default:
5378            ParseMode = ModeFirst;            ParseMode = ModeFirst;
5379            ParseFirst(b);            ParseFirst(b);
# Line 5772  void EndTerm() { Line 5730  void EndTerm() {
5730          if (CLocale) {          if (CLocale) {
5731                  _free_locale(CLocale);                  _free_locale(CLocale);
5732          }          }
         if (OSCStrBuff) {  
                 free(OSCStrBuff);  
                 OSCStrBuff = NULL;  
                 OSCStrBuffSize = 0;  
         }  
5733          CLocale = NULL;          CLocale = NULL;
5734  }  }
5735    

Legend:
Removed from v.5907  
changed lines
  Added in v.5911

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26