Tail now works (costs 6k). Several other updates.
-Erik
diff --git a/utility.c b/utility.c
index 469275f..de7a0fb 100644
--- a/utility.c
+++ b/utility.c
@@ -289,7 +289,7 @@
#endif
-#ifdef BB_TAR
+#if defined BB_TAR
/*
* Return the standard ls-like time string from a time_t
* This is static and so is overwritten on each call.
@@ -340,8 +340,10 @@
return total;
}
+#endif
+#if defined BB_TAR || defined BB_TAIL
/*
* Read all of the supplied buffer from a file.
* This does multiple reads as necessary.
@@ -1018,6 +1020,55 @@
#endif
+#if defined BB_DD || defined BB_TAIL
+/*
+ * Read a number with a possible multiplier.
+ * Returns -1 if the number format is illegal.
+ */
+extern long getNum (const char *cp)
+{
+ long value;
+
+ if (!isDecimal (*cp))
+ return -1;
+
+ value = 0;
+
+ while (isDecimal (*cp))
+ value = value * 10 + *cp++ - '0';
+
+ switch (*cp++) {
+ case 'm':
+ value *= 1048576;
+ break;
+
+ case 'k':
+ value *= 1024;
+ break;
+
+ case 'b':
+ value *= 512;
+ break;
+
+ case 'w':
+ value *= 2;
+ break;
+
+ case '\0':
+ return value;
+
+ default:
+ return -1;
+ }
+
+ if (*cp)
+ return -1;
+
+ return value;
+}
+#endif
+
+
/* END CODE */