# HG changeset patch # User Rob Landley # Date 1340761514 18000 # Node ID 1121e0f4213205edaade9fa29932832dd3f9ee18 # Parent c9865aadb9fcfb69ca2a69b51e0303a91381e64b Some refactoring, shouldn't affect the generated code. diff -r c9865aadb9fc -r 1121e0f42132 toys/od.c --- a/toys/od.c Tue Jun 26 19:36:45 2012 -0500 +++ b/toys/od.c Tue Jun 26 20:45:14 2012 -0500 @@ -154,23 +154,20 @@ offset = TT.jump_bytes; } - do { + for (;;) { int len; int max_len = OD_BLOCK_SIZE; - if ((toys.optflags & FLAG_N) && - offset + OD_BLOCK_SIZE > TT.max_count) + if ((toys.optflags & FLAG_N) && offset + OD_BLOCK_SIZE > TT.max_count) max_len = TT.max_count - offset; len = xread(fd, block[index], max_len); - if (!len) - break; + if (!len) break; memset(&block[index][len], 0, OD_BLOCK_SIZE - len); - if (!(toys.optflags & FLAG_v) && - offset > 0 && - memcmp(block[0], block[1], OD_BLOCK_SIZE) == 0) { - if (!last_match) - puts("*"); + if (!(toys.optflags & FLAG_v) && offset > 0 && + memcmp(block[0], block[1], OD_BLOCK_SIZE) == 0) + { + if (!last_match) puts("*"); last_match = 1; } else { display_line(offset, block[index], len); @@ -179,9 +176,8 @@ offset += len; index = !index; - if (len != OD_BLOCK_SIZE) - break; - } while (1); + if (len != OD_BLOCK_SIZE) break; + } if (!(toys.optflags & FLAG_N) && offset != TT.max_count) display_line(offset, NULL, 0); @@ -211,10 +207,8 @@ error_exit("invalid width for ascii base"); break; case 'd': case 'x': case 'o': case'u': - if (width != 1 && width != 2 && - width != 4 && width != 8) - error_exit("this system doesn't provide a %d-byte type", - width); + if (width != 1 && width != 2 && width != 4 && width != 8) + error_exit("this system doesn't provide a %d-byte type", width); break; case 'f': if (width != 4 && width != 8) @@ -231,20 +225,13 @@ void od_main(void) { - if (!TT.address_base) - TT.address_base = "o"; - if (toys.optflags & FLAG_b) - append_base("o1"); - if (toys.optflags & FLAG_d) - append_base("u2"); - if (toys.optflags & FLAG_o) - append_base("o2"); - if (toys.optflags & FLAG_s) - append_base("d2"); - if (toys.optflags & FLAG_x) - append_base("x2"); - if (!TT.output_base) - append_base("o2"); + if (!TT.address_base) TT.address_base = "o"; + if (toys.optflags & FLAG_b) append_base("o1"); + if (toys.optflags & FLAG_d) append_base("u2"); + if (toys.optflags & FLAG_o) append_base("o2"); + if (toys.optflags & FLAG_s) append_base("d2"); + if (toys.optflags & FLAG_x) append_base("x2"); + if (!TT.output_base) append_base("o2"); valid_bases(); loopfiles(toys.optargs, do_od); }