|
From: Petr M. <mi...@ph...> - 2003-11-24 15:20:50
|
> > A snapshot is here: > > http://www.sci.muni.cz/~mikulik/gnuplot/gp_rgb.png > > I see. > I like that! So it is in cvs. Associated changes: - 'test' is synonym for 'test terminal' - Undocumented command 'testtime' changed to undocumented command 'test time'. BTW, is there any particular reason this to be undocumented, now, when it is a suboption of 'test'? Cannot it be changed to become useful for users of "time" plots? --- Petr Mikulik |
|
From: Hans-Bernhard B. <br...@ph...> - 2003-11-25 15:30:54
|
On Tue, 25 Nov 2003, Petr Mikulik wrote: > > > Man page of tmpnam() and of tempnam() says: > > > Never use this function. Use mkstemp(3) instead. > > > > > > Is there any safe and portable way to create a file in a temporary > > > directory, like /tmp or C:\TMP? > > > > <stdio.h>: FILE *tmpfile(void) > > Unfortunately this does not provide name of the file which I could use in > plot 'tmp_file1' > save set 'tmp_file2' Hmm... looks like the right answer would be "don't do that, then", in this case. I.e. we may have to find a way to generate that test page without writing any files. E.g. set up gnuplot a function per palette channel that the core can plot, instead of storing its values to a file. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |
|
From: Petr M. <mi...@ph...> - 2003-11-25 16:04:25
|
> > Unfortunately this does not provide name of the file which I could use in > > plot 'tmp_file1' > > save set 'tmp_file2' > > Hmm... looks like the right answer would be "don't do that, then", in this > case. I.e. we may have to find a way to generate that test page without > writing any files. E.g. set up gnuplot a function per palette channel > that the core can plot, instead of storing its values to a file. That would need: 1. gnuplot can draw data from memory 2. gnuplot can save its current status of 'set' to recover from the current temporary plot setting Nb 2, alias "push and pop current set status" would be nice, but unfortunately it is not so structured. For now, using temporary save help is quite easy. --- Petr Mikulik |
|
From: Ethan M. <merritt@u.washington.edu> - 2003-11-25 00:08:09
|
> So it is in cvs. Works nicely the first time. =20 Crashes on the second. Same behaviour seen for x11, png, and post terminal types gnuplot> set term png font arial Terminal type set to 'png' Options are 'nocrop font arial 12 size 640,480 ' gnuplot> set output 'rgb.png' gnuplot> test palette smooth palette in png: available 157 color positions; using 157 of them gnuplot> test palette Program received signal SIGSEGV, Segmentation fault. 0x401ebbc3 in strlen () from /lib/i686/libc.so.6 (gdb) where #0 0x401ebbc3 in strlen () from /lib/i686/libc.so.6 #1 0x080e8c67 in loadpath_handler (action=3D0, path=3D0x1 <Address 0x1 o= ut of bounds>) at variable.c:175 #2 0x08092612 in save_set_all (fp=3D0x8212240) at save.c:837 #3 0x08090e08 in save_set (fp=3D0x80f6c3c) at save.c:100 #4 0x080536f8 in test_palette_subcommand () at command.c:1371 #5 0x08051e4a in command () at command.c:507 #6 0x080519b5 in do_line () at command.c:364 #7 0x080518d3 in com_line () at command.c:323 #8 0x08084e69 in main (argc=3D1, argv=3D0xbfffec74) at plot.c:609 #9 0x4018f082 in __libc_start_main () from /lib/i686/libc.so.6 --=20 Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Box 357742 University of Washington, Seattle, WA 98195 |
|
From: Petr M. <mi...@ph...> - 2003-11-25 09:38:00
|
Further, it was crashing in read-only directory. I've fixed that.
The problem is that it needs to write two temporary files ('save set', and
palette data). For that, I use mkstemp(). But this functions makes the file
in the current directory.
Man page of tmpnam() and of tempnam() says:
Never use this function. Use mkstemp(3) instead.
Is there any safe and portable way to create a file in a temporary
directory, like /tmp or C:\TMP?
---
Petr Mikulik
|
|
From: Hans-Bernhard B. <br...@ph...> - 2003-11-25 12:57:29
|
On Tue, 25 Nov 2003, Petr Mikulik wrote: > Man page of tmpnam() and of tempnam() says: > Never use this function. Use mkstemp(3) instead. > > Is there any safe and portable way to create a file in a temporary > directory, like /tmp or C:\TMP? <stdio.h>: FILE *tmpfile(void) It may not be particularly safe, but it's as portable as they come, being an ANSI/ISO C Standard Library function. You get no control whatsoever about the directory it places the file in, though. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |
|
From: Lars H. <lhe...@us...> - 2003-11-25 13:04:56
|
Hans-Bernhard Broeker writes: > On Tue, 25 Nov 2003, Petr Mikulik wrote: > > > Man page of tmpnam() and of tempnam() says: > > Never use this function. Use mkstemp(3) instead. > > > > Is there any safe and portable way to create a file in a temporary > > directory, like /tmp or C:\TMP? > > <stdio.h>: FILE *tmpfile(void) > > It may not be particularly safe, but it's as portable as they come, being > an ANSI/ISO C Standard Library function. You get no control whatsoever > about the directory it places the file in, though. It is quite difficult to do this portably and securly (avoiding races). It's probably best to create a temporary directory (mkdtemp() if available), chmod 700 it, and create all temp files in that directory. I've written some not terribly intelligent code like this for amavis. |
|
From: Petr M. <mi...@ph...> - 2003-11-25 13:58:27
|
> > Man page of tmpnam() and of tempnam() says: > > Never use this function. Use mkstemp(3) instead. > > > > Is there any safe and portable way to create a file in a temporary > > directory, like /tmp or C:\TMP? > > <stdio.h>: FILE *tmpfile(void) Unfortunately this does not provide name of the file which I could use in plot 'tmp_file1' save set 'tmp_file2' --- Petr Mikulik |
|
From: Daniel J S. <dan...@ie...> - 2003-11-25 15:33:28
|
Petr Mikulik wrote: >>>Man page of tmpnam() and of tempnam() says: >>> Never use this function. Use mkstemp(3) instead. >>> >>>Is there any safe and portable way to create a file in a temporary >>>directory, like /tmp or C:\TMP? >>> >>> >><stdio.h>: FILE *tmpfile(void) >> >> > >Unfortunately this does not provide name of the file which I could use in > plot 'tmp_file1' > save set 'tmp_file2' > An alternative if these temp files are not too big might be to slightly alter the "datafile.c" so that it doesn't necessarily need to read from a file stream but can instead read from some internal memory stream. That way you could temporarily put memory on the heap and not have to deal with files... or the equivalent, some type of mechanism to generate an arbitrary function mapping points from one set to another set that you can plot without having to use a datafile but rather a function... or, could datafile.c be rewritten so that the name of the file is not needed, just the FILE *. That is, there is already a special case '-'. Maybe there is something simple to do there. Dan |
|
From: Petr M. <mi...@ph...> - 2003-11-25 16:06:53
|
> >Unfortunately this does not provide name of the file which I could use in > > plot 'tmp_file1' > > An alternative if these temp files are not too big might be > to slightly alter the "datafile.c" so that it doesn't necessarily > need to read from a file stream but can instead read from > some internal memory stream. That way you could > temporarily put memory on the heap and not have to deal > with files... It could e.g. read from internal memory, and also from shared memory. |
|
From: Ethan M. <merritt@u.washington.edu> - 2003-11-25 20:32:06
|
On Tuesday 25 November 2003 05:58, Petr Mikulik wrote: > > <stdio.h>: FILE *tmpfile(void) > > Unfortunately this does not provide name of the file which I could use > in plot 'tmp_file1' You wouldn't need a file name if you wrote the data as an in-line command= : plot '-' xx xx xx xx xx xx E and then passed the FILE pointer directly to load_file(). So the code would look like: =09pre1 =3D tmpfile(); data =3D tmpfile(); post1 =3D tmpfile(); =09fprintf(pre1, buf1);=09/* write preliminary commands */ =09fprintf(data, buf2);=09/* write inline data for plot */ =09fprintf(post1, buf3);=09/* write any trailing commands */ =09rewind(pre1); rewind(data); rewind(post1); =09load_file(pre1, ...); =09load_file(data, ...); =09load_file(post1, ...); > =09save set 'tmp_file2' A similar trick should work here: =09save_set(savefp=3Dtmpfile()); =09... =09load_file(savefp, ...); --=20 Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Box 357742 University of Washington, Seattle, WA 98195 |
|
From: Petr M. <mi...@ph...> - 2003-11-28 08:08:14
|
> On Tuesday 25 November 2003 05:58, Petr Mikulik wrote: > > > <stdio.h>: FILE *tmpfile(void) > > > > Unfortunately this does not provide name of the file which I could use > > in plot 'tmp_file1' > > You wouldn't need a file name if you wrote the data as an in-line command: > plot '-' > xx xx xx > xx xx xx > E > and then passed the FILE pointer directly to load_file(). > > So the code would look like: > pre1 = tmpfile(); data = tmpfile(); post1 = tmpfile(); > fprintf(pre1, buf1); /* write preliminary commands */ > fprintf(data, buf2); /* write inline data for plot */ > fprintf(post1, buf3); /* write any trailing commands */ > rewind(pre1); rewind(data); rewind(post1); > load_file(pre1, ...); > load_file(data, ...); > load_file(post1, ...); > > > > save set 'tmp_file2' > > A similar trick should work here: > save_set(savefp=tmpfile()); > ... > load_file(savefp, ...); In the final rework, it turned out that it is sufficient to use only one temporary file once submitted to load_file(). --- Petr Mikulik |
|
From: Ethan M. <merritt@u.washington.edu> - 2003-12-11 22:46:42
|
Petr: 'help test palette' says The optional parameter, a permutation of letters rgb, determines the se= quence of r,g,b profiles drawn one after the other --- try this yourself for `set= palette gray`. The default sequence is rgb. When I try this with the x11, post or png terminals, I do not see any dif= ference in=20 the resulting plot no matter whether I say rgb or grb or brg or whatever= =2E The order of labels on the curves change, but that is the only thing diff= erent. Am I doing something wrong, or is this a bug, or am I not understanding what the output is supposed to show? --=20 Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Box 357742 University of Washington, Seattle, WA 98195 |
|
From: Petr M. <mi...@ph...> - 2003-12-12 10:34:33
|
> 'help test palette' says > The optional parameter, a permutation of letters rgb, determines the sequence of > r,g,b profiles drawn one after the other --- try this yourself for `set palette > gray`. The default sequence is rgb. > > When I try this with the x11, post or png terminals, I do not see any difference in > the resulting plot no matter whether I say rgb or grb or brg or whatever. > The order of labels on the curves change, but that is the only thing different. > > Am I doing something wrong, or is this a bug, or am I not understanding > what the output is supposed to show? Try this: set palette gray test palette rgb pause test palette rbg pause test palette bgr ...it shows different things. If it not clear from the docs, you can modify it. --- Petr Mikulik |