diff --git a/units-1.87-gcc-warnings-1.patch b/units-1.87-gcc-warnings-1.patch new file mode 100644 index 0000000..b4e6f79 --- /dev/null +++ b/units-1.87-gcc-warnings-1.patch @@ -0,0 +1,234 @@ +diff --git a/parse.y b/parse.y +index 89a05b1..0bdd8a3 100644 +--- a/parse.y ++++ b/parse.y +@@ -29,6 +29,8 @@ + + #include "units.h" + ++int yylex(); ++void yyerror(char *); + + static int err; /* value used by parser to store return values */ + +@@ -114,7 +116,7 @@ funcunit(struct unittype *theunit, struct function *fun) + if (err) + return err; + } else if (fun->type==ANGLEOUT || fun->type == DIMENSIONLESS) { +- if (err=unit2num(theunit)) ++ if ((err=unit2num(theunit))) + return err; + + } else +@@ -278,7 +280,7 @@ struct { + "per" , DIVIDE, + 0, 0 }; + +-yylex(YYSTYPE *lvalp, struct commtype *comm) ++int yylex(YYSTYPE *lvalp, struct commtype *comm) + { + int length, count; + struct unittype *output; +@@ -414,7 +416,7 @@ yylex(YYSTYPE *lvalp, struct commtype *comm) + } + + +-yyerror(char *s){} ++void yyerror(char *s){} + + void + freelist(int startunit) +diff --git a/units.c b/units.c +index f5416b0..2cd6765 100644 +--- a/units.c ++++ b/units.c +@@ -29,6 +29,7 @@ + + #ifdef READLINE + # include ++# include + # define RVERSTR "with readline" + #else + # define RVERSTR "without readline" +@@ -489,7 +490,7 @@ readunits(char *file, FILE *errfile, + } + if (wronglocale) + continue; +- if (lineptr = strchr(line,COMMENTCHAR)) ++ if ((lineptr = strchr(line,COMMENTCHAR))) + *lineptr = 0; + unitname = strtok(line, WHITE); + if (!unitname || !*unitname) +@@ -519,9 +520,9 @@ readunits(char *file, FILE *errfile, + goterr=1; + continue; + } +- if (pfxptr = plookup(unitname)) { /* already there: redefinition */ ++ if ((pfxptr = plookup(unitname))) { /* already there: redefinition */ + goterr=1; +- if (errfile) ++ if (errfile) { + if (!strcmp(pfxptr->name, unitname)) + fprintf(errfile, + "%s: redefinition of prefix '%s-' on line %d of '%s' ignored.\n", +@@ -529,6 +530,7 @@ readunits(char *file, FILE *errfile, + else + fprintf(errfile, "%s: prefix '%s-' on line %d of '%s' is hidden by earlier definition of '%s-'.\n", + progname, unitname, linenum, file, pfxptr->name); ++ } + continue; + } + +@@ -948,7 +950,7 @@ lookupunit(char *unit,int prefixok) + struct prefixlist *pfxptr; + struct unitlist *uptr; + +- if (uptr = ulookup(unit)) ++ if ((uptr = ulookup(unit))) + return uptr->value; + + if (strlen(unit)>2 && unit[strlen(unit) - 1] == 's') { +@@ -1278,7 +1280,7 @@ completereduce(struct unittype *unit) + { + int err; + +- if (err=reduceunit(unit)) ++ if ((err=reduceunit(unit))) + return err; + sortunit(unit); + cancelunit(unit); +@@ -1340,7 +1342,7 @@ unit2num(struct unittype *input) + int err; + + initializeunit(&one); +- if (err=completereduce(input)) ++ if ((err=completereduce(input))) + return err; + if (compareunits(input,&one,ignore_nothing)) + return E_NOTANUMBER; +@@ -1404,13 +1406,13 @@ rootunit(struct unittype *inunit,int n) + int err; + + initializeunit(&outunit); +- if (err=completereduce(inunit)) ++ if ((err=completereduce(inunit))) + return err; +- if ((n & 1==0) && (inunit->factor<0)) return E_NOTROOT; ++ if (((n & 1)==0) && (inunit->factor<0)) return E_NOTROOT; + outunit.factor = pow(inunit->factor,1.0/(double)n); +- if (err = subunitroot(n, inunit->numerator, outunit.numerator)) ++ if ((err = subunitroot(n, inunit->numerator, outunit.numerator))) + return err; +- if (err = subunitroot(n, inunit->denominator, outunit.denominator)) ++ if ((err = subunitroot(n, inunit->denominator, outunit.denominator))) + return err; + freeunit(inunit); + initializeunit(inunit); +@@ -1482,9 +1484,9 @@ addunit(struct unittype *unita, struct unittype *unitb) + { + int err; + +- if (err=completereduce(unita)) ++ if ((err=completereduce(unita))) + return err; +- if (err=completereduce(unitb)) ++ if ((err=completereduce(unitb))) + return err; + if (compareunits(unita,unitb,ignore_nothing)) + return E_BADSUM; +@@ -1723,7 +1725,7 @@ showanswer(char *havestr,struct unittype *have, + { + struct unittype invhave; + int doingrec; /* reciprocal conversion? */ +- char *sep, *right, *left; ++ char *sep = NULL, *right = NULL, *left = NULL; + + doingrec=0; + havestr = removepadding(havestr); +@@ -1970,7 +1972,8 @@ addtolist(struct unittype *have, char *searchstring, char *rname, char *name, ch + int *count, int searchtype) + { + struct unittype want; +- int len,keepit; ++ int len = 0; ++ int keepit = 0; + + if (!name) + return; +@@ -2243,7 +2246,7 @@ completeunits(char *text, int state) + curunit = utab[uhash]; + } + if (!curunit && !curprefix){ +- if (curprefix = plookup(text)){ ++ if ((curprefix = plookup(text))){ + if (strlen(curprefix->name)>1 && strlen(curprefix->name)file; + unitline = function->linenumber; + } +- else if (unit = ulookup(str)){ ++ else if ((unit = ulookup(str))){ + unitline = unit->linenumber; + file = unit->file; + } +@@ -2678,7 +2681,7 @@ main(int argc, char **argv) + } + + if (!interactive) { +- if (funcval = isfunction(havestr)){ ++ if ((funcval = isfunction(havestr))){ + showfuncdefinition(funcval); + exit(0); + } +@@ -2688,7 +2691,7 @@ main(int argc, char **argv) + showdefinition(havestr,&have); + exit(0); + } +- if (funcval = isfunction(wantstr)){ ++ if ((funcval = isfunction(wantstr))){ + if (showfunc(havestr, &have, funcval)) + exit(1); + else +@@ -2710,7 +2713,7 @@ main(int argc, char **argv) + } while (isblankstr(havestr) || ishelpquery(havestr,0) || + (isfunction(havestr)==0 + && processunit(&have, havestr, queryhave, POINT))); +- if (funcval = isfunction(havestr)){ ++ if ((funcval = isfunction(havestr))){ + showfuncdefinition(funcval); + continue; + } +@@ -2728,7 +2731,7 @@ main(int argc, char **argv) + && processunit(&want, wantstr, querywant, POINT)); + if (isblankstr(wantstr)) + showdefinition(havestr,&have); +- else if (funcval = isfunction(wantstr)) ++ else if ((funcval = isfunction(wantstr))) + showfunc(havestr, &have, funcval); + else { + showanswer(havestr,&have,wantstr, &want); diff --git a/units-1.87-gcc-warnings-2.patch b/units-1.87-gcc-warnings-2.patch new file mode 100644 index 0000000..1a6f39c --- /dev/null +++ b/units-1.87-gcc-warnings-2.patch @@ -0,0 +1,67 @@ +diff --git a/parse.y b/parse.y +index 0bdd8a3..3d2c8c2 100644 +--- a/parse.y ++++ b/parse.y +@@ -247,38 +247,38 @@ double strtod(); + + + struct function +- realfunctions[] = { "sin", sin, ANGLEIN, +- "cos", cos, ANGLEIN, +- "tan", tan, ANGLEIN, +- "ln", log, DIMENSIONLESS, +- "log", log10, DIMENSIONLESS, +- "log2", logb2, DIMENSIONLESS, +- "exp", exp, DIMENSIONLESS, +- "acos", acos, ANGLEOUT, +- "atan", atan, ANGLEOUT, +- "asin", asin, ANGLEOUT, +- 0, 0, 0}; ++ realfunctions[] = { {"sin", sin, ANGLEIN}, ++ {"cos", cos, ANGLEIN}, ++ {"tan", tan, ANGLEIN}, ++ {"ln", log, DIMENSIONLESS}, ++ {"log", log10, DIMENSIONLESS}, ++ {"log2", logb2, DIMENSIONLESS}, ++ {"exp", exp, DIMENSIONLESS}, ++ {"acos", acos, ANGLEOUT}, ++ {"atan", atan, ANGLEOUT}, ++ {"asin", asin, ANGLEOUT}, ++ {0, 0, 0}}; + + struct { + char op; + int value; +-} optable[] = { '*', MULTIPLY, +- '/', DIVIDE, +- '|', NUMDIV, +- '+', ADD, +- '(', '(', +- ')', ')', +- '^', EXPONENT, +- '~', FUNCINV, +- 0, 0 }; ++} optable[] = { {'*', MULTIPLY}, ++ {'/', DIVIDE}, ++ {'|', NUMDIV}, ++ {'+', ADD}, ++ {'(', '('}, ++ {')', ')'}, ++ {'^', EXPONENT}, ++ {'~', FUNCINV}, ++ {0, 0}}; + + struct { + char *name; + int value; +-} strtable[] = { "sqrt", SQRT, +- "cuberoot", CUBEROOT, +- "per" , DIVIDE, +- 0, 0 }; ++} strtable[] = { {"sqrt", SQRT}, ++ {"cuberoot", CUBEROOT}, ++ {"per" , DIVIDE}, ++ {0, 0}}; + + int yylex(YYSTYPE *lvalp, struct commtype *comm) + { diff --git a/units.spec b/units.spec index 4d7b1a6..fb07cbb 100644 --- a/units.spec +++ b/units.spec @@ -1,15 +1,18 @@ Summary: A utility for converting amounts from one unit to another Name: units Version: 1.87 -Release: 5%{?dist} +Release: 6%{?dist} Source: ftp://ftp.gnu.org/gnu/units/%{name}-%{version}.tar.gz +Patch1: units-1.87-gcc-warnings-1.patch +Patch2: units-1.87-gcc-warnings-2.patch URL: http://www.gnu.org/software/units/units.html -License: GPLv2+ +License: GPLv3+ Group: Applications/Engineering BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires(post): /sbin/install-info Requires(preun): /sbin/install-info -BuildRequires: readline-devel ncurses-devel +BuildRequires: ncurses-devel +BuildRequires: readline-devel %description Units converts an amount from one unit to another, or tells you what @@ -19,10 +22,12 @@ well as conversions such as Fahrenheit to Celsius. %prep %setup -q +%patch1 -p1 +%patch2 -p1 %build %configure -make +make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT @@ -45,7 +50,7 @@ if [ $1 = 0 -a -e %{_infodir}/units.info.gz ]; then fi %files -%defattr(-,root,root) +%defattr(-,root,root,-) %doc ChangeLog COPYING NEWS README %{_bindir}/* %{_datadir}/units.dat @@ -53,6 +58,10 @@ fi %{_mandir}/man1/* %changelog +* Tue Dec 01 2009 Kamil Dudka - 1.87-6 +- update license to GPLv3+, sanitize specfile +- fix tons of gcc warnings + * Thu Aug 20 2009 Zdenek Prikryl - 1.87-5 - Don't complain if installing with --excludedocs (#515941)