--- ./2nash.c.orig 2016-05-27 03:04:13.000000000 -0600
+++ ./2nash.c 2016-05-27 08:37:14.830639712 -0600
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+ #include <fcntl.h>
int main(int argc, char *argv[])
{
@@ -27,14 +28,16 @@
if(cpid[l-1] == 0) {
//forked threads
// n= sprintf(buffer, "lrs %s > out%i", argv[l], l);
+ sprintf(buffer, "out%i", l);
+ int fd = creat(buffer, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ dup2(fd, 1);
if(l==1) {
- int n= sprintf(buffer, "lrsnash %s %s > out%i", argv[1], argv[2], l);
+ execlp("lrsnash", "lrsnash", argv[1], argv[2], NULL);
}
else {
- int n= sprintf(buffer, "lrsnash %s %s > out%i", argv[2], argv[1], l);
+ execlp("lrsnash", "lrsnash", argv[2], argv[1], NULL);
}
- int i=system(buffer);
_exit(0);
}
}
@@ -49,18 +52,18 @@
printf("lrsnash %s %s finished first\n", argv[2], argv[1]);
printf("player numbers will be reversed in output\n");
}
+ sprintf(buffer, "out%i", j);
if(argc == 4) {
printf("output file: %s\n", argv[3]);
- int n = sprintf(buffer, "/bin/mv -f out%i %s", j, argv[3]);
+ rename(buffer, argv[3]);
}
else {
- printf("output file: out\n", argv[2], argv[1]);
- int n = sprintf(buffer, "/bin/mv -f out%i out", j);
+ printf("output file: out\n");
+ rename(buffer, "out");
}
- int i = system(buffer);
} else {
- int n = sprintf(buffer, "/bin/rm -f out%i", j);
- int i = system(buffer);
+ sprintf(buffer, "out%i", j);
+ unlink(buffer);
}
}
printf("the other process will be "); /*...will be killed */
--- ./fourier.c.orig 2016-05-27 03:02:13.000000000 -0600
+++ ./fourier.c 2016-05-27 08:37:14.845638448 -0600
@@ -408,7 +408,6 @@ long compute_redundancy(long *redineq, l
{
long ineq;
long d, m;
- long nlinearity;
long lastdv, index;
lrs_mp_matrix Lin;
@@ -421,7 +420,6 @@ long compute_redundancy(long *redineq, l
}
m = P->m_A;
d = P->d;
- nlinearity = Q->nlinearity;
lastdv = Q->lastdv;
for(index = lastdv +1;index <= m+d; index++)
{
@@ -710,7 +708,7 @@ void full_fel(lrs_dic *iP, lrs_dat *iQ,
long *Dep; /*Dep[0] not used, Dep[i] = 1 if eqn lin. dep., else 0 */
long nlinearity;
long eqn;
- long last=0; /* =1 if equation used to remove var. =2 if FME used */
+ /* long last=0; */ /* =1 if equation used to remove var. =2 if FME used */
/* could do with less of these monsters */
lrs_mp Temp, Temp1, div1;
@@ -770,7 +768,7 @@ void full_fel(lrs_dic *iP, lrs_dat *iQ,
}
if (eqn > 0)
{
- last = 1;
+ /* last = 1; */
for(l=eqn-1;l<nlinearity-1;l++) /* reduce linearities */
{
Q1->linearity[l] = Q1->linearity[l+1] -1;
@@ -832,7 +830,7 @@ void full_fel(lrs_dic *iP, lrs_dat *iQ,
}
else
{
- last = 2;
+ /* last = 2; */
if( (Q2 = lrs_alloc_dat("LRS GLOBALS")) == NULL)
fel_abort("ERROR>Can't allocate memory for structures");
--- ./lrsgmp.c.orig 2016-05-27 03:04:14.000000000 -0600
+++ ./lrsgmp.c 2016-05-27 08:55:50.476023791 -0600
@@ -250,7 +250,7 @@ readrat (lrs_mp Na, lrs_mp Da) /* read a
}
#ifdef PLRS
-string prat (char name[], lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
+string prat (const char *name, lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
{
//create stream to collect output
@@ -284,7 +284,7 @@ string prat (char name[], lrs_mp Nin, lr
return str;
}
-char *cprat (char name[], lrs_mp Nin, lrs_mp Din)
+char *cprat (const char *name, lrs_mp Nin, lrs_mp Din)
{
char *ret;
unsigned long len;
@@ -311,7 +311,7 @@ char *cprat (char name[], lrs_mp Nin, lr
return ret;
}
-string pmp (char name[], lrs_mp Nt) /*print the long precision integer a */
+string pmp (const char *name, lrs_mp Nt) /*print the long precision integer a */
{
//create stream to collect output
@@ -333,7 +333,7 @@ string pmp (char name[], lrs_mp Nt) /*pr
#else
void
-pmp (char name[], lrs_mp Nt)
+pmp (const char *name, lrs_mp Nt)
{
fprintf (lrs_ofp, "%s", name);
if (sign (Nt) != NEG)
@@ -343,7 +343,7 @@ pmp (char name[], lrs_mp Nt)
}
void
-prat (char name[], lrs_mp Nin, lrs_mp Din)
+prat (const char *name, lrs_mp Nin, lrs_mp Din)
/*print the long precision rational Nt/Dt */
{
lrs_mp temp1, temp2;
@@ -458,7 +458,7 @@ lrs_getdigits (long *a, long *b)
}
void *
-xcalloc (long n, long s, long l, char *f)
+xcalloc (long n, long s, long l, const char *f)
{
void *tmp;
@@ -494,7 +494,7 @@ lrs_mp_init (long dec_digits, FILE * fpi
void
-notimpl (char s[])
+notimpl (const char *s)
{
fflush (stdout);
fprintf (stderr, "\nAbnormal Termination %s\n", s);
--- ./lrsgmp.h.orig 2016-05-27 03:04:14.000000000 -0600
+++ ./lrsgmp.h 2016-05-27 08:54:29.730576958 -0600
@@ -168,13 +168,13 @@ void atomp (const char s[], lrs_mp a); /
long compare (lrs_mp a, lrs_mp b); /* a ? b and returns -1,0,1 for <,=,> */
void linint (lrs_mp a, long ka, lrs_mp b, long kb); /* compute a*ka+b*kb --> a */
#ifdef PLRS
-string pmp (char name[], lrs_mp a); /* print the long precision integer a */
-string prat (char name[], lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
-char *cprat(char name[], lrs_mp Nt, lrs_mp Dt); /* C version of prat */
+string pmp (const char *name, lrs_mp a); /* print the long precision integer a */
+string prat (const char *name, lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
+char *cprat(const char *name, lrs_mp Nt, lrs_mp Dt); /* C version of prat */
long plrs_readrat (lrs_mp Na, lrs_mp Da, const char * rat); /* take a rational number and convert to lrs_mp */
#else
-void pmp (char name[], lrs_mp a); /* print the long precision integer a */
-void prat (char name[], lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
+void pmp (const char *name, lrs_mp a); /* print the long precision integer a */
+void prat (const char *name, lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
#endif
void readmp (lrs_mp a); /* read an integer and convert to lrs_mp */
long readrat (lrs_mp Na, lrs_mp Da); /* read a rational or int and convert to lrs_mp */
@@ -195,7 +195,7 @@ void lcm (lrs_mp a, lrs_mp b); /* a = le
void mulrat (lrs_mp Na, lrs_mp Da, lrs_mp Nb, lrs_mp Db, lrs_mp Nc, lrs_mp Dc);
/* computes Nc/Dc=(Na/Da)*(Nb/Db) and reduce */
long myrandom (long num, long nrange); /* return a random number in range 0..nrange-1 */
-void notimpl (char s[]); /* bail out - help! */
+void notimpl (const char *s); /* bail out - help! */
void rattodouble (lrs_mp a, lrs_mp b, double *x); /* convert lrs_mp rational to double */
void reduceint (lrs_mp Na, lrs_mp Da); /* divide Na by Da and return it */
void reducearray (lrs_mp_vector p, long n); /* find gcd of p[0]..p[n-1] and divide through by */
@@ -214,7 +214,7 @@ void *calloc ();
void *malloc ();
#endif
-void *xcalloc (long n, long s, long l, char *f);
+void *xcalloc (long n, long s, long l, const char *f);
void lrs_default_digits_overflow ();
--- ./lrslib.c.orig 2016-05-27 03:04:13.000000000 -0600
+++ ./lrslib.c 2016-05-27 08:37:14.850638027 -0600
@@ -56,8 +56,8 @@ static void lrs_dump_state ();
static void pushQ (lrs_dat * global, long m, long d, long m_A);
#ifdef TIMES
-static void ptimes ();
-static double get_time();
+static void ptimes (void);
+static double get_time(void);
#endif
@@ -65,10 +65,10 @@ static double get_time();
/* signals handling */
/*******************************/
#ifdef SIGNALS
-static void checkpoint ();
-static void die_gracefully ();
-static void setup_signals ();
-static void timecheck ();
+static void checkpoint (int signum);
+static void die_gracefully (int signum);
+static void setup_signals (void);
+static void timecheck (int signum);
#endif
/*******************************/
@@ -922,7 +922,7 @@ if (Q->countonly)
#ifdef PLRS
//Make new output node
- char *type=NULL;
+ const char *type=NULL;
//Make stream to collect prat / pmp data
stringstream ss;
@@ -1013,7 +1013,7 @@ void lrs_lpoutput(lrs_dic * P,lrs_dat *
/* end of lrs_lpoutput */
/***********************/
void
-lrs_printrow (char name[], lrs_dat * Q, lrs_mp_vector output, long rowd)
+lrs_printrow (const char *name, lrs_dat * Q, lrs_mp_vector output, long rowd)
/* print a row of A matrix in output in "original" form */
/* rowd+1 is the dimension of output vector */
/* if input is H-rep. output[0] contains the RHS */
@@ -1096,7 +1096,7 @@ lrs_getsolution (lrs_dic * P, lrs_dat *
long
-lrs_init (char *name) /* returns TRUE if successful, else FALSE */
+lrs_init (const char *name) /* returns TRUE if successful, else FALSE */
{
printf ("%s", name);
@@ -1120,7 +1120,7 @@ lrs_init (char *name) /* returns T
}
void
-lrs_close (char *name)
+lrs_close (const char *name)
{
fprintf (lrs_ofp, "\n*%s", name);
@@ -1998,8 +1998,8 @@ lrs_getfirstbasis (lrs_dic ** D_p, lrs_d
#ifndef PLRS
fprintf (lrs_ofp, "\n*Voronoi Diagram: Voronoi vertices and rays are output");
#else
- char *type = "header";
- char *data = "*Voronoi Diagram: Voronoi vertices and rays are output";
+ const char *type = "header";
+ const char *data = "*Voronoi Diagram: Voronoi vertices and rays are output";
//post output in a nonblocking manner (a consumer thread will manage output)
post_output(type,data);
#endif
@@ -2008,8 +2008,8 @@ lrs_getfirstbasis (lrs_dic ** D_p, lrs_d
#ifndef PLRS
fprintf (lrs_ofp, "\nH-representation");
#else
- char *type = "header";
- char *data = "H-representation";
+ const char *type = "header";
+ const char *data = "H-representation";
//post output in a nonblocking manner (a consumer thread will manage output)
post_output(type, data);
#endif
@@ -2018,8 +2018,8 @@ lrs_getfirstbasis (lrs_dic ** D_p, lrs_d
#ifndef PLRS
fprintf (lrs_ofp, "\nV-representation");
#else
- char *type = "header";
- char *data = "V-representation";
+ const char *type = "header";
+ const char *data = "V-representation";
//post output in a nonblocking manner (a consumer thread will manage output)
post_output(type,data);
#endif
@@ -2040,7 +2040,7 @@ lrs_getfirstbasis (lrs_dic ** D_p, lrs_d
fprintf (lrs_ofp, "\nlinearity %ld ", nredundcol - k); /*adjust nredundcol for homog. */
#else
stringstream ss;
- char *type = "header";
+ const char *type = "header";
ss<<"linearity "<<(nredundcol -k);
#endif
for (i = 1; i <= nredundcol - k; i++){
@@ -2060,7 +2060,7 @@ lrs_getfirstbasis (lrs_dic ** D_p, lrs_d
fprintf (lrs_ofp, "\nbegin");
fprintf (lrs_ofp, "\n***** %ld rational", Q->n);
#else
- char *type = "header";
+ const char *type = "header";
stringstream ss;
ss<<"begin"<<endl<<"***** "<<Q->n<<" rational";
post_output(type, ss.str().c_str());
@@ -2694,7 +2694,7 @@ lrs_printcobasis (lrs_dic * P, lrs_dat *
long nincidence; /* count number of tight inequalities */
//Make new output node
- char *type = "cobasis";
+ const char *type = "cobasis";
//Make stream to collect prat / pmp data
stringstream ss;
@@ -4698,7 +4698,7 @@ printA (lrs_dic * P, lrs_dat * Q) /* pri
void
-pimat (lrs_dic * P, long r, long s, lrs_mp Nt, char name[])
+pimat (lrs_dic * P, long r, long s, lrs_mp Nt, const char *name)
/*print the long precision integer in row r col s of matrix A */
{
long *B = P->B;
@@ -5303,7 +5303,7 @@ setup_signals ()
}
static void
-timecheck ()
+timecheck (int signum __attribute__((unused)))
{
lrs_dump_state ();
errcheck ("signal", signal (SIGALRM, timecheck));
@@ -5311,14 +5311,14 @@ timecheck ()
}
static void
-checkpoint ()
+checkpoint (int signum __attribute__((unused)))
{
lrs_dump_state ();
errcheck ("signal", signal (SIGUSR1, checkpoint));
}
static void
-die_gracefully ()
+die_gracefully (int signum __attribute__((unused)))
{
lrs_dump_state ();
--- ./lrslib.h.orig 2016-05-27 03:04:13.000000000 -0600
+++ ./lrslib.h 2016-05-27 08:37:14.851637942 -0600
@@ -240,12 +240,12 @@ long lrs_getnextbasis (lrs_dic ** dict_p
long lrs_getsolution (lrs_dic * P, lrs_dat * Q, lrs_mp_vector output, long col);
long lrs_getray (lrs_dic * P, lrs_dat * Q, long col, long comment, lrs_mp_vector output);
long lrs_getvertex (lrs_dic * P, lrs_dat * Q, lrs_mp_vector output);
-void lrs_close (char *name); /* close lrs lib program "name" */
-long lrs_init (char *name); /* initialize lrslib and arithmetic package for prog "name" */
+void lrs_close (const char *name); /* close lrs lib program "name" */
+long lrs_init (const char *name); /* initialize lrslib and arithmetic package for prog "name" */
void lrs_lpoutput(lrs_dic * P,lrs_dat * Q, lrs_mp_vector output); /* print LP primal and dual solutions */
void lrs_printcobasis (lrs_dic * P, lrs_dat * Q, long col); /* print cobasis for column col(verted or ray) */
void lrs_printoutput (lrs_dat * Q, lrs_mp_vector output); /* print output array */
-void lrs_printrow (char name[], lrs_dat * Q, lrs_mp_vector output, long rowd); /*print row of A matrix in output[0..rowd] */
+void lrs_printrow (const char *name, lrs_dat * Q, lrs_mp_vector output, long rowd); /*print row of A matrix in output[0..rowd] */
void lrs_printsol (lrs_dic * P, lrs_dat * Q, long col, long comment); /* print out solution from col, comment= 0=normal,-1=geometric ray,1..inputd=linearity */
void lrs_printtotals (lrs_dic * P, lrs_dat * Q);/* print final totals for lrs */
long lrs_set_digits (long dec_digits ); /* set lrsmp digits to equiv. of decimal dec_digits */
@@ -284,7 +284,7 @@ void updatevolume (lrs_dic * P, lrs_dat
long lrs_degenerate (lrs_dic * P, lrs_dat * Q); /* TRUE if the dictionary is primal degenerate */
void print_basis (FILE * fp, lrs_dat * Q);
void printA (lrs_dic * P, lrs_dat * Q); /* raw print of dictionary, bases for debugging */
-void pimat (lrs_dic * P, long r, long s, lrs_mp Nt, char name[]); /* print the row r col s of A */
+void pimat (lrs_dic * P, long r, long s, lrs_mp Nt, const char *name); /* print the row r col s of A */
long readfacets (lrs_dat * Q, long facet[]); /* read and check facet list */
long readlinearity (lrs_dat * Q); /* read and check linearity list */
void rescaledet (lrs_dic * P, lrs_dat * Q, lrs_mp Vnum, lrs_mp Vden); /* rescale determinant to get its volume */
--- ./lrslong.c.orig 2016-05-27 03:04:13.000000000 -0600
+++ ./lrslong.c 2016-05-27 08:56:03.739946770 -0600
@@ -272,7 +272,7 @@ readmp (lrs_mp a) /* read an integer an
#ifdef PLRS
-string prat (char name[], lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
+string prat (const char *name, lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
{
//create stream to collect output
@@ -294,7 +294,7 @@ string prat (char name[], lrs_mp Nin, lr
return str;
}
-char *cprat (char name[], lrs_mp Nin, lrs_mp Din)
+char *cprat (const char *name, lrs_mp Nin, lrs_mp Din)
{
char *ret;
unsigned long len;
@@ -321,7 +321,7 @@ char *cprat (char name[], lrs_mp Nin, lr
return ret;
}
-string pmp (char name[], lrs_mp Nt) /*print the long precision integer a */
+string pmp (const char *name, lrs_mp Nt) /*print the long precision integer a */
{
//create stream to collect output
@@ -339,7 +339,7 @@ string pmp (char name[], lrs_mp Nt) /*pr
}
#else
void
-pmp (char name[], lrs_mp Nt)
+pmp (const char *name, lrs_mp Nt)
{
fprintf (lrs_ofp, "%s", name);
if (sign (Nt) != NEG)
@@ -349,7 +349,7 @@ pmp (char name[], lrs_mp Nt)
}
void
-prat (char name[], lrs_mp Nin, lrs_mp Din)
+prat (const char *name, lrs_mp Nin, lrs_mp Din)
/*print the long precision rational Nt/Dt */
{
lrs_mp Nt, Dt;
@@ -456,7 +456,7 @@ lrs_getdigits (long *a, long *b)
}
void *
-xcalloc (long n, long s, long l, char *f)
+xcalloc (long n, long s, long l, const char *f)
{
void *tmp;
@@ -490,7 +490,7 @@ lrs_mp_init (long dec_digits, FILE * fpi
}
void
-notimpl (char s[])
+notimpl (const char *s)
{
fflush (stdout);
fprintf (stderr, "\nAbnormal Termination %s\n", s);
--- ./lrslong.h.orig 2016-05-27 03:04:13.000000000 -0600
+++ ./lrslong.h 2016-05-27 08:54:46.920183553 -0600
@@ -181,13 +181,13 @@ void gcd (lrs_mp u, lrs_mp v); /* return
void mptodouble (lrs_mp a, double *x); /* convert lrs_mp to double */
long mptoi (lrs_mp a); /* convert lrs_mp to long integer */
#ifdef PLRS
-string pmp (char name[], lrs_mp a); /* print the long precision integer a */
-string prat (char name[], lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
-char *cprat(char name[], lrs_mp Nt, lrs_mp Dt); /* C version of prat */
+string pmp (const char *name, lrs_mp a); /* print the long precision integer a */
+string prat (const char *name, lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
+char *cprat(const char *name, lrs_mp Nt, lrs_mp Dt); /* C version of prat */
long plrs_readrat (lrs_mp Na, lrs_mp Da, const char * rat); /* take a rational number and convert to lrs_mp */
#else
-void pmp (char name[], lrs_mp a); /* print the long precision integer a */
-void prat (char name[], lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
+void pmp (const char *name, lrs_mp a); /* print the long precision integer a */
+void prat (const char *name, lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
#endif
void readmp (lrs_mp a); /* read an integer and convert to lrs_mp */
long readrat (lrs_mp Na, lrs_mp Da); /* read a rational or int and convert to lrs_mp */
@@ -209,7 +209,7 @@ void lcm (lrs_mp a, lrs_mp b); /* a = le
void mulrat (lrs_mp Na, lrs_mp Da, lrs_mp Nb, lrs_mp Db, lrs_mp Nc, lrs_mp Dc);
/* computes Nc/Dc=(Na/Da)*(Nb/Db) and reduce */
long myrandom (long num, long nrange); /* return a random number in range 0..nrange-1 */
-void notimpl (char s[]); /* bail out - help! */
+void notimpl (const char *s); /* bail out - help! */
void rattodouble (lrs_mp a, lrs_mp b, double *x); /* convert lrs_mp rational to double */
void reduceint (lrs_mp Na, lrs_mp Da); /* divide Na by Da and return it */
void reducearray (lrs_mp_vector p, long n); /* find gcd of p[0]..p[n-1] and divide through by */
@@ -225,7 +225,7 @@ void stringcpy (char *s, char *t); /* co
void *calloc ();
void *malloc ();
-void *xcalloc (long n, long s, long l, char *f);
+void *xcalloc (long n, long s, long l, const char *f);
void lrs_default_digits_overflow ();
--- ./lrsmp.c.orig 2016-05-27 03:04:14.000000000 -0600
+++ ./lrsmp.c 2016-05-27 08:56:19.321681547 -0600
@@ -624,7 +624,7 @@ mptoi (lrs_mp a) /* convert lrs_mp to l
#ifdef PLRS
-string prat (char name[], lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
+string prat (const char *name, lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
{
@@ -663,7 +663,7 @@ string prat (char name[], lrs_mp Nin, lr
return str;
}
-char *cprat (char name[], lrs_mp Nin, lrs_mp Din)
+char *cprat (const char *name, lrs_mp Nin, lrs_mp Din)
{
char *ret;
unsigned long len;
@@ -690,7 +690,7 @@ char *cprat (char name[], lrs_mp Nin, lr
return ret;
}
-string pmp (char name[], lrs_mp a) /*print the long precision integer a */
+string pmp (const char *name, lrs_mp a) /*print the long precision integer a */
{
long i;
@@ -715,7 +715,7 @@ string pmp (char name[], lrs_mp a) /*pri
return str;
}
#else
-void prat (char name[], lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
+void prat (const char *name, lrs_mp Nin, lrs_mp Din) /*reduce and print Nin/Din */
{
lrs_mp Nt, Dt;
long i;
@@ -743,7 +743,7 @@ void prat (char name[], lrs_mp Nin, lrs_
}
-void pmp (char name[], lrs_mp a) /*print the long precision integer a */
+void pmp (const char *name, lrs_mp a) /*print the long precision integer a */
{
long i;
@@ -988,7 +988,7 @@ comprod (lrs_mp Na, lrs_mp Nb, lrs_mp Nc
void
-notimpl (char s[])
+notimpl (const char *s)
{
fflush (stdout);
fprintf (stderr, "\nAbnormal Termination %s\n", s);
@@ -1063,7 +1063,7 @@ mulrat (lrs_mp Na, lrs_mp Da, lrs_mp Nb,
void *
-xcalloc (long n, long s, long l, char *f)
+xcalloc (long n, long s, long l, const char *f)
{
void *tmp;
--- ./lrsmp.h.orig 2016-05-27 03:04:14.000000000 -0600
+++ ./lrsmp.h 2016-05-27 08:54:59.103195222 -0600
@@ -177,13 +177,13 @@ long mptoi (lrs_mp a); /* convert lrs_m
void mulint (lrs_mp a, lrs_mp b, lrs_mp c); /* multiply two integers a*b --> c */
void normalize (lrs_mp a); /* normalize lrs_mp after computation */
#ifdef PLRS
-string pmp (char name[], lrs_mp a); /* print the long precision integer a */
-string prat (char name[], lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
-char *cprat(char name[], lrs_mp Nt, lrs_mp Dt); /* C version of prat */
+string pmp (const char *name, lrs_mp a); /* print the long precision integer a */
+string prat (const char *name, lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
+char *cprat(const char *name, lrs_mp Nt, lrs_mp Dt); /* C version of prat */
long plrs_readrat (lrs_mp Na, lrs_mp Da, const char * rat); /* take a rational number and convert to lrs_mp */
#else
-void pmp (char name[], lrs_mp a); /* print the long precision integer a */
-void prat (char name[], lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
+void pmp (const char *name, lrs_mp a); /* print the long precision integer a */
+void prat (const char *name, lrs_mp Nt, lrs_mp Dt); /* reduce and print Nt/Dt */
#endif
long readrat (lrs_mp Na, lrs_mp Da); /* read a rational or int and convert to lrs_mp */
void reduce (lrs_mp Na, lrs_mp Da); /* reduces Na Da by gcd(Na,Da) */
@@ -207,7 +207,7 @@ void lcm (lrs_mp a, lrs_mp b); /* a = le
void mulrat (lrs_mp Na, lrs_mp Da, lrs_mp Nb, lrs_mp Db, lrs_mp Nc, lrs_mp Dc);
/* computes Nc/Dc=(Na/Da)*(Nb/Db) and reduce */
long myrandom (long num, long nrange); /* return a random number in range 0..nrange-1 */
-void notimpl (char s[]); /* bail out - help! */
+void notimpl (const char *s); /* bail out - help! */
void rattodouble (lrs_mp a, lrs_mp b, double *x); /* convert lrs_mp rational to double */
void reduceint (lrs_mp Na, lrs_mp Da); /* divide Na by Da and return it */
void reducearray (lrs_mp_vector p, long n); /* find gcd of p[0]..p[n-1] and divide through by */
@@ -224,7 +224,7 @@ void lrs_getdigits (long *a, long *b); /
void stringcpy (char *s, char *t); /* copy t to s pointer version */
-void *xcalloc (long n, long s, long l, char *f);
+void *xcalloc (long n, long s, long l, const char *f);
void lrs_default_digits_overflow ();
void digits_overflow ();
--- ./lrsnash.c.orig 2016-05-27 03:02:14.000000000 -0600
+++ ./lrsnash.c 2016-05-27 08:37:14.853637774 -0600
@@ -118,7 +118,7 @@ int tl_readrat(long *num, long *den, cha
//----------------------------------------------------------------------------------------//
-int readGame(game * g, char *filename)
+int readGame(game * g, const char *filename)
{
FILE *IN;
long pos, s, t, nr, nc;
@@ -162,11 +162,11 @@ int readGame(game * g, char *filename)
static long Print_game_flag;
static long Standard_input_flag;
-void printUsage(char *progname) {
+void printUsage(const char *progname) {
fprintf(stderr, Usage, progname, progname, progname);
}
-void printInfo(char *progname) {
+void printInfo(const char *progname) {
fprintf(stderr, Helptext, progname, progname);
}
@@ -252,7 +252,7 @@ int getArgs(int argc, char **argv)
//----------------------------------------------------------------------------------------//
// Checks if an input file is legacy (contains letters)
-int isLegacy(char *filename) {
+int isLegacy(const char *filename) {
FILE *fp;
int i, n, foundLetter = FALSE;
char buf[100];
--- ./lrsnashlib.c.orig 2016-05-27 03:02:14.000000000 -0600
+++ ./lrsnashlib.c 2016-05-27 08:37:14.854637689 -0600
@@ -25,7 +25,7 @@
//========================================================================
int lrs_solve_nash(game * g)
{
- lrs_dic *P1, *P2; /* structure for holding current dictionary and indices */
+ lrs_dic *P1; /* structure for holding current dictionary and indices */
lrs_dat *Q1, *Q2; /* structure for holding static problem data */
lrs_mp_vector output1; /* holds one line of output; ray,vertex,facet,linearity */
@@ -52,7 +52,7 @@ int lrs_solve_nash(game * g)
Q1 = lrs_alloc_dat("LRS globals"); /* allocate and init structure for static problem data */
if (Q1 == NULL) {
- return;
+ return 1;
}
Q1->nash = TRUE;
@@ -64,7 +64,7 @@ int lrs_solve_nash(game * g)
P1 = lrs_alloc_dic(Q1); /* allocate and initialize lrs_dic */
if (P1 == NULL) {
- return;
+ return 1;
}
BuildRep(P1, Q1, g, 1, 0);
@@ -74,7 +74,7 @@ int lrs_solve_nash(game * g)
/* allocate and init structure for player 2's problem data */
Q2 = lrs_alloc_dat("LRS globals");
if (Q2 == NULL) {
- return;
+ return 1;
}
Q2->debug = Debug_flag;
@@ -86,7 +86,7 @@ int lrs_solve_nash(game * g)
P2orig = lrs_alloc_dic(Q2); /* allocate and initialize lrs_dic */
if (P2orig == NULL) {
- return;
+ return 1;
}
BuildRep(P2orig, Q2, g, 0, 1);
A2orig = P2orig->A;
@@ -325,14 +325,12 @@ lrs_getfirstbasis2(lrs_dic ** D_p, lrs_d
/* assign local variables to structures */
lrs_mp_matrix A;
- long *B, *C, *Row, *Col;
+ long *B, *C, *Col;
long *inequality;
long *linearity;
long hull = Q->hull;
long m, d, lastdv, nlinearity, nredundcol;
- static long ocount = 0;
-
m = D->m;
d = D->d;
lastdv = Q->lastdv;
@@ -344,7 +342,6 @@ lrs_getfirstbasis2(lrs_dic ** D_p, lrs_d
A = D->A;
B = D->B;
C = D->C;
- Row = D->Row;
Col = D->Col;
inequality = Q->inequality;
@@ -459,7 +456,6 @@ lrs_getfirstbasis2(lrs_dic ** D_p, lrs_d
if (Q->verbose) {
fprintf(lrs_ofp, "\nNumber of pivots for starting dictionary: %ld", Q->count[3]);
- ocount = Q->count[3];
}
/* Do dual pivots to get primal feasibility */
@@ -467,14 +463,12 @@ lrs_getfirstbasis2(lrs_dic ** D_p, lrs_d
if (Q->verbose) {
fprintf(lrs_ofp, "\nNumber of pivots for feasible solution: %ld", Q->count[3]);
fprintf(lrs_ofp, " - No feasible solution");
- ocount = Q->count[3];
}
return FALSE;
}
if (Q->verbose) {
fprintf(lrs_ofp, "\nNumber of pivots for feasible solution: %ld", Q->count[3]);
- ocount = Q->count[3];
}
/* Now solve LP if objective function was given */
@@ -768,7 +762,7 @@ long lrs_nashoutput(lrs_dat * Q, lrs_mp_
int lrs_solve_nash_legacy (int argc, char *argv[])
// Handles legacy input files
{
- lrs_dic *P1,*P2; /* structure for holding current dictionary and indices */
+ lrs_dic *P1; /* structure for holding current dictionary and indices */
lrs_dat *Q1,*Q2; /* structure for holding static problem data */
lrs_mp_vector output1; /* holds one line of output; ray,vertex,facet,linearity */
--- ./plrs.cpp.orig 2016-05-27 03:04:14.000000000 -0600
+++ ./plrs.cpp 2016-05-27 08:48:20.279509911 -0600
@@ -167,8 +167,11 @@ void startThread(int thread_number){
}
void findInitCobasis(){
- char * argv[] = {"init_temp.ine"};
+ char *input = new char[strlen ("init_temp.ine") + 1U];
+ strcpy(input, "init_temp.ine");
+ char * argv[] = { input };
lrs_main(1, argv);
+ delete [] input;
//No longer need temporary ine file so delete it
if(remove("init_temp.ine") != 0) printf("Error deleting init file!\n");
}
@@ -189,12 +192,12 @@ void processOutput(){
while(consume_list){
if(consume_list->type == "vertex"){
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n",consume_list->data.c_str());
else OUTSTREAM <<consume_list->data<<endl;
}else if(consume_list->type == "ray"){
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n",consume_list->data.c_str());
else OUTSTREAM <<consume_list->data<<endl;
@@ -204,13 +207,13 @@ void processOutput(){
//Note that we will not be piping initial cobasis to output
processCobasis(consume_list->data);
}else{
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n",consume_list->data.c_str());
else OUTSTREAM <<consume_list->data<<endl;
}
}else if(consume_list->type =="V cobasis"){
if(!initializing){
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n",consume_list->data.c_str());
else OUTSTREAM <<consume_list->data<<endl;
}
@@ -243,20 +246,20 @@ void processOutput(){
}else if(consume_list->type == "options warning"){
//Only pipe warnings if initializing otherwise they are displayed multiple times
if(initializing){
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n", consume_list->data.c_str());
else OUTSTREAM <<consume_list->data<<endl;
}
}else if(consume_list->type == "header"){
//Only pipe headers if initializing otherwise they are displayed multiple times
if(initializing){
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n", consume_list->data.c_str());
else OUTSTREAM <<consume_list->data<<endl;
}
}else if(consume_list->type == "debug"){
//Print debug output if it's produced
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("%s\n", consume_list->data.c_str());
else OUTSTREAM << consume_list->data<<endl;
}
@@ -292,7 +295,7 @@ void initializeStartingCobasis(){
printf("*Max depth of %d to initialize starting cobasis list\n",
INITDEPTH);
- if(OUTSTREAM != NULL)
+ if(OUTSTREAM.good())
OUTSTREAM <<"*Max depth of "<<INITDEPTH<<" to initialize starting cobasis list"<<endl;
//Copy contents of ine file to temporary file
@@ -303,13 +306,13 @@ void initializeStartingCobasis(){
{
init_temp_file<<"estimates "<<ESTIMATES<<endl;
printf("*Estimates %d\n",ESTIMATES);
- if(OUTSTREAM != NULL)
+ if(OUTSTREAM.good())
OUTSTREAM <<"*Estimates "<<ESTIMATES<<endl;
if (SUBTREESIZE<1)
SUBTREESIZE=1000;
printf("*Subtreesize %d\n",SUBTREESIZE);
init_temp_file<<"subtreesize "<<SUBTREESIZE<<endl;
- if(OUTSTREAM != NULL)
+ if(OUTSTREAM.good())
OUTSTREAM <<"*Subtreesize "<<SUBTREESIZE<<endl;
}
if (!ESTIMATES || PLRS_DEBUG)
@@ -416,7 +419,7 @@ int main(int argc, char* argv[]){
printf("*Output written to: %s\n",outputfile.c_str());
}
- if(OUTSTREAM != NULL)
+ if(OUTSTREAM.good())
{
OUTSTREAM <<"*plrs:"<<TITLE<<VERSION<<"("<<ARITH<<")"<<MAXTHREADS<<" processes"<<endl<<AUTHOR<<endl;
OUTSTREAM <<"*Input taken from "<<INPUTFILE<<endl;
@@ -472,11 +475,11 @@ int main(int argc, char* argv[]){
consumer_thread.join();
}
- if (OUTSTREAM == NULL)
+ if (OUTSTREAM.fail())
printf("end\n");
else
OUTSTREAM <<"end"<<endl;;
- if(OUTSTREAM != NULL)
+ if(OUTSTREAM.good())
{
OUTSTREAM<<"*Finished initializing cobasis list with "<<cobasislistsize<<" starting cobases"<<endl;
OUTSTREAM <<"*Starting "<<MAXTHREADS<<" producer thread(s) and 1 consumer thread"<<endl;
@@ -484,22 +487,22 @@ int main(int argc, char* argv[]){
if(FACETS > 0){
printf("%s\n", prat("*Volume=",Vnum,Vden).c_str());
printf("*Totals: facets=%ld bases=%ld\n",FACETS,BASIS);
- if (OUTSTREAM != NULL) {
+ if (OUTSTREAM.good()) {
OUTSTREAM <<prat("*Volume=",Vnum,Vden) << endl ;
OUTSTREAM <<"*Totals: facets="<<FACETS<<" bases="<<BASIS<<endl;
}
}else{
printf("*Totals: vertices=%ld rays=%ld bases=%ld integer-vertices=%ld\n",VERTICES,RAYS,BASIS,INTVERTICES);
- if (OUTSTREAM != NULL)
+ if (OUTSTREAM.good())
OUTSTREAM<<"*Totals: vertices="<<VERTICES<<" rays="<<RAYS<<" bases="<<BASIS<< " integer-vertices="<<INTVERTICES<<endl;
}
- if(OUTSTREAM != NULL)
+ if(OUTSTREAM.good())
OUTSTREAM<< "*Phase 1 time: "<< phase1time <<
" seconds"<<endl;
gettimeofday(&end, NULL);
printf("*Elapsed time: %ld seconds\n", end.tv_sec - start.tv_sec);
- if (OUTSTREAM != NULL)
+ if (OUTSTREAM.good())
{
OUTSTREAM <<"*Elapsed time: "<<end.tv_sec - start.tv_sec<<" seconds."<<endl;
}