write error on <stdout> - output buffer overflow

View: New views
4 Messages — Rating Filter:   Alert me  

write error on <stdout> - output buffer overflow

by xypron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andrew,

the following model returns an error
"write error on <stdout> - output buffer overflow"

for {i in 1..2000}
  printf "%6s", "x";
end;

Currently the output buffer is only flushed when reaching a new line.

For very long output lines the buffer should be flushed instead of
throwing an error.

The problem is in write_char (file glpmpl04.c)

The following change should resolve it.

Please, replace
         if (mpl->out_cnt == OUTBUF_SIZE)
            error(mpl, "write error on %s - output buffer overflow",
               mpl->out_file);
by
         mpl->out_buf[mpl->out_cnt++] = (char)c;
         if (mpl->out_cnt == OUTBUF_SIZE - 1)
         {  mpl->out_buf[mpl->out_cnt] = '\0';
            if (mpl->out_fp == stdout)
               xprintf("%s", mpl->out_buf);
            else
               fprintf(mpl->out_fp, "%s", mpl->out_buf);
            mpl->out_cnt = 0;
         }

Best regards

Xypron

Re: write error on <stdout> - output buffer overflow

by Andrew Makhorin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> the following model returns an error
> "write error on <stdout> - output buffer overflow"

> for {i in 1..2000}
>   printf "%6s", "x";
> end;

> Currently the output buffer is only flushed when reaching a new line.

> For very long output lines the buffer should be flushed instead of
> throwing an error.

Thank you for your suggestion and patch.

I removed the buffering at all. (This was needed due to an old version
of glplib which allowed printing only an entire line.)



_______________________________________________
Bug-glpk mailing list
Bug-glpk@...
http://lists.gnu.org/mailman/listinfo/bug-glpk

Re: write error on <stdout> - output buffer overflow

by xypron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andrew,

>> Thank you for your suggestion and patch.
>>
>> I removed the buffering at all. (This was needed due to an old version
>> of glplib which allowed printing only an entire line.)

some operating systems often are very slow on single byte file ouput because
the changes are immediately written to disk. Hence buffering may make
sense.

Best regards

Xypron

Re: write error on <stdout> - output buffer overflow

by Andrew Makhorin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>> I removed the buffering at all. (This was needed due to an old version
>>> of glplib which allowed printing only an entire line.)

> some operating systems often are very slow on single byte file ouput
> because the changes are immediately written to disk. Hence buffering
> may make sense.

I meant that now buffering is not used in the translator routines;
they call xprintf/xfprintf, which provide the standard buffering.




_______________________________________________
Bug-glpk mailing list
Bug-glpk@...
http://lists.gnu.org/mailman/listinfo/bug-glpk