Changeset 1045 for trunk/tools/assistant


Ignore:
Timestamp:
Sep 2, 2011, 2:18:55 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: Fix Qt Assistant remote control.

The commands were only processed if terminated with '\0' while
'\n' should also be interpreted as a terminator. This is an r701
regression.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/assistant/tools/assistant/remotecontrol.cpp

    r846 r1045  
    8686    TRACE_OBJ
    8787    char chBuf[4096];
    88     size_t pos = 0;
    8988    ULONG ulRead;
     89
    9090
    9191    HFILE hStdinDup = HFILE(~0);
     
    9494
    9595    while (arc == NO_ERROR) {
    96         arc = DosRead(hStdinDup, chBuf + pos, sizeof(chBuf) - pos, &ulRead);
     96        arc = DosRead(hStdinDup, chBuf, &ulRead);
    9797        if (arc == NO_ERROR && ulRead != 0) {
    98             size_t totalRead = pos + ulRead;
    99             size_t len = ulRead;
    100             char *start = chBuf, *zero = chBuf + pos;
    101             // send all complete commands
    102             while (len && (zero = static_cast<char *>(memchr(zero, '\0', len)))) {
    103                 emit receivedCommand(QString::fromLocal8Bit(start));
    104                 start = ++zero;
    105                 len = totalRead - (start - chBuf);
     98           
     99            ;
     100            ;
     101           
     102           
     103                ;
     104               
     105                ;
    106106            }
    107             if (start != chBuf) {
    108                 // move the incomplete portion to the beginning
    109                 memcpy(chBuf, start, len);
    110                 pos = len;
    111             } else {
    112                 pos = totalRead;
    113                 if (pos == sizeof(chBuf)) {
    114                     // buffer full, emit the command anyway and start over
    115                     QByteArray cmd(chBuf, sizeof(chBuf));
    116                     emit receivedCommand(QString::fromLocal8Bit(cmd));
    117                     pos = 0;
    118                 }
     107            cmd.append(chBuf, i);
     108            if (gotIt) {
     109                emit receivedCommand(QString::fromLocal8Bit(cmd));
     110                cmd.clear();
     111                // get the remains if any
     112                cmd.append(chBuf + i, ulRead - i);
    119113            }
    120114        }
     
    149143    hStdinDup = stdin;
    150144#endif
    151 
    152     // ### do the same as in the OS/2 version above
    153145
    154146    while (ok) {
Note: See TracChangeset for help on using the changeset viewer.