X-Git-Url: http://winboard.nl/cgi-bin?p=polyglot.git;a=blobdiff_plain;f=pipex_win32.c;h=13adfeb316f4315cfe1028260083be432db9242e;hp=8d9e893e43c51808d58e3e8074af8ffe9aba643b;hb=baab92d048b9ba06dada3a17ec51d9e9340d4730;hpb=9d90dc40cca05e03cafd0519e17f15b1d7441e37 diff --git a/pipex_win32.c b/pipex_win32.c index 8d9e893..13adfeb 100644 --- a/pipex_win32.c +++ b/pipex_win32.c @@ -322,6 +322,8 @@ bool pipex_eof(pipex_t *pipex){ bool pipex_readln_nb(pipex_t *pipex, char *szLineStr) { int nFeedEnd; int ret; + int src, dst; + char c; EnterCriticalSection(&(pipex->CriticalSection)); if ((pipex->lpFeedEnd) == NULL) { ret=FALSE; @@ -329,10 +331,18 @@ bool pipex_readln_nb(pipex_t *pipex, char *szLineStr) { nFeedEnd = pipex->lpFeedEnd - pipex->lpBuffer; memcpy(szLineStr, pipex->lpBuffer, nFeedEnd+1); szLineStr[nFeedEnd] = '\0'; - // temp hack: we use the fact that strtok modifies its first argument - strtok(szLineStr,"\r\n"); + + // temp hack: stolen from util.c + // remove CRs and LFs + src = 0; + dst = 0; + while ((c=szLineStr[src++]) != '\0') { + if (c != '\r' && c != '\n') szLineStr[dst++] = c; + } + szLineStr[dst] = '\0'; ASSERT(strchr(szLineStr,'\n')==NULL) ASSERT(strchr(szLineStr,'\r')==NULL) + nFeedEnd ++; pipex->nReadEnd -= nFeedEnd; memcpy(pipex->lpBuffer, pipex->lpBuffer + nFeedEnd, pipex->nReadEnd+1);