Skip to content
This repository was archived by the owner on Jul 21, 2018. It is now read-only.

Commit 17e4d9f

Browse files
committed
fixed reading from stdin
1 parent b2d7b3c commit 17e4d9f

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Ansifilter ChangeLog
22

3+
06.08.2017
4+
5+
ansifilter 2.8
6+
7+
-fixed reading from stdin (https://github.com/andre-simon/ansifilter/issues/8)
8+
9+
---
10+
311
03.08.2017
412

513
ansifilter 2.7

README

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-------------------------------------------------------------------------------
2-
--- ANSIFILTER MANUAL - Version 2.6 --------------------------- JULY 2017 ---
2+
--- ANSIFILTER MANUAL - Version 2.8 ------------------------- AUGUST 2017 ---
33
-------------------------------------------------------------------------------
44

55
OSI Certified Open Source Software
@@ -60,9 +60,9 @@ Format options:
6060
--wrap-no-numbers Omit line numbers of wrapped lines (assumes -l)
6161

6262
ANSI art options:
63-
--art-cp437 Parse codepage 437 ANSI art (HTML, RTF output only)
64-
--art-bin Parse BIN/XBIN ANSI art (HTML, RTF output only)
65-
--art-tundra Parse Tundra ANSI art (HTML, RTF output only)
63+
--art-cp437 Parse codepage 437 ANSI art (HTML, RTF output)
64+
--art-bin Parse BIN/XBIN ANSI art (HTML output, no stdin)
65+
--art-tundra Parse Tundra ANSI art (HTML output, no stdin)
6666
--art-width Set ANSI art width (default 80)
6767
--art-height Set ANSI art height (default 150)
6868

@@ -76,6 +76,7 @@ ansifilter *.txt
7676
tail -f server.log | ansifilter
7777

7878
Parsing XBIN files overrides --art-width, --art-height and --map options.
79+
The ANSI art file formats BIN, XBIN and TND cannot be read from stdin.
7980

8081
The GUI version (ansifilter-gui) also accepts the first command line argument
8182
as input file name.

man/ansifilter.1.gz

42 Bytes
Binary file not shown.

src/codegenerator.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,11 @@ void CodeGenerator::allocateTermBuffer(){
964964
}
965965

966966
bool CodeGenerator::streamIsXBIN() {
967+
if (in==&cin) return false;
968+
967969
bool isXBIN = false;
968970
char head[5] = {0};
969-
if (in!=&cin && in->read (head, sizeof head -1) ) {
971+
if (in->read (head, sizeof head -1) ) {
970972
isXBIN = string(head)=="XBIN";
971973
}
972974
in->clear();
@@ -976,13 +978,14 @@ bool CodeGenerator::streamIsXBIN() {
976978

977979

978980
bool CodeGenerator::streamIsTundra() {
981+
if (in==&cin) return false;
982+
979983
bool isTND = false;
980984
char head[10] = {0};
981985

982-
if (in!=&cin && in->read (head, sizeof head -1) ) {
986+
if (in->read (head, sizeof head -1) ) {
983987
isTND = string(head)=="\x18TUNDRA24";
984988
}
985-
986989
in->clear();
987990
in->seekg (0, ios::beg);
988991
return isTND;

src/main.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ void ANSIFilterApp::printHelp()
8181
cout << " --wrap-no-numbers Omit line numbers of wrapped lines (assumes -l)\n";
8282

8383
cout << "\nANSI art options:\n";
84-
cout << " --art-cp437 Parse codepage 437 ANSI art (HTML, RTF output only)\n";
85-
cout << " --art-bin Parse BIN/XBIN ANSI art (HTML, RTF output only)\n";
86-
cout << " --art-tundra Parse Tundra ANSI art (HTML, RTF output only)\n";
84+
cout << " --art-cp437 Parse codepage 437 ANSI art (HTML and RTF output)\n";
85+
cout << " --art-bin Parse BIN/XBIN ANSI art (HTML output, no stdin)\n";
86+
cout << " --art-tundra Parse Tundra ANSI art (HTML output, no stdin)\n";
8787
cout << " --art-width Set ANSI art width (default 80)\n";
8888
cout << " --art-height Set ANSI art height (default 150)\n";
8989

@@ -95,6 +95,7 @@ void ANSIFilterApp::printHelp()
9595
cout << "ansifilter *.txt\n";
9696
cout << "tail -f server.log | ansifilter\n\n";
9797
cout << "Parsing XBIN files overrides --art-width, --art-height and --map options.\n";
98+
cout << "The ANSI art file formats BIN, XBIN and TND cannot be read from stdin.\n";
9899
cout << "\nPlease report bugs to " ANSIFILTER_EMAIL "\n";
99100
cout << "For updates see " ANSIFILTER_URL "\n";
100101
}

src/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ along with ANSIFilter. If not, see <http://www.gnu.org/licenses/>.
2525
#ifndef VERSION_H
2626
#define VERSION_H
2727

28-
#define ANSIFILTER_VERSION "2.7"
28+
#define ANSIFILTER_VERSION "2.8"
2929

3030
#define ANSIFILTER_URL "http://www.andre-simon.de/"
3131
#define ANSIFILTER_EMAIL "[email protected]"

0 commit comments

Comments
 (0)