| Homepage Computerstoff (Hauptseite) | [français] [english] |
fortext-0.04.tgz (8K) [Der ausführbare Code ist gestrippt ca. 12K groß. Das Paket enthält die sourcen und ein man-page-template.]
(benötigt lediglich die Standard-Include-Dateien.)
Häufig wollte ich ascii-Texte, die ich irgendwo im Netz, insbesondere im usenet, aufgelesen habe, neu formatieren. Die Hauptarbeit dabei bestand darin, die Absätze durch Leerzeilen zu markieren und dann die einzelnen Abschnitte mit fester (ev. neuer) Zeilenlänge zu reformatieren. Das letztere kann jeder halbwegs vernünftige Editor. Beim ersteren mußte ich jedesmal Hand anlegen.
fortext ist ein Programm, welches versucht, zu erraten, an welchen Stellen eines Textes Absätze sind, und den Text dann je nach gesetzten Optionen auf die eine oder andere Art neu formatiert. Normalerweise liest es einen Text von stdin und schreibt das Ergebnis nach stdout, man kann aber auch von Dateien lesen und in Dateien schreiben. Nähere Informationen kann man der manpage entnehmen, die durch ein make hergestellt wird.
Hier ein Beispiel: Aus dem Text (den ich, durch diverse news-reader verunstaltet, tatsächlich so bekommen habe)
Of the Spirit ------------- (c) Jasjit Singh, March 1999 The crew of the USS Voyager was celebrating. They had just completed another milestone in their long journey towards Earth, and everyone was in a jovial mood. A group of the senior staff agreed to head down to the mess hall for their celebration. On their way, Tom Paris and Seven of Nine encountered Chakotay in the hallway. "Chakotay, you'll be joining us in the mess hall?" inquired Paris. Chakotay grinned but shook his head. "I need to be getting back to my quarters," he replied. "Its early still! Come on, have a drink with us," cajoled Paris. "Thanks but I can't. It is coming close to my meditation time," said Chakotay, smiling politely. "Ah, yes, the daily meditation," Paris nodded. "You have been doing that day in and day out, every day since I've known you. Doesn't it get repetitive?" "Repetitive, no. Customary, yes. Beneficial, absolutely." "I don't know, Chakotay. We're in the twenty fourth century. We have warp drive. We are out among the stars! Is ancient religion really that important any more?" [...] |
macht fortext, wenn man keinen weiteren Optionen angibt, folgendes:
Of the Spirit ------------- (c) Jasjit Singh, March 1999 The crew of the USS Voyager was celebrating. They had just completed another milestone in their long journey towards Earth, and everyone was in a jovial mood. A group of the senior staff agreed to head down to the mess hall for their celebration. On their way, Tom Paris and Seven of Nine encountered Chakotay in the hallway. "Chakotay, you'll be joining us in the mess hall?" inquired Paris. Chakotay grinned but shook his head. "I need to be getting back to my quarters," he replied. "Its early still! Come on, have a drink with us," cajoled Paris. "Thanks but I can't. It is coming close to my meditation time," said Chakotay, smiling politely. "Ah, yes, the daily meditation," Paris nodded. "You have been doing that day in and day out, every day since I've known you. Doesn't it get repetitive?" "Repetitive, no. Customary, yes. Beneficial, absolutely." "I don't know, Chakotay. We're in the twenty fourth century. We have warp drive. We are out among the stars! Is ancient religion really that important any more?" [...] |
Wenn allerdings die Zeile mit dem vorletzten Absatz (bis "absolutely") nur ein paar Zeichen länger gewesen wäre, hätte fortext diesen Absatz nicht richtig erkannt, sondern mit den darauf folgenden Zeilen verbunden.
fortext-0.02 ist, wie die Versionsnummer schon zeigt, einer meiner ersten Versuche. Wieviel das Programm in der Praxis taugt, weiß ich deshalb noch nicht. Auch für einige interne Parameter müssen noch optimale Werte gefunden werden, und sie sollten u.U. durch Optionen einstellbar gemacht werden.
Alle Programmteile stehen unter der BSD-Lizenz.
Das Programm läuft auf meinen Linux-Kisten (SuSE-6.4 und 7.0) und in einer CygWin-Umgebung auf Windows-Systemen. Es läßt sich mit dem gcc übersetzen. Anpassungen an andere C-Libraries und/oder Betriebssyteme sollten nicht schwierig sein, zumal der Code nicht sehr umfangreich ist.
| Homepage Computerstoff (Hauptseite) | by Michael Becker, 10/2001. Letzte Änderung 7/2002 |