Re: [9fans] How to take a portion of a screenshot

2016-11-27 Thread erik quanstrom
On Wed Nov 23 13:50:02 PST 2016, jules.merit.eurocorp...@gmail.com wrote:


> I ported doom, after someone Runed plan9. Trying to get 9front Jurassic
> Park on MIPS r12k now.
> 
> Also plan9 clearly needs EEG for user defined scheduler and jukebox
> selection whilst in the labs.
> 

as soon as i saw the first "dnl", i gave up.

- erik



Re: [9fans] Using plot(1)

2016-11-27 Thread Chris McGee
Thanks,

> not sure what you mean by pipe the output, if you want to save the graph
> you need to do that by grabbing the window, there could be things like 
> gifplot which render the plot command stream into a gif, but it doesn't (yet).

Yes, this is what I was after. I'll try fetching the window buffer and extract 
it from there. I'll see if a command line switch can be added easily to plot to 
do just that.

> i am pretty sure graph has a "don't clear the screen" option if that will do 
> for you,
> however my suspicion is that if you close and reopen the stream to plot it 
> will
> clear and redraw the screen. i thing (guess) that you would need to send all 
> your
> plot commands in a single stream.

I was thinking that if plot didn't automatically clear the window (maybe with 
an option) you could add a background to the plot. Another option could be for 
plot to have an image command that imports and draws one from a file.

>> o
>> ra -1.0 -1.0 1.0 1.0
>> e
>> co r
>> cf r
>> di 0.0 0.0 1.0
>> co k
>> li 0.0 -1.0 0.0 1.0
>> li -1.0 0.0 1.0 0.0
>> cl


I tried this same plot program on a raspberry Pi with much slower graphics and 
I noticed that the red circle is drawn for an instant and then disappears 
behind a white box that covers most of it. I tried it without the lines and 
it's the same thing. Not sure what is clipping the circle. Very strange.

Chris


Re: [9fans] snprintf buffer overrun

2016-11-27 Thread cinap_lenrek
commited fix in 9front, thanks for reporting!

--
cinap



Re: [9fans] snprintf buffer overrun

2016-11-27 Thread cinap_lenrek
theres a bug is in sclose() where it doesnt check if wp is beyond
the buffer. also wp was not updated after realloc().

--- a/sys/src/libstdio/sclose.c Sat Nov 19 16:47:21 2016 +0100
+++ b/sys/src/libstdio/sclose.c Sun Nov 27 21:07:48 2016 +0100
@@ -5,27 +5,35 @@
 char *sclose(FILE *f){
switch(f->state){
default:/* ERR CLOSED */
+   Error:
if(f->buf && f->flags&BALLOC)
free(f->buf);
-   f->flags=0;
-   return NULL;
+   f->buf=0;
+   break;
case OPEN:
f->buf=malloc(1);
f->buf[0]='\0';
break;
case RD:
case END:
-   f->flags=0;
break;
case RDWR:
case WR:
+   f->rp=f->buf+f->bufl;
if(f->wp==f->rp){
-   if(f->flags&BALLOC)
-   f->buf=realloc(f->buf, f->bufl+1);
-   if(f->buf==NULL) return NULL;
+   if(f->flags&BALLOC){
+   char *t = realloc(f->buf, f->bufl+1);
+   if(t==NULL)
+   goto Error;
+   f->buf=t;
+   f->wp=t+f->bufl;
+   } else {
+   if(f->wp > f->buf)
+   *(f->wp-1) = '\0';
+   goto Error;
+   }
}
*f->wp='\0';
-   f->flags=0;
break;
}
f->state=CLOSED;

--
cinap



[9fans] snprintf buffer overrun

2016-11-27 Thread Porlock
Plan 9's implementation of the standard C functions snprintf and
vsnprintf have a buffer overrun bug.

If the buffer length equals the output length (without the terminating
null), then one too many characters is written to the buffer.

For example,
  snprintf(buf, 4, "ABCD");

will write 5 characters to buf.

Attached is a short program to illustrate this, which gives the
following output :-

% 8c printftest.c && 8l printftest.8
% ./8.out
  A   B   C   D   \0  *   *   *   *   *   *   *   *   *   *   *


#include 
#include 
#include 

void main()
{
char buf[16];
int i;
memset(buf, '*', sizeof(buf));
snprintf(buf, 4, "ABCD");
for (i = 0; i < sizeof(buf); ++i) {
if (buf[i])
print("  %c ", buf[i]);
else
print("  \\0");
}
print("\n");
}


Re: [9fans] Using plot(1)

2016-11-27 Thread Steve Simon
hi,

not sure what you mean by pipe the output, if you want to save the graph
you need to do that by grabbing the window, there could be things like gifplot 
which render the plot command stream into a gif, but it doesn't (yet).

i am pretty sure graph has a "don't clear the screen" option if that will do 
for you,
however my suspicion is that if you close and reopen the stream to plot it will
clear and redraw the screen. i thing (guess) that you would need to send all 
your
plot commands in a single stream.

steve

> On 27 Nov 2016, at 03:03, Chris McGee  wrote:
> 
> Hi All,
> 
> I’m trying graph and plot out. I have some questions.
> 
> Is there a way to pipe the output of plot or do I need to pull that out of 
> the screen/window buffer? Also, is there a way to plot on top of an existing 
> image?
> 
> I tried making a simple plot routine to draw a red unit circle with x and y 
> axes. The lines are drawing fine, but the circle is completely cut off except 
> for a hint of the top-most and bottom-most edges. Here’s the routine that I’m 
> using. Is there something obvious that I’m doing wrong?
> 
> o
> ra -1.0 -1.0 1.0 1.0
> e
> co r
> cf r
> di 0.0 0.0 1.0
> co k
> li 0.0 -1.0 0.0 1.0
> li -1.0 0.0 1.0 0.0
> cl
> 
> Thanks,
> Chris