From 7de78054ec0eb3f65230773974a297bfa41864e9 Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Tue, 4 Jan 2005 13:33:11 +0000 Subject: workaround bug in windows to print strings of more than about 50 thousand characters on the console --- wcon.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/wcon.c b/wcon.c index 63883be..bce94c2 100644 --- a/wcon.c +++ b/wcon.c @@ -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 -- cgit v1.2.3