changeset 752:c79aaed75bd8

compile-fc-batt: allow possible third field in source lines Battery tables maintained in the fc-battery-conf repository will now have a third field added, defining thresholds for the battery bars icon, and there will be a new utility to compile them into the new /etc/batterytab2 file read by the FC Tourmaline version of our FCHG driver. For backward compatibility with the original Magnetite version of FCHG, compile-fc-batt remains the tool for compiling the original /etc/batterytab file format, and it needs to ignore the newly added third field in battery table sources.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Nov 2020 20:37:55 +0000
parents 5dd748850f2b
children cae22bec3cba
files ffstools/newcomp/compile-fc-batt.c
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ffstools/newcomp/compile-fc-batt.c	Thu Nov 05 19:30:14 2020 +0000
+++ b/ffstools/newcomp/compile-fc-batt.c	Thu Nov 05 20:37:55 2020 +0000
@@ -1,7 +1,7 @@
 /*
- * This utility compiles a table of battery thresholds for the new FreeCalypso
- * battery management code from ASCII source into the binary form suitable
- * for uploading into /etc/batterytab on a FreeCalypso device.
+ * This utility compiles a table of battery thresholds for the 2017-12 version
+ * of FreeCalypso battery management code from ASCII source into the binary
+ * form suitable for uploading into /etc/batterytab on a FreeCalypso device.
  */
 
 #include <ctype.h>
@@ -43,10 +43,9 @@
 	percent = strtoul(cp, 0, 10);
 	while (isdigit(*cp))
 		cp++;
-	while (isspace(*cp))
-		cp++;
-	if (*cp != '\0' && *cp != '#')
+	if (*cp && !isspace(*cp))
 		goto inv;
+	/* ignore possible third field added in 2020-11 for bars threshold */
 	if (mv > 0xFFFF) {
 		fprintf(stderr, "%s line %d: the millivolt value is invalid\n",
 			infname, lineno);