aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2018-06-18 21:19:57 +1200
committerDavid Phillips <david@sighup.nz>2018-06-18 21:21:21 +1200
commit4a400975b24acef58d6c3ee6092413ff51a0be86 (patch)
tree851ef26d934f95e23c708c76f5a2c1dece27cc2a
parent62aa5397036216480c859849a8d983b7bce5bf47 (diff)
downloadsand-leek-4a400975b24acef58d6c3ee6092413ff51a0be86.tar.xz
Clarify documentation for make_unit_whatsit
-rw-r--r--unit_label.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/unit_label.c b/unit_label.c
index b050b89..b53e4a3 100644
--- a/unit_label.c
+++ b/unit_label.c
@@ -7,15 +7,18 @@
* label. While the value is larger than the current unit's maximum count,
* the value is divided by this count and the next unit in the table is
* examined. Example:
- * 100 flooby
- * 500 glargle
- * 30 lafplop // Can be any count
- * 0 NULL // Can be any count
+ * {100, "flooby" },
+ * {500, "glargle"},
+ * { 30, "lafplop"}, // Can be any non-zero count
+ * { 0, NULL } // Can be any count
*
- * Given this table, a value of:
- * 150 will store glargle and return 1.5
- * 50 will store flooby and return 50
- * 55000 will store lafplop and return 1.1
+ * Given this table is in `labels`,
+ * ret1 = make_unit_whatsit(labels, &unit1, 150);
+ * ret2 = make_unit_whatsit(labels, &unit2, 50);
+ * ret3 = make_unit_whatsit(labels, &unit3, 55000);
+ * leaves ret1 as 1.5 and unit1 as "gargle",
+ * leaves ret2 as 50 and unit2 as "flooby",
+ * leaves ret3 as 1.1 and unit3 as "lafplop",
*/
double make_unit_whatsit(const struct unit_label l[], char **unit, double value) {
size_t i = 0;