+
+ if (*endp == '\0') {
+ /*
+ * There's nothing after the file size,
+ * so the size is in units of 1 MB
+ * (1,000,000 bytes).
+ */
+ Cflagmult = 1000000;
+ } else {
+ /*
+ * There's something after the file
+ * size.
+ *
+ * If it's a single letter, then:
+ *
+ * if the letter is k or K, the size
+ * is in units of 1 KiB (1024 bytes);
+ *
+ * if the letter is m or M, the size
+ * is in units of 1 MiB (1,048,576 bytes);
+ *
+ * if the letter is g or G, the size
+ * is in units of 1 GiB (1,073,741,824 bytes).
+ *
+ * Otherwise, it's an error.
+ */
+ switch (*endp) {
+
+ case 'k':
+ case 'K':
+ Cflagmult = 1024;
+ break;
+
+ case 'm':
+ case 'M':
+ Cflagmult = 1024*1024;
+ break;
+
+ case 'g':
+ case 'G':
+ Cflagmult = 1024*1024*1024;
+ break;
+
+ default:
+ error("invalid file size %s", optarg);
+ }
+
+ /*
+ * OK, there was a letter that we treat
+ * as a units indication; was there
+ * anything after it?
+ */
+ endp++;
+ if (*endp != '\0') {
+ /* Yes - error */
+ error("invalid file size %s", optarg);
+ }
+ }
+