From: Chris Koeritz Date: Sun, 22 Nov 2015 09:40:06 +0000 (-0500) Subject: fixing column flags for splitter. also need to fix some persistent issues with end... X-Git-Tag: 2.140.90~576 X-Git-Url: https://feistymeow.org/gitweb/?p=feisty_meow.git;a=commitdiff_plain;h=6fd0c83fb2f5fed78bc0014f912e77a0963bb962 fixing column flags for splitter. also need to fix some persistent issues with end of line in splitter esp. where double dashes occur. --- diff --git a/nucleus/applications/utilities/splitter.cpp b/nucleus/applications/utilities/splitter.cpp index 0de8347a..7eac606f 100644 --- a/nucleus/applications/utilities/splitter.cpp +++ b/nucleus/applications/utilities/splitter.cpp @@ -65,7 +65,7 @@ Any filenames on the command line are split and sent to standard output.\n\ The following options change how the splitting is performed:\n\ --help or -?\tShow this help information.\n\ --mincol N\tMinimum column to use for output.\n\ - --maxcol N\tMinimum column to use for output.\n\ + --maxcol N\tMaximum column to use for output.\n\ ")); return -3; } @@ -77,11 +77,19 @@ int splitter_app::execute() // retrieve any specific flags first. astring temp; int min_col = 0; - if (cmds.get_value("mincol", temp)) + int min_indy = 0; +//hmmm: this whole thing is annoying. we need a better way to have a list of parms. + if (cmds.find("mincol", min_indy)) { + cmds.get_value("mincol", temp); min_col = temp.convert(min_col); - int max_col = 77; - if (cmds.get_value("maxcol", temp)) + } + int max_col = 78; + int max_indy = 0; + if (cmds.find("maxcol", max_indy)) { + cmds.get_value("maxcol", temp); max_col = temp.convert(max_col); + } +//printf("got max_col=%d\n", max_col); // look for help command. int junk_index = 0; if (cmds.find("help", junk_index, false) @@ -92,12 +100,16 @@ int splitter_app::execute() return 0; } + int skip_index = basis::maximum(min_indy, max_indy); + skip_index += 2; +//printf("got a skip index of %d\n", skip_index); + // gather extra input files. string_set input_files; - for (int i = 0; i < cmds.entries(); i++) { + for (int i = skip_index; i < cmds.entries(); i++) { const command_parameter &curr = cmds.get(i); if (curr.type() == command_parameter::VALUE) { -//log(astring("adding input file:") + curr.text()); +log(astring("adding input file:") + curr.text()); input_files += curr.text(); } } @@ -112,7 +124,6 @@ int splitter_app::execute() if (!num_chars) continue; //printf("line len=%d, cont=%s\n", line_read.length(), line_read.s()); accumulator += line_read; -//// accumulator += '\n'; } } @@ -124,7 +135,6 @@ int splitter_app::execute() if (!got) break; //printf("line=%s\n", got); accumulator += got; -//// accumulator += '\n'; } } //printf("splitting accum with %d chars...\n", accumulator.length()); diff --git a/nucleus/library/application/command_line.cpp b/nucleus/library/application/command_line.cpp index 0fb818aa..de6d6110 100644 --- a/nucleus/library/application/command_line.cpp +++ b/nucleus/library/application/command_line.cpp @@ -25,6 +25,9 @@ #include #include +#include +//temp + #undef LOG #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s) @@ -367,6 +370,7 @@ LOG(astring("found option string with dash! string is: ") + option_string); bool command_line::get_value(char option_character, astring &value, bool case_sense) const { + FUNCDEF("get_value"); value = ""; int posn = 0; // where we find the flag. if (!find(option_character, posn, case_sense)) return false; @@ -394,17 +398,21 @@ LOG(astring("found option string with dash! string is: ") + option_string); value = ""; int posn = 0; // where we find the flag. if (!find(option_string, posn, case_sense)) return false; +//printf("found the flag! at %d\n", posn); // get the value after the flag, if there is such. posn++; // this is where we think our flag's value lives. if (posn >= entries()) return false; +//printf("next posn is still okay at %d\n", posn); // there's still an entry after where we found our flag; grab it. command_parameter cp = get(posn); +//printf("comm parm has text %s\n", cp.text().s()); if (cp.type() != command_parameter::VALUE) return false; // finally; we've found an appropriate text value. value = cp.text(); +//printf("assigning value %s\n", value.s()); return true; } diff --git a/nucleus/library/textual/string_manipulation.cpp b/nucleus/library/textual/string_manipulation.cpp index a0febcaa..b2ba4748 100644 --- a/nucleus/library/textual/string_manipulation.cpp +++ b/nucleus/library/textual/string_manipulation.cpp @@ -222,11 +222,11 @@ void string_manipulation::split_lines(const astring &input_in, astring &output, // check that we're still in bounds. int chars_added = next_break - j + 1; - if (col + chars_added + punct_adder > max_column + 1) { + if (col + chars_added + punct_adder > max_column) { // we need to break before the next breakable character. break_line = true; just_had_break = true; - if (col + chars_added <= max_column + 1) { + if (col + chars_added <= max_column) { // it will fit without the punctuation spaces, which is fine since // it should be the end of the line. invisible = false; @@ -234,7 +234,7 @@ void string_manipulation::split_lines(const astring &input_in, astring &output, end_sentence = false; punct_adder = 0; keep_on_line = true; - } else if (min_column + chars_added > max_column + 1) { + } else if (min_column + chars_added > max_column) { // this word won't ever fit unless we break it. int chars_left = max_column - col + 1; // remember to take out room for the dash also. diff --git a/scripts/core/inventory.sh b/scripts/core/inventory.sh index 4e88af11..d4a00e5c 100644 --- a/scripts/core/inventory.sh +++ b/scripts/core/inventory.sh @@ -37,7 +37,7 @@ fi # decide whether they've got splitter available or not. if [ -f "$BINDIR/splitter" -o -f "$BINDIR/splitter.exe" ]; then - splitter="$BINDIR/splitter" + splitter="$BINDIR/splitter --maxcol $(($COLUMNS - 1))" else # not available, so just emit as huge overly long string. splitter="cat"