commit: 90a5b258f1a278aab642356fd46b5a46307241df Author: NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com> AuthorDate: Tue May 14 09:56:52 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Mon Feb 10 09:51:17 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=90a5b258
sci-libs/pgplot: Port to C99 Patch is full of stuffing definitions into right places In one place it discovered a bug - missing parameters to a function I stuffed minimum and maximum bit depth of color with possibly-incorrect but most likely working solution - 1 and maximum supported depth Other variant would have been 8,8 and 0,0, and I don't want to understand logic well enough to get correct value. Hope no one gets blinded by wrong colors of UI or their graph. Closes: https://bugs.gentoo.org/875437 Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com> Closes: https://github.com/gentoo/gentoo/pull/36670 Signed-off-by: Sam James <sam <AT> gentoo.org> sci-libs/pgplot/files/pgplot-C99.patch | 331 +++++++++++++++++++++++++++++++++ sci-libs/pgplot/pgplot-5.2.2-r9.ebuild | 177 ++++++++++++++++++ 2 files changed, 508 insertions(+) diff --git a/sci-libs/pgplot/files/pgplot-C99.patch b/sci-libs/pgplot/files/pgplot-C99.patch new file mode 100644 index 000000000000..ba3c5e46f6c2 --- /dev/null +++ b/sci-libs/pgplot/files/pgplot-C99.patch @@ -0,0 +1,331 @@ +https://bugs.gentoo.org/875437 +diff -ru a/pgdispd/figcurs.c b/pgdispd/figcurs.c +--- a/pgdispd/figcurs.c 2024-05-14 13:48:50.018175785 +0400 ++++ b/pgdispd/figcurs.c 2024-05-14 13:43:58.801142627 +0400 +@@ -55,8 +55,7 @@ + /* Return Values: */ + /* Whatever getcurs returns */ + +-int pggcurs(buf) +-short *buf; ++int pggcurs(short *buf) + { + int getcurs (); + +@@ -64,8 +63,7 @@ + } + + #ifndef PGDISP +-int bmgcurs(buf) +-short *buf; ++int bmgcurs(short *buf) + { + int getcurs (); + +@@ -79,10 +77,7 @@ + /* 0 There are no cursor positions to return */ + /* 1 The buffer was set properly */ + +-int getcurs(buf,curlist,listend) +-short *buf; +-struct curpos **curlist; +-struct curpos **listend; ++int getcurs(short *buf, struct curpos **curlist,struct curpos **listend) + { + struct curpos *tmpptr; + +@@ -106,8 +101,7 @@ + /* on the line graphics window. */ + /* Return Value: 1 (no matter what) */ + +-int pgcursor(event) +-XEvent event; ++int pgcursor(XEvent event) + { + short val; /* the "value" of the event" */ + +@@ -159,8 +153,7 @@ + /* on the bitmap graphics window. */ + /* Return Value: 1 (no matter what) */ + +-int bmcursor(event) +-XEvent event; ++int bmcursor(XEvent event) + { + short val; /* The value associated with the cursor event */ + +@@ -211,9 +204,7 @@ + /* The getbuttonval routine updates val to correspond to the appropriate */ + /* keypress. */ + +-void getbuttonval(button,val) +-unsigned int button; +-short *val; ++void getbuttonval(unsigned int button, short *val) + { + switch(button) + { +@@ -244,9 +235,7 @@ + /* 0 A modifier key was pressed */ + /* 1 A regular key was pressed */ + +-int getkeyval(event,val) +-XEvent event; +-short *val; ++int getkeyval(XEvent event, short *val) + { + char tmpchr; + KeySym keysym; +@@ -264,8 +253,7 @@ + /* cursor events and does not do anything visible unless this position is */ + /* different than the previousrecorded line graphics cursor location. */ + +-void pgscurs(x,y) +-int x,y; ++void pgscurs(int x, int y) + { + if (lgcurses != NULL) return; + +@@ -285,8 +273,7 @@ + /* position is different than the previous recorded line graphics cursor */ + /* location. */ + +-void bmscurs(x,y) +-int x,y; ++void bmscurs(int x, int y) + { + if (bmcurses != NULL) return; + +diff -ru a/pgdispd/getcolors.c b/pgdispd/getcolors.c +--- a/pgdispd/getcolors.c 2024-05-14 13:23:54.984716132 +0400 ++++ b/pgdispd/getcolors.c 2024-05-14 13:34:48.860787865 +0400 +@@ -30,17 +30,20 @@ + static int rovis[]={TrueColor, StaticColor, StaticGray}; + static int nrovis=sizeof(rovis)/sizeof(rovis[0]); + +-int getcolors(vistype, visual, cmap, pix, maxcolors, mincolors, depth, +- maxdepth, mindepth) +-int vistype; /* The type of visual to use */ +-Visual **visual; /* The visual actually used */ +-Colormap *cmap; /* The color map actually used */ +-unsigned long *pix; /* The pixels allocated */ +-int maxcolors; /* The maximum number of colors to allocate */ +-int mincolors; /* The minimum number of colors to allocate */ +-int *depth; /* The depth of the visual actually used */ +-int maxdepth; /* The maximum allowed visual depth */ +-int mindepth; /* The minimum allowed visual depth */ ++int getcolors(int vistype, Visual **visual, Colormap *cmap, ++ unsigned long *pix, int maxcolors, int mincolors, ++ int *depth,int maxdepth, int mindepth) ++/* ++int vistype; The type of visual to use ++Visual **visual; The visual actually used ++Colormap *cmap; The color map actually used ++unsigned long *pix; The pixels allocated ++int maxcolors; The maximum number of colors to allocate ++int mincolors; The minimum number of colors to allocate ++int *depth; The depth of the visual actually used ++int maxdepth; The maximum allowed visual depth ++int mindepth; The minimum allowed visual depth ++*/ + { + XVisualInfo vinfo; /* The template for our visual */ + unsigned long pmtmp[1]; /* temporary for plane masks */ +diff -ru a/pgdispd/getdata.c b/pgdispd/getdata.c +--- a/pgdispd/getdata.c 2024-05-14 13:23:54.985716126 +0400 ++++ b/pgdispd/getdata.c 2024-05-14 13:46:09.874257376 +0400 +@@ -36,13 +36,13 @@ + #include "messages.h" + + +-int getdata(event,rbuf,rbuflen,srcwin,selset) +-XSelectionEvent event; /* the event we're handling */ +-short *rbuf; /* a return buffer, if needed */ +-int *rbuflen; /* the length of the return buffer. If it's 0, no return */ ++int getdata(XSelectionEvent event, short *rbuf, int *rbuflen, Window srcwin, int *selset) ++/*XSelectionEvent event; the event we're handling */ ++/*short *rbuf; a return buffer, if needed */ ++/*int *rbuflen; the length of the return buffer. If it's 0, no return */ + /* message should be sent. */ +-Window srcwin; /* the source of our data */ +-int *selset; /* whether or not the selection is owned by a user program */ ++/*Window srcwin; the source of our data */ ++/*int *selset; whether or not the selection is owned by a user program */ + { + short *buffer; /* buffer for the data received */ + /* the max buffer length (in 16-bit words) */ +diff -ru a/pgdispd/getvisuals.c b/pgdispd/getvisuals.c +--- a/pgdispd/getvisuals.c 2024-05-14 13:23:54.984716132 +0400 ++++ b/pgdispd/getvisuals.c 2024-05-14 13:39:07.775108180 +0400 +@@ -34,6 +34,10 @@ + + #define MAX_DEPTH 24 /* the maximum visual depth to use */ + ++extern int getcolors(int vistype, Visual **visual, Colormap *cmap, ++ unsigned long *pix, int maxcolors, int mincolors, ++ int *depth, int maxdepth, int mindepth); ++ + int getvisuals() + { + int i; /* Silly loop variable */ +@@ -277,10 +281,10 @@ + + if ((bm.colors=getcolors(UseDefaultCmap, &bitvisual, &bitcmap, bm.pix, + res.maxcolors+res.leavecolors, res.mincolors+res.leavecolors, +- &bitdepth)) ++ &bitdepth, MAX_DEPTH, 1)) + || (bm.colors=getcolors(UseRWVisual, &bitvisual, &bitcmap, bm.pix, + res.maxcolors+res.savecolors, res.mincolors+res.savecolors, +- &bitdepth))) ++ &bitdepth, MAX_DEPTH, 1))) + { /* success! */ + if (bitcmap == DefaultColormap(display, screen)) + { +@@ -323,7 +327,7 @@ + while (res.lgcolors > 2) + { + if (lg.colors=getcolors(UseROVisual, &linevisual, &linecmap, +- lg.pix, res.lgcolors, res.lgcolors, &linedepth)) break; ++ lg.pix, res.lgcolors, res.lgcolors, &linedepth,MAX_DEPTH, 1)) break; + + /* lower our standards */ + if (res.lgcolors > 16) res.lgcolors=16; +diff -ru a/pgdispd/handlexevent.c b/pgdispd/handlexevent.c +--- a/pgdispd/handlexevent.c 2024-05-14 13:23:54.985716126 +0400 ++++ b/pgdispd/handlexevent.c 2024-05-14 13:49:17.490990237 +0400 +@@ -46,12 +46,15 @@ + #include "globals.h" + #include "messages.h" + ++extern int pggcurs(short *buf); ++extern int getdata(XSelectionEvent event, short *rbuf, int *rbuflen, Window srcwin, int *selset); ++extern int pgcursor(XEvent event); ++ + int luttransoff=0; + int modluttransoff=0; + +-int handlexevent(event,go_on) +-XEvent event; +-int *go_on; /* whether the calling routine shoudl exit successfully */ ++int handlexevent(XEvent event,int *go_on) ++/* *go_on; whether the calling routine shoudl exit successfully */ + { + #ifndef PGDISP + static int slitxs= -1,slitys; /* the starting point for the slit */ +diff -ru a/pgdispd/mainloop.c b/pgdispd/mainloop.c +--- a/pgdispd/mainloop.c 2024-05-14 13:23:54.984716132 +0400 ++++ b/pgdispd/mainloop.c 2024-05-14 13:41:28.880155175 +0400 +@@ -58,6 +58,9 @@ + #include "figdisp.h" + #include "globals.h" + ++extern int waitevent(); ++int handlexevent(XEvent event,int *go_on); ++ + int mainloop() + { + XEvent event; /* the current event */ +diff -ru a/pgdispd/pgdisp.c b/pgdispd/pgdisp.c +--- a/pgdispd/pgdisp.c 2024-05-14 13:23:54.985716126 +0400 ++++ b/pgdispd/pgdisp.c 2024-05-14 13:27:23.658462490 +0400 +@@ -43,9 +43,12 @@ + #undef DEFINE_GLOBALS + #undef INC_HEADER_RCS + +-int main(argc,argv) +-int argc; +-char **argv; ++extern int initlock(); ++extern int getvisuals(); ++extern int initlgwin(); ++extern int mainloop(); ++ ++int main(int argc,char **argv) + { + Display *XOpenDisplay(); + +diff -ru a/pgdispd/proccom.c b/pgdispd/proccom.c +--- a/pgdispd/proccom.c 2024-05-14 13:23:54.984716132 +0400 ++++ b/pgdispd/proccom.c 2024-05-14 13:44:27.000952169 +0400 +@@ -117,11 +117,13 @@ + /* A trivial macro */ + #define min(x,y) (((x) > (y)) ? (y) : (x)) + +-int proccom(buf,len,retbuf,retbuflen) +-unsigned short *buf; /* the buffer of commands and arguments */ +-int len; /* the length of the buffer */ +-unsigned short *retbuf; /* a buffer for return values */ +-int *retbuflen; /* the length of retbuf */ ++extern int pggcurs(short *buf); ++ ++int proccom(unsigned short *buf, int len, unsigned short *retbuf, int *retbuflen) ++/*unsigned short *buf; the buffer of commands and arguments */ ++/*int len; the length of the buffer */ ++/*unsigned short *retbuf; a buffer for return values */ ++/*int *retbuflen; the length of retbuf */ + { + static short bufcont[7]; /* the buffer contents while we're */ + /* working on things */ +diff -ru a/pgdispd/resdb.c b/pgdispd/resdb.c +--- a/pgdispd/resdb.c 2024-05-14 13:23:54.984716132 +0400 ++++ b/pgdispd/resdb.c 2024-05-14 13:29:59.091528701 +0400 +@@ -371,7 +371,7 @@ + char *strtype[20]; + XrmValue value; + int flags; +- char resource[80]; ++ char resource[180]; + + (void)sprintf(resource, "%s.bm.geometry", prog); + if (XrmGetResource(resdb, resource, "*Geometry", strtype, &value) +diff -ru a/pgdispd/returnbuf.c b/pgdispd/returnbuf.c +--- a/pgdispd/returnbuf.c 2024-05-14 13:23:54.985716126 +0400 ++++ b/pgdispd/returnbuf.c 2024-05-14 13:47:02.256903591 +0400 +@@ -15,10 +15,10 @@ + #include <X11/Xlib.h> + #include <X11/Xatom.h> + +-void returnbuf(msg,len,destwin) +-short *msg; /* the message to send to the client. */ +-int len; /* The length of the message. */ +-Window destwin; /* The window who's atom should be changed. */ ++void returnbuf(short *msg, int len, Window destwin) ++/*short *msg; the message to send to the client. */ ++/*int len; The length of the message. */ ++/*Window destwin; The window who's atom should be changed. */ + { + /* If the window is still around, then send the reply */ + if (selset) XChangeProperty(display,destwin,selatom,XA_STRING,8, +diff -ru a/pgdispd/updatelgtitle.c b/pgdispd/updatelgtitle.c +--- a/pgdispd/updatelgtitle.c 2024-05-14 13:23:54.985716126 +0400 ++++ b/pgdispd/updatelgtitle.c 2024-05-14 13:42:06.519900960 +0400 +@@ -15,6 +15,7 @@ + #include "globals.h" + #include <X11/Xlib.h> + #include <string.h> ++#include <stdio.h> + + void updatelgtitle(x,y) + int x,y; /* cursor position */ +@@ -28,7 +29,7 @@ + int i; + + #ifndef _AIX +- char *sprintf(); ++// char *sprintf(); + #endif + + /* make sure we don't confuse anything. */ +diff -ru a/pgdispd/waitevent.c b/pgdispd/waitevent.c +--- a/pgdispd/waitevent.c 2024-05-14 13:23:54.985716126 +0400 ++++ b/pgdispd/waitevent.c 2024-05-14 13:47:12.777832534 +0400 +@@ -63,6 +63,9 @@ + #define SELECT /* Use the select call to wait */ + #endif + ++extern int proccom(unsigned short *buf, int len, unsigned short *retbuf, int *retbuflen); ++void returnbuf(short *msg, int len, Window destwin); ++ + int waitevent() + { + short retbuf; diff --git a/sci-libs/pgplot/pgplot-5.2.2-r9.ebuild b/sci-libs/pgplot/pgplot-5.2.2-r9.ebuild new file mode 100644 index 000000000000..5f4ede557a91 --- /dev/null +++ b/sci-libs/pgplot/pgplot-5.2.2-r9.ebuild @@ -0,0 +1,177 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit fortran-2 flag-o-matic toolchain-funcs + +MY_P="${PN}${PV//.}" + +DESCRIPTION="FORTRAN/C device-independent scientific graphic library" +HOMEPAGE="https://www.astro.caltech.edu/~tjp/pgplot/" +SRC_URI="ftp://ftp.astro.caltech.edu/pub/pgplot/${MY_P}.tar.gz" +S="${WORKDIR}/${PN}" + +LICENSE="free-noncomm" +SLOT="0" +KEYWORDS="~amd64 ~arm ~ia64 ~ppc ~x86 ~amd64-linux ~x86-linux" +IUSE="doc motif static-libs tk" + +RDEPEND=" + media-libs/libpng:= + x11-libs/libX11:= + x11-libs/libXt:= + motif? ( x11-libs/motif:= ) + tk? ( dev-lang/tk:= ) +" +DEPEND="${RDEPEND}" +BDEPEND=" + doc? ( virtual/latex-base ) +" + +PATCHES=( + "${FILESDIR}"/${PN}-drivers.patch + "${FILESDIR}"/${PN}-makemake.patch + "${FILESDIR}"/${PN}-compile-setup.patch + "${FILESDIR}"/${PN}-headers.patch + "${FILESDIR}"/${PN}-libpng15.patch + "${FILESDIR}"/${PN}-tk86.patch + "${FILESDIR}"/${PN}-C99.patch +) + +src_prepare() { + default + + # fix pointers for 64 bits + if use amd64 || use ia64; then + sed -e 's/INTEGER PIXMAP/INTEGER*8 PIXMAP/g' \ + -i drivers/{gi,pp,wd}driv.f || die "sed 64bits failed" + fi + + cp sys_linux/g77_gcc.conf local.conf + + sed -e "s:FCOMPL=.*:FCOMPL=\"$(tc-getFC)\":g" \ + -e "s:CCOMPL=.*:CCOMPL=\"$(tc-getCC)\":g" \ + -i local.conf || die "sed flags failed" + + if [[ "$(tc-getFC)" = if* ]]; then + sed -e 's/-Wall//g' \ + -e 's/TK_LIBS="/TK_LIBS="-nofor-main /' \ + -i local.conf || die "sed drivers failed" + fi + + sed -e "s:/usr/local/pgplot:${EPREFIX}/usr/$(get_libdir)/pgplot:g" \ + -e "s:/usr/local/bin:${EPREFIX}/usr/bin:g" \ + -i src/grgfil.f makehtml maketex || die "sed path failed" + + use motif && sed -i -e '/XMDRIV/s/!//' drivers.list + use tk && sed -i -e '/TKDRIV/s/!//' drivers.list +} + +src_configure() { + # -Werror=lto-type-mismatch + # https://bugs.gentoo.org/862918 + # + # Upstream contact method is email. I have sent one. + filter-lto + + # GCC 10 workaround + # bug #722190 + append-fflags $(test-flags-FC -fallow-argument-mismatch) + + ./makemake . linux + # post makefile creation prefix hack + sed -i -e "s|/usr|${EPREFIX}/usr|g" makefile || die +} + +src_compile() { + emake \ + CFLAGS="${CFLAGS} -fPIC" \ + FFLAGS="${FFLAGS} -fPIC" \ + shared cpg-shared pgxwin_server pgdisp pgplot.doc + + use tk && emake CFLAGS="${CFLAGS} -fPIC" libtkpgplot.so + use motif && emake CFLAGS="${CFLAGS} -fPIC" libXmPgplot.so + + emake -j1 clean + use static-libs && emake all cpg + + if use doc; then + export VARTEXFONTS="${T}/fonts" + emake pgplot.html pgplot-routines.tex + pdflatex pgplot-routines.tex + pdflatex pgplot-routines.tex + fi + + # this just cleans out not needed files + emake -j1 clean +} + +src_test() { + # i can go to 16 + local i j + for i in 1 2 3; do + emake pgdemo${i} + # j can also be LATEX CPS... + for j in NULL PNG PS CPS LATEX; do + local testexe=./test_${j}_${i} + echo "LD_LIBRARY_PATH=. ./pgdemo${i} <<EOF" > ${testexe} + echo "/${j}" >> ${testexe} + echo "EOF" >> ${testexe} + sh ${testexe} || die "test ${i} failed" + done + done +} + +src_install() { + insinto /usr/$(get_libdir)/pgplot + doins grfont.dat grexec.f *.inc rgb.txt + echo "PGPLOT_FONT=${EPREFIX}/usr/$(get_libdir)/pgplot/grfont.dat" >> 99pgplot + doenvd 99pgplot + + dolib.so libpgplot.so* + dobin pgxwin_server pgdisp + + # C binding + insinto /usr/include + doins cpgplot.h + dolib.so libcpgplot.so* + + if use motif; then + insinto /usr/include + doins XmPgplot.h + dolib.so libXmPgplot.so* + fi + + if use tk; then + insinto /usr/include + doins tkpgplot.h + dolib.so libtkpgplot.so* + fi + + use static-libs && dolib.a lib*pgplot.a + + # minimal doc + dodoc aaaread.me pgplot.doc + newdoc pgdispd/aaaread.me pgdispd.txt + + if use doc; then + dodoc cpg/cpgplot.doc applications/curvefit/curvefit.doc pgplot.html + dodoc pgplot-routines.pdf pgplot-routines.tex + docinto examples + dodoc -r examples/. cpg/cpgdemo.c + docompress -x /usr/share/doc/${PF}/examples + dodoc -r applications + docompress -x /usr/share/doc/${PF}/applications + if use motif; then + docinto pgm + dodoc -r pgmf/. drivers/xmotif/pgmdemo.c + docompress -x /usr/share/doc/${PF}/pgm + fi + if use tk; then + docinto pgtk + dodoc drivers/xtk/pgtkdemo.* + docompress -x /usr/share/doc/${PF}/pgtk + fi + fi +}
