+2008-07-10 Guillem Jover <guillem@debian.org>
+
+ * lib/dpkg-priv.h (min, max): New macros.
+ * lib/tarfn.c: Include <dpkg-priv.h>.
+ * src/configure.c: Likewise.
+ * src/enquiry.c: Likewise.
+
+ * src/configure.c (conffderef): Use max instead of hardcoded test.
+ * lib/tarfn.c (TarExtractor): Use min instead of hardcoded test.
+ * lib/fields.c (conffvalue_lastword): Likewise.
+ * src/enquiry.c (limiteddescription): Likewise.
+ * src/main.c (setforce): Likewise.
+ * src/query.c (limiteddescription): Likewise.
+
2008-07-10 Guillem Jover <guillem@debian.org>,
Timothy G Abbott <tabbott@mega-man.mit.edu>
#define sizeof_array(a) (sizeof(a) / sizeof((a)[0]))
#endif
+#ifndef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef max
+#define max(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
/* String handling. */
char *str_escape_fmt(char *dest, const char *src);
malformed:
parse_error(filename, lno, pigp,
_("value for `conffiles' has malformatted line `%.*s'"),
- (int)(endent - value > 250 ? 250 : endent - value), value);
+ (int)min(endent - value, 250), value);
}
void f_conffiles(struct pkginfo *pigp, struct pkginfoperfile *pifp,
#include <errno.h>
#include <tarfn.h>
#include <dpkg.h>
+#include <dpkg-priv.h>
#include "strnlen.h"
}
break;
}
-
- copysize = long_read > 512 ? 512 : long_read;
+ copysize = min(long_read, 512);
memcpy (bp, buffer, copysize);
bp += copysize;
#include <dpkg.h>
#include <dpkg-db.h>
+#include <dpkg-priv.h>
#include "filesdb.h"
#include "main.h"
return -1;
}
debug(dbg_conffdetail,"conffderef readlink gave %d, `%.*s'",
- r, r>0 ? r : 0, linkreadbuf);
+ r, max(r, 0), linkreadbuf);
if (r < linkreadbufsize-1) break;
need= r<<2;
}
#include <dpkg.h>
#include <dpkg-db.h>
+#include <dpkg-priv.h>
#include <myopt.h>
#include "filesdb.h"
if (!pdesc) pdesc= _("(no description available)");
p= strchr(pdesc,'\n');
if (!p) p= pdesc+strlen(pdesc);
- l= (p - pdesc > maxl) ? maxl : (int)(p - pdesc);
+ l = min(p - pdesc, maxl);
*pdesc_r=pdesc; *l_r=l;
}
#include <dpkg.h>
#include <dpkg-db.h>
+#include <dpkg-priv.h>
#include <myopt.h>
#include "main.h"
if (fip->opt)
*fip->opt= cip->arg;
} else
- badusage(_("unknown force/refuse option `%.*s'"), l<250 ? (int)l : 250, value);
+ badusage(_("unknown force/refuse option `%.*s'"), min(l, 250), value);
} else {
if (fip->opt)
*fip->opt= cip->arg;
if (!pdesc) pdesc= _("(no description available)");
p= strchr(pdesc,'\n');
if (!p) p= pdesc+strlen(pdesc);
- l= (p - pdesc > maxl) ? maxl : (int)(p - pdesc);
+ l = min(p - pdesc, maxl);
*pdesc_r=pdesc; *l_r=l;
}