Changeset 2915 in kBuild
- Timestamp:
- Sep 14, 2016 4:31:28 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kWorker/kWorker.c
r2912 r2915 354 354 355 355 /** 356 * Console line buffer .356 * Console line buffer or output full buffer. 357 357 */ 358 358 typedef struct KWCONSOLEOUTPUTLINE … … 362 362 /** Our backup handle. */ 363 363 HANDLE hBackup; 364 /** Set if this is a console handle. */ 364 /** Set if this is a console handle and we're in line buffered mode. 365 * When clear, we may buffer multiple lines, though try flush on line 366 * boundraries when ever possible. */ 365 367 KBOOL fIsConsole; 366 /** Amount of pending console output in wchar_t's. */ 367 KU32 cwcBuf; 368 /** The allocated buffer size. */ 369 KU32 cwcBufAlloc; 370 /** Pending console output. */ 371 wchar_t *pwcBuf; 368 KU8 abPadding[3]; 369 union 370 { 371 /** Line buffer mode (fIsConsole == K_TRUE). */ 372 struct 373 { 374 /** Amount of pending console output in wchar_t's. */ 375 KU32 cwcBuf; 376 /** The allocated buffer size. */ 377 KU32 cwcBufAlloc; 378 /** Pending console output. */ 379 wchar_t *pwcBuf; 380 } Con; 381 /** Fully buffered mode (fIsConsole == K_FALSE). */ 382 struct 383 { 384 /** Amount of pending output (in chars). */ 385 KU32 cchBuf; 386 /** The allocated buffer size (in chars). */ 387 KU32 cchBufAlloc; 388 /** Pending output. */ 389 char *pchBuf; 390 } Fully; 391 } u; 372 392 } KWCONSOLEOUTPUTLINE; 373 393 /** Pointer to a console line buffer. */ … … 5116 5136 } 5117 5137 5138 #ifdef WITH_CONSOLE_OUTPUT_BUFFERING 5139 5140 /** 5141 * Write something to a handle, making sure everything is actually written. 5142 * 5143 * @param hHandle Where to write it to. 5144 * @param pchBuf What to write 5145 * @param cchToWrite How much to write. 5146 */ 5147 static void kwSandboxOutBufWriteIt(HANDLE hFile, char const *pchBuf, KU32 cchToWrite) 5148 { 5149 if (cchToWrite > 0) 5150 { 5151 DWORD cchWritten = 0; 5152 if (WriteFile(hFile, pchBuf, cchToWrite, &cchWritten, NULL)) 5153 { 5154 if (cchWritten == cchToWrite) 5155 { /* likely */ } 5156 else 5157 { 5158 do 5159 { 5160 pchBuf += cchWritten; 5161 cchToWrite -= cchWritten; 5162 cchWritten = 0; 5163 } while ( cchToWrite > 0 5164 && WriteFile(hFile, pchBuf, cchToWrite, &cchWritten, NULL)); 5165 } 5166 } 5167 else 5168 kHlpAssertFailed(); 5169 } 5170 } 5171 5172 5173 /** 5174 * Worker for WriteFile when the output isn't going to the console. 5175 * 5176 * @param pSandbox The sandbox. 5177 * @param pOutBuf The output buffer. 5178 * @param pchBuffer What to write. 5179 * @param cchToWrite How much to write. 5180 */ 5181 static void kwSandboxOutBufWrite(PKWSANDBOX pSandbox, PKWCONSOLEOUTPUTLINE pOutBuf, const char *pchBuffer, KU32 cchToWrite) 5182 { 5183 if (pOutBuf->u.Fully.cchBufAlloc > 0) 5184 { /* likely */ } 5185 else 5186 { 5187 /* No realloc, max size is 64KB. */ 5188 pOutBuf->u.Fully.cchBufAlloc = 0x10000; 5189 pOutBuf->u.Fully.pchBuf = (char *)kHlpAlloc(pOutBuf->u.Fully.cchBufAlloc); 5190 if (!pOutBuf->u.Fully.pchBuf) 5191 { 5192 while ( !pOutBuf->u.Fully.pchBuf 5193 && pOutBuf->u.Fully.cchBufAlloc > 64) 5194 { 5195 pOutBuf->u.Fully.cchBufAlloc /= 2; 5196 pOutBuf->u.Fully.pchBuf = (char *)kHlpAlloc(pOutBuf->u.Fully.cchBufAlloc); 5197 } 5198 if (!pOutBuf->u.Fully.pchBuf) 5199 { 5200 pOutBuf->u.Fully.cchBufAlloc = sizeof(pOutBuf->abPadding); 5201 pOutBuf->u.Fully.pchBuf = pOutBuf->abPadding; 5202 } 5203 } 5204 } 5205 5206 /* 5207 * Special case: Output ends with newline and fits in the buffer. 5208 */ 5209 if ( cchToWrite > 1 5210 && pchBuffer[cchToWrite - 1] == '\n' 5211 && cchToWrite <= pOutBuf->u.Fully.cchBufAlloc - pOutBuf->u.Fully.cchBuf) 5212 { 5213 memcpy(&pOutBuf->u.Fully.pchBuf[pOutBuf->u.Fully.cchBuf], pchBuffer, cchToWrite); 5214 pOutBuf->u.Fully.cchBuf += cchToWrite; 5215 } 5216 else 5217 { 5218 /* 5219 * Work thru the text line by line, flushing the buffer when 5220 * appropriate. The buffer is not a line buffer here, it's a 5221 * full buffer. 5222 */ 5223 while (cchToWrite > 0) 5224 { 5225 char const *pchNewLine = (char *)memchr(pchBuffer, '\n', cchToWrite); 5226 KU32 cchLine = pchNewLine ? (KU32)(pchNewLine - pchBuffer) + 1 : cchToWrite; 5227 if (cchLine <= pOutBuf->u.Fully.cchBufAlloc - pOutBuf->u.Fully.cchBuf) 5228 { 5229 memcpy(&pOutBuf->u.Fully.pchBuf[pOutBuf->u.Fully.cchBuf], pchBuffer, cchLine); 5230 pOutBuf->u.Fully.cchBuf += cchLine; 5231 } 5232 /* 5233 * Option one: Flush the buffer and the current line. 5234 * 5235 * We choose this one when the line won't ever fit, or when we have 5236 * an incomplete line in the buffer. 5237 */ 5238 else if ( cchLine >= pOutBuf->u.Fully.cchBufAlloc 5239 || pOutBuf->u.Fully.cchBuf == 0 5240 || pOutBuf->u.Fully.pchBuf[pOutBuf->u.Fully.cchBuf - 1] != '\n') 5241 { 5242 if (pOutBuf->u.Fully.cchBuf > 0) 5243 { 5244 kwSandboxOutBufWriteIt(pOutBuf->hBackup, pOutBuf->u.Fully.pchBuf, pOutBuf->u.Fully.cchBuf); 5245 pOutBuf->u.Fully.cchBuf = 0; 5246 } 5247 kwSandboxOutBufWriteIt(pOutBuf->hBackup, pchBuffer, cchLine); 5248 } 5249 /* 5250 * Option two: Only flush the lines in the buffer. 5251 */ 5252 else 5253 { 5254 kwSandboxOutBufWriteIt(pOutBuf->hBackup, pOutBuf->u.Fully.pchBuf, pOutBuf->u.Fully.cchBuf); 5255 memcpy(&pOutBuf->u.Fully.pchBuf[0], pchBuffer, cchLine); 5256 pOutBuf->u.Fully.cchBuf = cchLine; 5257 } 5258 5259 /* advance */ 5260 pchBuffer += cchLine; 5261 cchToWrite -= cchLine; 5262 } 5263 } 5264 } 5265 #endif /* WITH_CONSOLE_OUTPUT_BUFFERING */ 5266 5118 5267 #ifdef WITH_TEMP_MEMORY_FILES 5119 5268 … … 5272 5421 return TRUE; 5273 5422 } 5423 kwSandboxOutBufWrite(&g_Sandbox, pLineBuf, (const char *)pvBuffer, cbToWrite); 5424 KWFS_LOG(("WriteFile(stdout/err) -> TRUE\n", hFile)); 5425 return TRUE; 5274 5426 } 5275 5427 #endif … … 5815 5967 off += cwcWritten; 5816 5968 cwcWritten = 0; 5817 } 5818 while ( off < cwcToWrite 5819 && WriteConsoleW(pSandbox->Combined.hOutput, &pwcBuf[off], cwcToWrite - off, &cwcWritten, NULL)); 5969 } while ( off < cwcToWrite 5970 && WriteConsoleW(pSandbox->Combined.hOutput, &pwcBuf[off], cwcToWrite - off, &cwcWritten, NULL)); 5820 5971 kHlpAssert(off == cwcWritten); 5821 5972 } … … 5877 6028 static void kwSandboxConsoleFinalFlushLineBuf(PKWSANDBOX pSandbox, PKWCONSOLEOUTPUTLINE pLineBuf) 5878 6029 { 5879 if (pLineBuf-> cwcBuf > 0)5880 { 5881 if (pLineBuf-> fIsConsole)5882 { 5883 if (pLineBuf-> cwcBuf < pLineBuf->cwcBufAlloc)5884 { 5885 pLineBuf-> pwcBuf[pLineBuf->cwcBuf++] = '\n';5886 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf-> pwcBuf, pLineBuf->cwcBuf, K_FALSE /*fBrokenLine*/);6030 if (pLineBuf->fIsConsole) 6031 { 6032 if (pLineBuf->u.Con.cwcBuf > 0) 6033 { 6034 if (pLineBuf->u.Con.cwcBuf < pLineBuf->u.Con.cwcBufAlloc) 6035 { 6036 pLineBuf->u.Con.pwcBuf[pLineBuf->u.Con.cwcBuf++] = '\n'; 6037 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf, K_FALSE /*fBrokenLine*/); 5887 6038 } 5888 6039 else 5889 6040 { 5890 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf-> pwcBuf, pLineBuf->cwcBuf, K_TRUE /*fBrokenLine*/);6041 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf, K_TRUE /*fBrokenLine*/); 5891 6042 kwSandboxConsoleAddToCombined(pSandbox, L"\n", 1, K_TRUE /*fBrokenLine*/); 5892 6043 } 5893 pLineBuf->cwcBuf = 0; 5894 } 5895 else 5896 { 5897 kHlpAssertFailed(); 5898 } 6044 pLineBuf->u.Con.cwcBuf = 0; 6045 } 6046 } 6047 else if (pLineBuf->u.Fully.cchBuf > 0) 6048 { 6049 kwSandboxOutBufWriteIt(pLineBuf->hBackup, pLineBuf->u.Fully.pchBuf, pLineBuf->u.Fully.cchBuf); 6050 pLineBuf->u.Fully.cchBuf = 0; 5899 6051 } 5900 6052 } … … 5910 6062 /* 5911 6063 * First do the cl.exe source file supression trick, if applicable. 6064 * The output ends up on CONOUT$ if either StdOut or StdErr is a console 6065 * handle. 5912 6066 */ 5913 if ( pSandbox->Combined.cwcBuf >= 3 5914 && pSandbox->StdOut.cwcBuf == 0 5915 && pSandbox->StdErr.cwcBuf == 0 5916 && pSandbox->Combined.cFlushes == 0 5917 && pSandbox->pTool->u.Sandboxed.enmHint == KWTOOLHINT_VISUAL_CPP_CL) 5918 { 5919 KI32 off = pSandbox->Combined.cwcBuf - 1; 5920 if (pSandbox->Combined.wszBuf[off] == '\n') 5921 { 5922 KBOOL fOk = K_TRUE; 5923 while (off-- > 0) 5924 { 5925 wchar_t const wc = pSandbox->Combined.wszBuf[off]; 5926 if (iswalnum(wc) || wc == '.' || wc == ' ' || wc == '_' || wc == '-') 5927 { /* likely */ } 5928 else 6067 if ( pSandbox->pTool->u.Sandboxed.enmHint == KWTOOLHINT_VISUAL_CPP_CL 6068 && pSandbox->Combined.cFlushes == 0) 6069 { 6070 if ( pSandbox->StdOut.fIsConsole 6071 || pSandbox->StdErr.fIsConsole) 6072 { 6073 if ( pSandbox->Combined.cwcBuf >= 3 6074 && (pSandbox->StdOut.fIsConsole ? pSandbox->StdOut.u.Con.cwcBuf : pSandbox->StdOut.u.Fully.cchBuf) == 0 6075 && (pSandbox->StdErr.fIsConsole ? pSandbox->StdErr.u.Con.cwcBuf : pSandbox->StdErr.u.Fully.cchBuf) == 0 ) 6076 { 6077 KI32 off = pSandbox->Combined.cwcBuf - 1; 6078 if (pSandbox->Combined.wszBuf[off] == '\n') 5929 6079 { 5930 fOk = K_FALSE; 5931 break; 6080 KBOOL fOk = K_TRUE; 6081 while (off-- > 0) 6082 { 6083 wchar_t const wc = pSandbox->Combined.wszBuf[off]; 6084 if (iswalnum(wc) || wc == '.' || wc == ' ' || wc == '_' || wc == '-') 6085 { /* likely */ } 6086 else 6087 { 6088 fOk = K_FALSE; 6089 break; 6090 } 6091 } 6092 if (fOk) 6093 { 6094 pSandbox->Combined.cwcBuf = 0; 6095 return; 6096 } 5932 6097 } 5933 6098 } 5934 if (fOk) 5935 { 5936 pSandbox->Combined.cwcBuf = 0; 5937 return; 6099 } 6100 /* 6101 * Otherwise, it goes to standard error. 6102 */ 6103 else if ( pSandbox->StdOut.u.Fully.cchBuf == 0 6104 && pSandbox->StdErr.u.Fully.cchBuf >= 3) 6105 { 6106 char const *pchBuf = pSandbox->StdErr.u.Fully.pchBuf; 6107 KI32 off = pSandbox->StdErr.u.Fully.cchBuf - 1; 6108 kHlpAssert(pSandbox->Combined.cFlushes == 0 && pSandbox->Combined.cwcBuf == 0); /* unused! */ 6109 6110 if (pchBuf[off] == '\n') 6111 { 6112 KBOOL fOk = K_TRUE; 6113 if (pchBuf[off - 1] == '\r') 6114 off--; 6115 while (off-- > 0) 6116 { 6117 char const ch = pchBuf[off]; 6118 if (isalnum(ch) || ch == '.' || ch == ' ' || ch == '_' || ch == '-') 6119 { /* likely */ } 6120 else 6121 { 6122 fOk = K_FALSE; 6123 break; 6124 } 6125 } 6126 if (fOk) 6127 { 6128 pSandbox->StdErr.u.Fully.cchBuf = 0; 6129 return; 6130 } 5938 6131 } 5939 6132 } … … 5959 6152 static void kwSandboxConsoleWriteW(PKWSANDBOX pSandbox, PKWCONSOLEOUTPUTLINE pLineBuf, wchar_t const *pwcBuffer, KU32 cwcToWrite) 5960 6153 { 6154 kHlpAssert(pLineBuf->fIsConsole); 5961 6155 if (cwcToWrite > 0) 5962 6156 { … … 5976 6170 { 5977 6171 /* Need to grow the line buffer? */ 5978 KU32 cwcNeeded = offLastIncompleteLine != 0 ? offLastIncompleteLine : cchLastIncompleteLine + pLineBuf-> cwcBuf;5979 if (cwcNeeded > pLineBuf-> cwcBufAlloc)6172 KU32 cwcNeeded = offLastIncompleteLine != 0 ? offLastIncompleteLine : cchLastIncompleteLine + pLineBuf->u.Con.cwcBuf; 6173 if (cwcNeeded > pLineBuf->u.Con.cwcBufAlloc) 5980 6174 { 5981 6175 void *pvNew; 5982 KU32 cwcNew = !pLineBuf-> cwcBufAlloc ? 1024 : pLineBuf->cwcBufAlloc * 2;6176 KU32 cwcNew = !pLineBuf->u.Con.cwcBufAlloc ? 1024 : pLineBuf->u.Con.cwcBufAlloc * 2; 5983 6177 while (cwcNew < cwcNeeded) 5984 6178 cwcNew *= 2; 5985 pvNew = kHlpRealloc(pLineBuf-> pwcBuf, cwcNew * sizeof(wchar_t));6179 pvNew = kHlpRealloc(pLineBuf->u.Con.pwcBuf, cwcNew * sizeof(wchar_t)); 5986 6180 if (pvNew) 5987 6181 { 5988 pLineBuf-> pwcBuf = (wchar_t *)pvNew;5989 pLineBuf-> cwcBufAlloc = cwcNew;6182 pLineBuf->u.Con.pwcBuf = (wchar_t *)pvNew; 6183 pLineBuf->u.Con.cwcBufAlloc = cwcNew; 5990 6184 } 5991 6185 else 5992 6186 { 5993 pvNew = kHlpRealloc(pLineBuf-> pwcBuf, cwcNeeded * sizeof(wchar_t));6187 pvNew = kHlpRealloc(pLineBuf->u.Con.pwcBuf, cwcNeeded * sizeof(wchar_t)); 5994 6188 if (pvNew) 5995 6189 { 5996 pLineBuf-> pwcBuf = (wchar_t *)pvNew;5997 pLineBuf-> cwcBufAlloc = cwcNeeded;6190 pLineBuf->u.Con.pwcBuf = (wchar_t *)pvNew; 6191 pLineBuf->u.Con.cwcBufAlloc = cwcNeeded; 5998 6192 } 5999 6193 else 6000 6194 { 6001 6195 /* This isn't perfect, but it will have to do for now. */ 6002 if (pLineBuf-> cwcBuf > 0)6196 if (pLineBuf->u.Con.cwcBuf > 0) 6003 6197 { 6004 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->pwcBuf, pLineBuf->cwcBuf, K_TRUE /*fBrokenLine*/); 6005 pLineBuf->cwcBuf = 0; 6198 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf, 6199 K_TRUE /*fBrokenLine*/); 6200 pLineBuf->u.Con.cwcBuf = 0; 6006 6201 } 6007 6202 kwSandboxConsoleAddToCombined(pSandbox, pwcBuffer, cwcToWrite, K_TRUE /*fBrokenLine*/); … … 6016 6211 if (offLastIncompleteLine == 0) 6017 6212 { 6018 memcpy(&pLineBuf-> pwcBuf[pLineBuf->cwcBuf], pwcBuffer, cwcToWrite * sizeof(wchar_t));6019 pLineBuf-> cwcBuf += cwcToWrite;6213 memcpy(&pLineBuf->u.Con.pwcBuf[pLineBuf->u.Con.cwcBuf], pwcBuffer, cwcToWrite * sizeof(wchar_t)); 6214 pLineBuf->u.Con.cwcBuf += cwcToWrite; 6020 6215 return; 6021 6216 } … … 6025 6220 * If there is sufficient combined buffer to handle this request, this are rather simple. 6026 6221 */ 6027 if (pLineBuf-> cwcBuf + cchLastIncompleteLine <= K_ELEMENTS(pSandbox->Combined.wszBuf))6028 { 6029 if (pLineBuf-> cwcBuf > 0)6222 if (pLineBuf->u.Con.cwcBuf + cchLastIncompleteLine <= K_ELEMENTS(pSandbox->Combined.wszBuf)) 6223 { 6224 if (pLineBuf->u.Con.cwcBuf > 0) 6030 6225 { 6031 6226 memcpy(&pSandbox->Combined.wszBuf[pSandbox->Combined.cwcBuf], 6032 pLineBuf-> pwcBuf, pLineBuf->cwcBuf * sizeof(wchar_t));6033 pSandbox->Combined.cwcBuf += pLineBuf-> cwcBuf;6034 pLineBuf-> cwcBuf = 0;6227 pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf * sizeof(wchar_t)); 6228 pSandbox->Combined.cwcBuf += pLineBuf->u.Con.cwcBuf; 6229 pLineBuf->u.Con.cwcBuf = 0; 6035 6230 } 6036 6231 … … 6050 6245 /* If there is buffered chars, we handle the first line outside the 6051 6246 main loop. We must try our best outputting it as a complete line. */ 6052 if (pLineBuf-> cwcBuf > 0)6247 if (pLineBuf->u.Con.cwcBuf > 0) 6053 6248 { 6054 6249 while (offNextLine < cwcToWrite && pwcBuffer[offNextLine] != '\n') … … 6057 6252 kHlpAssert(offNextLine <= offLastIncompleteLine); 6058 6253 6059 if (pLineBuf-> cwcBuf + offNextLine + pSandbox->Combined.cwcBuf <= K_ELEMENTS(pSandbox->Combined.wszBuf))6254 if (pLineBuf->u.Con.cwcBuf + offNextLine + pSandbox->Combined.cwcBuf <= K_ELEMENTS(pSandbox->Combined.wszBuf)) 6060 6255 { 6061 6256 memcpy(&pSandbox->Combined.wszBuf[pSandbox->Combined.cwcBuf], 6062 pLineBuf-> pwcBuf, pLineBuf->cwcBuf * sizeof(wchar_t));6063 pSandbox->Combined.cwcBuf += pLineBuf-> cwcBuf;6064 pLineBuf-> cwcBuf = 0;6257 pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf * sizeof(wchar_t)); 6258 pSandbox->Combined.cwcBuf += pLineBuf->u.Con.cwcBuf; 6259 pLineBuf->u.Con.cwcBuf = 0; 6065 6260 6066 6261 memcpy(&pSandbox->Combined.wszBuf[pSandbox->Combined.cwcBuf], pwcBuffer, offNextLine * sizeof(wchar_t)); … … 6069 6264 else 6070 6265 { 6071 KU32 cwcLeft = pLineBuf-> cwcBufAlloc - pLineBuf->cwcBuf;6266 KU32 cwcLeft = pLineBuf->u.Con.cwcBufAlloc - pLineBuf->u.Con.cwcBuf; 6072 6267 if (cwcLeft > 0) 6073 6268 { 6074 6269 KU32 cwcCopy = K_MIN(cwcLeft, offNextLine); 6075 memcpy(&pLineBuf-> pwcBuf[pLineBuf->cwcBuf], pwcBuffer, cwcCopy * sizeof(wchar_t));6076 pLineBuf-> cwcBuf += cwcCopy;6270 memcpy(&pLineBuf->u.Con.pwcBuf[pLineBuf->u.Con.cwcBuf], pwcBuffer, cwcCopy * sizeof(wchar_t)); 6271 pLineBuf->u.Con.cwcBuf += cwcCopy; 6077 6272 off += cwcCopy; 6078 6273 } 6079 if (pLineBuf-> cwcBuf > 0)6274 if (pLineBuf->u.Con.cwcBuf > 0) 6080 6275 { 6081 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->pwcBuf, pLineBuf->cwcBuf, K_TRUE /*fBrokenLine*/); 6082 pLineBuf->cwcBuf = 0; 6276 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf, 6277 K_TRUE /*fBrokenLine*/); 6278 pLineBuf->u.Con.cwcBuf = 0; 6083 6279 } 6084 6280 if (off < offNextLine) … … 6105 6301 if (offLastIncompleteLine < cwcToWrite) 6106 6302 { 6107 memcpy(&pLineBuf-> pwcBuf[0], &pwcBuffer[offLastIncompleteLine], cchLastIncompleteLine * sizeof(wchar_t));6108 pLineBuf-> cwcBuf = cchLastIncompleteLine;6303 memcpy(&pLineBuf->u.Con.pwcBuf[0], &pwcBuffer[offLastIncompleteLine], cchLastIncompleteLine * sizeof(wchar_t)); 6304 pLineBuf->u.Con.cwcBuf = cchLastIncompleteLine; 6109 6305 } 6110 6306 } … … 6129 6325 wchar_t *pwcBufFree = NULL; 6130 6326 wchar_t *pwcBuf; 6327 kHlpAssert(pLineBuf->fIsConsole); 6131 6328 6132 6329 if (cwcBuf <= 4096) … … 6144 6341 6145 6342 /* Flush the line buffer and combined buffer before calling WriteConsoleA. */ 6146 if (pLineBuf-> cwcBuf > 0)6147 { 6148 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf-> pwcBuf, pLineBuf->cwcBuf, K_TRUE /*fBroken*/);6149 pLineBuf-> cwcBuf = 0;6343 if (pLineBuf->u.Con.cwcBuf > 0) 6344 { 6345 kwSandboxConsoleAddToCombined(pSandbox, pLineBuf->u.Con.pwcBuf, pLineBuf->u.Con.cwcBuf, K_TRUE /*fBroken*/); 6346 pLineBuf->u.Con.cwcBuf = 0; 6150 6347 } 6151 6348 kwSandboxConsoleFlushCombined(pSandbox); … … 6215 6412 if (hConOutput == g_Sandbox.StdErr.hOutput) 6216 6413 pLineBuf = &g_Sandbox.StdErr; 6414 else if (hConOutput == g_Sandbox.StdOut.hOutput) 6415 pLineBuf = &g_Sandbox.StdOut; 6217 6416 else 6218 pLineBuf = &g_Sandbox.StdOut;6417 pLineBuf = g_Sandbox.StdErr.fIsConsole ? &g_Sandbox.StdErr : &g_Sandbox.StdOut; 6219 6418 if (pLineBuf->fIsConsole) 6220 6419 { … … 7377 7576 pSandbox->wpgmptr = (wchar_t *)pTool->pwszPath; 7378 7577 #ifdef WITH_CONSOLE_OUTPUT_BUFFERING 7379 pSandbox->StdOut.cwcBuf = 0; 7380 pSandbox->StdErr.cwcBuf = 0; 7578 if (pSandbox->StdOut.fIsConsole) 7579 pSandbox->StdOut.u.Con.cwcBuf = 0; 7580 else 7581 pSandbox->StdOut.u.Fully.cchBuf = 0; 7582 if (pSandbox->StdErr.fIsConsole) 7583 pSandbox->StdErr.u.Con.cwcBuf = 0; 7584 else 7585 pSandbox->StdErr.u.Fully.cchBuf = 0; 7381 7586 pSandbox->Combined.cwcBuf = 0; 7382 7587 pSandbox->Combined.cFlushes = 0; … … 8210 8415 } 8211 8416 8417 /* Trigger breakpoint */ 8418 if ( i < argc 8419 && strcmp(argv[i], "--breakpoint") == 0) 8420 { 8421 __debugbreak(); 8422 i++; 8423 } 8424 8212 8425 /* Check for '--'. */ 8213 8426 if (i >= argc) … … 8363 8576 "usage: kWorker <--help|-h>\n" 8364 8577 "usage: kWorker <--version|-V>\n" 8365 "usage: kWorker [--volatile dir] --test [<times> [--chdir <dir>] ] -- args\n"8578 "usage: kWorker [--volatile dir] --test [<times> [--chdir <dir>] [--breakpoint] -- args\n" 8366 8579 "\n" 8367 8580 "This is an internal kmk program that is used via the builtin_kSubmit.\n");
Note:
See TracChangeset
for help on using the changeset viewer.