diff options
author | John van Groningen | 2005-01-04 13:33:11 +0000 |
---|---|---|
committer | John van Groningen | 2005-01-04 13:33:11 +0000 |
commit | 7de78054ec0eb3f65230773974a297bfa41864e9 (patch) | |
tree | 803e56167b510025157da1920df182473b89cd31 | |
parent | fix bug in writing strings to redirected stdout (diff) |
workaround bug in windows to print strings of more than about 50 thousand characters on the console
-rw-r--r-- | wcon.c | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -87,7 +87,37 @@ static void print_text (char *s,unsigned long length,OS(HANDLE,int) file_number) char c; if (n>0) +#ifdef WINDOWS + /* workaround for bug in windows */ + { + char *s_p; + int i; + + s_p=s; + i=n; + + do { + if (DosWrite (file_number,s_p,i,&n_chars)!=0 || GetLastError()!=ERROR_NOT_ENOUGH_MEMORY || n_chars==i) + break; + + if (n_chars==0){ + int m; + + m=i; + do + m=m>>1; + while (m>0 && !DosWrite (file_number,s_p,m,&n_chars) && GetLastError()==ERROR_NOT_ENOUGH_MEMORY && n_chars==0); + + if (n_chars==0) + return; + } + i-=n_chars; + s_p+=n_chars; + } while (i>0); + } +#else DosWrite (file_number,s,n,&n_chars); +#endif c=13; DosWrite (file_number,&c,1,&n_chars); @@ -97,7 +127,36 @@ static void print_text (char *s,unsigned long length,OS(HANDLE,int) file_number) } if (length>0) +#ifdef WINDOWS + { + /* workaround for bug in windows */ + char *s_p; + int i; + + s_p=s; + i=length; + do { + if (DosWrite (file_number,s_p,i,&n_chars)!=0 || GetLastError()!=ERROR_NOT_ENOUGH_MEMORY || n_chars==i) + break; + + if (n_chars==0){ + int m; + + m=i; + do + m=m>>1; + while (m>0 && !DosWrite (file_number,s_p,m,&n_chars) && GetLastError()==ERROR_NOT_ENOUGH_MEMORY && n_chars==0); + + if (n_chars==0) + return; + } + i-=n_chars; + s_p+=n_chars; + } while (i>0); + } +#else DosWrite (file_number,s,length,&n_chars); +#endif } #ifdef WINDOWS |