Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/units ANSIfy, static + __dead
details: https://anonhg.NetBSD.org/src/rev/7ae23b688ccc
branches: trunk
changeset: 769340:7ae23b688ccc
user: joerg <joerg%NetBSD.org@localhost>
date: Tue Sep 06 18:35:41 2011 +0000
description:
ANSIfy, static + __dead
diffstat:
usr.bin/units/units.c | 104 ++++++++++++++++++++++---------------------------
1 files changed, 47 insertions(+), 57 deletions(-)
diffs (267 lines):
diff -r 866b7ac43cb5 -r 7ae23b688ccc usr.bin/units/units.c
--- a/usr.bin/units/units.c Tue Sep 06 18:34:57 2011 +0000
+++ b/usr.bin/units/units.c Tue Sep 06 18:35:41 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: units.c,v 1.16 2009/04/14 05:55:12 lukem Exp $ */
+/* $NetBSD: units.c,v 1.17 2011/09/06 18:35:41 joerg Exp $ */
/*
* units.c Copyright (c) 1993 by Adrian Mariano (adrian%cam.cornell.edu@localhost)
@@ -39,9 +39,9 @@
#define PRIMITIVECHAR '!'
-const char *powerstring = "^";
+static const char *powerstring = "^";
-struct {
+static struct {
const char *uname;
const char *uval;
} unittable[MAXUNITS];
@@ -58,36 +58,34 @@
} prefixtable[MAXPREFIXES];
-const char *NULLUNIT = "";
+static const char *NULLUNIT = "";
-int unitcount;
-int prefixcount;
+static int unitcount;
+static int prefixcount;
-int addsubunit __P((const char *[], const char *));
-int addunit __P((struct unittype *, const char *, int));
-void cancelunit __P((struct unittype *));
-int compare __P((const void *, const void *));
-int compareproducts __P((const char **, const char **));
-int compareunits __P((struct unittype *, struct unittype *));
-int compareunitsreciprocal __P((struct unittype *, struct unittype *));
-int completereduce __P((struct unittype *));
-void initializeunit __P((struct unittype *));
-int main __P((int, char **));
-void readerror __P((int));
-void readunits __P((const char *));
-int reduceproduct __P((struct unittype *, int));
-int reduceunit __P((struct unittype *));
-void showanswer __P((struct unittype *, struct unittype *));
-void showunit __P((struct unittype *));
-void sortunit __P((struct unittype *));
-void usage __P((void));
-void zeroerror __P((void));
-char *dupstr __P((const char *));
-const char *lookupunit __P((const char *));
+static int addsubunit(const char *[], const char *);
+static int addunit(struct unittype *, const char *, int);
+static void cancelunit(struct unittype *);
+static int compare(const void *, const void *);
+static int compareproducts(const char **, const char **);
+static int compareunits(struct unittype *, struct unittype *);
+static int compareunitsreciprocal(struct unittype *, struct unittype *);
+static int completereduce(struct unittype *);
+static void initializeunit(struct unittype *);
+static void readerror(int);
+static void readunits(const char *);
+static int reduceproduct(struct unittype *, int);
+static int reduceunit(struct unittype *);
+static void showanswer(struct unittype *, struct unittype *);
+static void showunit(struct unittype *);
+static void sortunit(struct unittype *);
+__dead static void usage(void);
+static void zeroerror(void);
+static char *dupstr(const char *);
+static const char *lookupunit(const char *);
-
-char *
+static char *
dupstr(const char *str)
{
char *ret;
@@ -99,14 +97,14 @@
}
-void
+static void
readerror(int linenum)
{
warnx("Error in units file '%s' line %d", UNITSFILE, linenum);
}
-void
+static void
readunits(const char *userfile)
{
FILE *unitfile;
@@ -221,15 +219,14 @@
fclose(unitfile);
}
-void
+static void
initializeunit(struct unittype * theunit)
{
theunit->factor = 1.0;
theunit->numerator[0] = theunit->denominator[0] = NULL;
}
-
-int
+static int
addsubunit(const char *product[], const char *toadd)
{
const char **ptr;
@@ -245,8 +242,7 @@
return 0;
}
-
-void
+static void
showunit(struct unittype * theunit)
{
const char **ptr;
@@ -291,8 +287,7 @@
printf("\n");
}
-
-void
+static void
zeroerror()
{
warnx("Unit reduces to zero");
@@ -305,7 +300,7 @@
Returns 0 for successful addition, nonzero on error.
*/
-int
+static int
addunit(struct unittype * theunit, const char *toadd, int flip)
{
char *scratch, *savescr;
@@ -389,16 +384,14 @@
return 0;
}
-
-int
+static int
compare(const void *item1, const void *item2)
{
return strcmp(*(const char * const *) item1,
*(const char * const *) item2);
}
-
-void
+static void
sortunit(struct unittype * theunit)
{
const char **ptr;
@@ -410,8 +403,7 @@
qsort(theunit->denominator, count, sizeof(char *), compare);
}
-
-void
+static void
cancelunit(struct unittype * theunit)
{
const char **den, **num;
@@ -447,7 +439,7 @@
static char buffer[100]; /* buffer for lookupunit answers with
prefixes */
-const char *
+static const char *
lookupunit(const char *unit)
{
int i;
@@ -522,7 +514,7 @@
#define ERROR 4
-int
+static int
reduceproduct(struct unittype * theunit, int flip)
{
@@ -565,7 +557,7 @@
Returns 0 on success, or 1 on unknown unit error.
*/
-int
+static int
reduceunit(struct unittype * theunit)
{
int ret;
@@ -579,8 +571,7 @@
return 0;
}
-
-int
+static int
compareproducts(const char **one, const char **two)
{
while (*one || *two) {
@@ -603,7 +594,7 @@
/* Return zero if units are compatible, nonzero otherwise */
-int
+static int
compareunits(struct unittype * first, struct unittype * second)
{
return
@@ -611,7 +602,7 @@
compareproducts(first->denominator, second->denominator);
}
-int
+static int
compareunitsreciprocal(struct unittype * first, struct unittype * second)
{
return
@@ -620,7 +611,7 @@
}
-int
+static int
completereduce(struct unittype * unit)
{
if (reduceunit(unit))
@@ -631,7 +622,7 @@
}
-void
+static void
showanswer(struct unittype * have, struct unittype * want)
{
if (compareunits(have, want)) {
@@ -651,8 +642,8 @@
}
-void
-usage()
+static void
+usage(void)
{
fprintf(stderr,
"\nunits [-f unitsfile] [-q] [-v] [from-unit to-unit]\n");
@@ -662,7 +653,6 @@
exit(3);
}
-
int
main(int argc, char **argv)
{
Home |
Main Index |
Thread Index |
Old Index