From ff2178bf30e3eda566cc1d1670768c6d6694a8ac Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 24 Jun 2016 21:48:29 -0400 Subject: maint: refactor common expand(1) and unexpand(1) code * src/expand.c, src/unexpand.c: Move global variables from here... * src/expand-common.h, src/expand-common.c: ... to here. * src/expand.c, src/unexpand.c: (parse_tab_stops, validate_tab_stops, next_file): Move identical functions to new module. (add_tab_stop): Move to new module, including additional code from 'unexpand' (keeping max_column_width) which will have no effect in when used in 'expand'. Refactor common next-column calculation code into a new function 'get_next_tab_column'. * src/local.mk: (src_expand_SOURCES, src_unexpand_SOURCES): Add 'expand-common.c'; (noinst_HEADERS): Add 'expand-common.h'. * po/POTFILES.in: Add 'expand-common.c'. * tests/misc/expand.pl: Add more tests. * tests/misc/unexpand.pl: Likewise. * TODO: Move conclusions to above test after investigation. --- TODO | 4 ---- 1 file changed, 4 deletions(-) (limited to 'TODO') diff --git a/TODO b/TODO index de95e5a64..dc1a9e2a2 100644 --- a/TODO +++ b/TODO @@ -67,10 +67,6 @@ lib/strftime.c: Since %N is the only format that we need but that would expand /%(-_)?\d*N/ to the desired string and then pass the resulting string to glibc's strftime. -unexpand: [http://www.opengroup.org/onlinepubs/007908799/xcu/unexpand.html] - printf 'x\t \t y\n'|unexpand -t 8,9 should print its input, unmodified. - printf 'x\t \t y\n'|unexpand -t 5,8 should print "x\ty\n" - sort: Investigate better sorting algorithms; see Knuth vol. 3. We tried list merge sort, but it was about 50% slower than the -- cgit v1.2.3-70-g09d2