be4311c07e14feb728abc6425ee606ffaa611a58 markd Fri Jan 22 06:46:58 2021 -0800 merge with master diff --git src/utils/wordLine/wordLine.c src/utils/wordLine/wordLine.c index 43fd015..5c05767 100644 --- src/utils/wordLine/wordLine.c +++ src/utils/wordLine/wordLine.c @@ -18,41 +18,37 @@ "wordLine - chop up words by white space and output them with one\n" "word to each line.\n" "usage:\n" " wordLine inFile(s)\n" "Output will go to stdout." "Options:\n" " -csym - Break up words based on C symbol rules rather than white space\n" ); } void wordLine(char *file) /* wordLine - chop up words by white space and output them with one * word to each line. */ { struct lineFile *lf = lineFileOpen(file, TRUE); -int lineSize, wordCount; -static char *line, *words[1024*16]; -int i; + char *line; -while (lineFileNext(lf, &line, &lineSize)) - { - wordCount = chopLine(line, words); - for (i=0; i<wordCount; ++i) +while (lineFileNext(lf, &line, NULL)) { - puts(words[i]); - } + char *word; + while ((word = nextWord(&line)) != NULL) + puts(word); } lineFileClose(&lf); } void tokenLine(char *file) /* tokenLine - chop up words by c-tokens and output one per line. */ { struct tokenizer *tok = tokenizerNew(file); char *s; tok->leaveQuotes = TRUE; tok->uncommentC = TRUE; tok->uncommentShell = TRUE; while ((s = tokenizerNext(tok)) != NULL) puts(s);