Ticket #9293: 0003-Style-cleanup-no-functional-change-intended.patch

File 0003-Style-cleanup-no-functional-change-intended.patch, 8.1 KB (added by Ziusudra, 11 years ago)
  • src/apps/terminal/TermParse.cpp

    From fe1df1ea028f30b85b3b92f2400c6132658ea320 Mon Sep 17 00:00:00 2001
    From: Ziusudra <ziusudra@gmail.com>
    Date: Sat, 15 Dec 2012 20:49:03 -0700
    Subject: [PATCH 3/9] Style cleanup, no functional change intended
    
     - Also added comments explaining which ACS characters we have
    ---
     src/apps/terminal/TermParse.cpp |  166 +++++++++++++++++++--------------------
     1 file changed, 82 insertions(+), 84 deletions(-)
    
    diff --git a/src/apps/terminal/TermParse.cpp b/src/apps/terminal/TermParse.cpp
    index 0ae798a..8b48806 100644
    a b TermParse::PtyReader()  
    252252        }
    253253
    254254        // Copy read string to PtyBuffer.
    255 
    256255        int32 left = READ_BUF_SIZE - readPos;
    257256
    258257        if (nread >= left) {
    TermParse::DumpState(int *groundtable, int *parsestate, uchar c)  
    297296        T(gMbcsTable),
    298297        { NULL, NULL }
    299298    };
    300     int i;
    301299    fprintf(stderr, "groundtable: ");
    302     for (i = 0; tables[i].p; i++) {
     300    for (int i = 0; tables[i].p; i++) {
    303301        if (tables[i].p == groundtable)
    304302            fprintf(stderr, "%s\t", tables[i].name);
    305303    }
    306304    fprintf(stderr, "parsestate: ");
    307     for (i = 0; tables[i].p; i++) {
     305    for (int i = 0; tables[i].p; i++) {
    308306        if (tables[i].p == parsestate)
    309307            fprintf(stderr, "%s\t", tables[i].name);
    310308    }
    TermParse::EscParse()  
    406404                currentEncoding = fBuffer->Encoding();
    407405            }
    408406
    409     //debug_printf("TermParse: char: '%c' (%d), parse state: %d\n", c, c, parsestate[c]);
     407    //debug_printf("TermParse: char: '%c' (%d), parse state: %d\n",
     408    //  c, c, parsestate[c]);
    410409            switch (parsestate[c]) {
    411410                case CASE_PRINT:
    412411                    fBuffer->InsertChar((char)c, fAttr);
    TermParse::EscParse()  
    481480                case CASE_PRINT_GRA:
    482481                    /* "Special characters and line drawing" enabled by \E(0 */
    483482                    switch (c) {
    484                         case 'a':
     483                        case 'a': // ACS_CKBOARD
    485484                            fBuffer->InsertChar("\xE2\x96\x92",3,fAttr);
    486485                            break;
    487                         case 'j':
     486                        case 'j': // ACS_LRCORNER
    488487                            fBuffer->InsertChar("\xE2\x94\x98",3,fAttr);
    489488                            break;
    490                         case 'k':
     489                        case 'k': // ACS_URCORNER
    491490                            fBuffer->InsertChar("\xE2\x94\x90",3,fAttr);
    492491                            break;
    493                         case 'l':
     492                        case 'l': // ACS_ULCORNER
    494493                            fBuffer->InsertChar("\xE2\x94\x8C",3,fAttr);
    495494                            break;
    496                         case 'm':
     495                        case 'm': // ACS_LLCORNER
    497496                            fBuffer->InsertChar("\xE2\x94\x94",3,fAttr);
    498497                            break;
    499                         case 'n':
     498                        case 'n': // ACS_PLUS
    500499                            fBuffer->InsertChar("\xE2\x94\xBC",3,fAttr);
    501500                            break;
    502                         case 'q':
     501                        case 'q': // ACS_HLINE
    503502                            fBuffer->InsertChar("\xE2\x94\x80",3,fAttr);
    504503                            break;
    505                         case 't':
     504                        case 't': // ACS_LTEE
    506505                            fBuffer->InsertChar("\xE2\x94\x9C",3,fAttr);
    507506                            break;
    508                         case 'u':
     507                        case 'u': // ACS_RTEE
    509508                            fBuffer->InsertChar("\xE2\x94\xA4",3,fAttr);
    510509                            break;
    511                         case 'v':
     510                        case 'v': // ACS_BTEE
    512511                            fBuffer->InsertChar("\xE2\x94\xB4",3,fAttr);
    513512                            break;
    514                         case 'w':
     513                        case 'w': // ACS_TTEE
    515514                            fBuffer->InsertChar("\xE2\x94\xAC",3,fAttr);
    516515                            break;
    517                         case 'x':
     516                        case 'x': // ACS_VLINE
    518517                            fBuffer->InsertChar("\xE2\x94\x82",3,fAttr);
    519518                            break;
    520519                        default:
    TermParse::EscParse()  
    924923                }
    925924
    926925                case CASE_CPR:
    927                 // Q & D hack by Y.Hayakawa (hida@sawada.riec.tohoku.ac.jp)
    928                 // 21-JUL-99
    929                 _DeviceStatusReport(param[0]);
    930                 parsestate = groundtable;
    931                 break;
     926                    // Q & D hack by Y.Hayakawa 21-JUL-99
     927                    // (hida@sawada.riec.tohoku.ac.jp)
     928                    _DeviceStatusReport(param[0]);
     929                    parsestate = groundtable;
     930                    break;
    932931
    933932                case CASE_DA1:
    934                 // DA - report device attributes
    935                 if (param[0] < 1) {
    936                     // claim to be a VT102
    937                     write(fFd, "\033[?6c", 5);
    938                 }
    939                 parsestate = groundtable;
    940                 break;
     933                    // DA - report device attributes
     934                    if (param[0] < 1) {
     935                        // claim to be a VT102
     936                        write(fFd, "\033[?6c", 5);
     937                    }
     938                    parsestate = groundtable;
     939                    break;
    941940
    942941                case CASE_DECSTBM:
    943                 /* DECSTBM - set scrolling region */
    944 
    945                 if ((top = param[0]) < 1)
    946                     top = 1;
     942                    /* DECSTBM - set scrolling region */
     943                    if ((top = param[0]) < 1)
     944                        top = 1;
    947945
    948                 if (nparam < 2)
    949                     bottom = fBuffer->Height();
    950                 else
    951                     bottom = param[1];
     946                    if (nparam < 2)
     947                        bottom = fBuffer->Height();
     948                    else
     949                        bottom = param[1];
    952950
    953                 top--;
     951                    top--;
    954952                    bottom--;
    955953
    956954                    if (bottom > top)
    TermParse::EscParse()  
    985983                    parsestate = groundtable;
    986984                    break;
    987985
    988                     //  case CASE_GSETS:
    989                     //      screen->gsets[scstype] = GSET(c) | cs96;
    990                     //      parsestate = groundtable;
    991                     //      break;
     986                //case CASE_GSETS:
     987                //  screen->gsets[scstype] = GSET(c) | cs96;
     988                //  parsestate = groundtable;
     989                //  break;
    992990
    993991                case CASE_DECSC:
    994992                    /* DECSC */
    TermParse::EscParse()  
    10431041                    break;
    10441042
    10451043                case CASE_OSC:
    1046                     {
    1047                         /* Operating System Command: ESC ] */
    1048                         char string[512];
    1049                         uint32 len = 0;
    1050                         uchar mode_char = _NextParseChar();
    1051                         if (mode_char != '0'
    1052                                 && mode_char != '1'
    1053                                 && mode_char != '2') {
    1054                             parsestate = groundtable;
     1044                {
     1045                    /* Operating System Command: ESC ] */
     1046                    char string[512];
     1047                    uint32 len = 0;
     1048                    uchar mode_char = _NextParseChar();
     1049                    if (mode_char != '0'
     1050                            && mode_char != '1'
     1051                            && mode_char != '2') {
     1052                        parsestate = groundtable;
     1053                        break;
     1054                    }
     1055                    uchar currentChar = _NextParseChar();
     1056                    while ((currentChar = _NextParseChar()) != 0x7) {
     1057                        if (!isprint(currentChar & 0x7f)
     1058                                || len+2 >= sizeof(string))
    10551059                            break;
    1056                         }
    1057                         uchar currentChar = _NextParseChar();
    1058                         while ((currentChar = _NextParseChar()) != 0x7) {
    1059                             if (!isprint(currentChar & 0x7f)
    1060                                     || len+2 >= sizeof(string))
     1060                        string[len++] = currentChar;
     1061                    }
     1062                    if (currentChar == 0x7) {
     1063                        string[len] = '\0';
     1064                        switch (mode_char) {
     1065                            case '0':
     1066                            case '2':
     1067                                fBuffer->SetTitle(string);
     1068                                break;
     1069                            case '1':
    10611070                                break;
    1062                             string[len++] = currentChar;
    1063                         }
    1064                         if (currentChar == 0x7) {
    1065                             string[len] = '\0';
    1066                             switch (mode_char) {
    1067                                 case '0':
    1068                                 case '2':
    1069                                     fBuffer->SetTitle(string);
    1070                                     break;
    1071                                 case '1':
    1072                                     break;
    1073                             }
    10741071                        }
    1075                         parsestate = groundtable;
    1076                         break;
    10771072                    }
     1073                    parsestate = groundtable;
     1074                    break;
     1075                }
    10781076
    10791077                case CASE_RIS:      // ESC c ... Reset terminal.
    10801078                    break;
    10811079
    10821080                case CASE_LS2:
    10831081                    /* LS2 */
    1084                     //      screen->curgl = 2;
     1082                    //screen->curgl = 2;
    10851083                    parsestate = groundtable;
    10861084                    break;
    10871085
    10881086                case CASE_LS3:
    10891087                    /* LS3 */
    1090                     //      screen->curgl = 3;
     1088                    //screen->curgl = 3;
    10911089                    parsestate = groundtable;
    10921090                    break;
    10931091
    10941092                case CASE_LS3R:
    10951093                    /* LS3R */
    1096                     //      screen->curgr = 3;
     1094                    //screen->curgr = 3;
    10971095                    parsestate = groundtable;
    10981096                    break;
    10991097
    11001098                case CASE_LS2R:
    11011099                    /* LS2R */
    1102                     //      screen->curgr = 2;
     1100                    //screen->curgr = 2;
    11031101                    parsestate = groundtable;
    11041102                    break;
    11051103
    11061104                case CASE_LS1R:
    11071105                    /* LS1R */
    1108                     //      screen->curgr = 1;
     1106                    //screen->curgr = 1;
    11091107                    parsestate = groundtable;
    11101108                    break;
    11111109
    TermParse::_DeviceStatusReport(int n)  
    12411239
    12421240    switch (n) {
    12431241        case 5:
    1244             {
    1245                 // Device status report requested
    1246                 // reply with "no malfunction detected"
    1247                 const char* toWrite = "\033[0n";
    1248                 write(fFd, toWrite, strlen(toWrite));
    1249                 break ;
    1250             }
     1242        {
     1243            // Device status report requested
     1244            // reply with "no malfunction detected"
     1245            const char* toWrite = "\033[0n";
     1246            write(fFd, toWrite, strlen(toWrite));
     1247            break ;
     1248        }
    12511249        case 6:
    12521250            // Cursor position report requested
    12531251            len = sprintf(sbuf, "\033[%" B_PRId32 ";%" B_PRId32 "R",
    TermParse::_DecPrivateModeReset(int value)  
    13991397            fBuffer->ReportNormalMouseEvent(false);
    14001398            break;
    14011399        case 1002:
    1402             // Don't send Mouse X and Y on button press and release, and on motion
    1403             // when the mouse enter a new cell
     1400            // Don't send Mouse X and Y on button press and release,
     1401            // and on motion when the mouse enter a new cell
    14041402            fBuffer->ReportButtonMouseEvent(false);
    14051403            break;
    14061404        case 1003: