5ba0549a475bafee7d17a3fa9fc3a42d08cb1c11 tdreszer Fri May 3 17:06:11 2013 -0700 Clarified some comments based upon Angie's feedback. Thanks. diff --git src/lib/bits.c src/lib/bits.c index e3e6b0c..1cca72c 100644 --- src/lib/bits.c +++ src/lib/bits.c @@ -358,56 +358,57 @@ /* Print part or all of bit map as a string of 0s and 1s. Mostly useful for * debugging */ { int i; for (i = startIx; i < bitCount; i++) { if (bitReadOne(a, i)) fputc('1', out); else fputc('0', out); } fputc('\n', out); } void bitsOut(FILE* out, Bits *bits, int startIx, int bitCount, boolean onlyOnes) -// Print part or all of bit map as a string of 0s and 1s. Optionally only print 1s and [bracket]. +// Print part or all of bit map as a string of 0s and 1s. +// If onlyOnes, enclose result in [] and use ' ' instead of '0'. { if (onlyOnes) fputc('[', out); int ix = startIx; for ( ; ix < bitCount; ix++) { if (bitReadOne(bits, ix)) fputc('1', out); else { if (onlyOnes) fputc(' ', out); else fputc('0', out); } } if (onlyOnes) fputc(']', out); } Bits *bitsIn(struct lm *lm,char *bitString, int len) // Returns a bitmap from a string of 1s and 0s. Any non-zero, non-blank char sets a bit. // Returned bitmap is the size of len even if that is longer than the string. -// Optionally supply local memory. +// Optionally supply local memory. Note does NOT handle enclosing []s printed with bitsOut(). { if (bitString == NULL || len == 0) return NULL; Bits *bits = NULL; if (lm != NULL) bits = lmBitAlloc(lm,len); else bits = bitAlloc(len); int ix = 0; for ( ;ix < len && bitString[ix] != '\0'; ix++) { if (bitString[ix] != '0' && bitString[ix] != ' ') bitSetOne(bits, ix);