Aaargh! All those x's have a rather neurotic SpamAssassin dumping this
thread in the spam folder :-/.
Recently, Somebody Somewhere wrote these words
> I'm sorry, I have NO smart ideas at all... Here's a stupid one,
> though, that may help a tiny bit... :P Possibly the indent program
> might do it for you, if you poke it just the right way? :P Other
> than that, I'm pretty much stumped... I wrote the following, but it's
> only a throught. :P It may be a a bit lame, but may at least help
> point you in the right direction. :) If you can't find something
> that'll do what you want, make your own! :) Sometimes it's the only
> way. :)
>
> Here's an example, which is NOT complete, probably has a bug or two in
> it, and since YOU really know what you need, you can take it from
> there. :P
>
> #include <stdio.h>
> #include <ctype.h>
>
> /* Make this how long you want the lines to be */
> #define MAX_LINE_LENGTH 80
>
> int main(void)
> {
> FILE *fp1;
> FILE *fp2;
>
> char c;
> char c2;
>
> int counter;
> int endofline;
>
> if ((fp1 = fopen("inputfile.txt", "r")) == NULL)
> {
> puts("Damn, couldn't open input file!");
> return -1;
> }
>
> if ((fp2 = fopen("outputfile.txt", "w")) == NULL)
> {
> puts("Damn, couldn't open output file!");
> return -1;
> }
>
> gottawrap = 0;
>
> while (1)
> {
> for (counter = 0; ; counter++)
> {
> c = fgetc(fp1);
>
> if (c == EOF)
> {
> fclose(fp1);
> fclose(fp2);
> return 0;
> }
>
> if (counter > MAX_LINE_LENGTH)
> {
> if (c == ' ' || c == '\t')
> {
> /* This line here will insert a tab
> when it's split the line */
> fputs("\n\t", fp2);
> break;
> }
> }
>
> if (c == '\r' || c == '\n')
> {
> c2 = fgetc(fp1);
>
> if (c2 == '\r' || c2 == '\n')
> {
> fputc('\n', fp2);
> }
> else
> {
> ungetc(c2);
> }
> }
>
> putc(c, fp2);
> }
> }
> }
>
>
There is an indent program, is there? Good . I'll go after it.
Thanks very much for the effort in the above example..... It's a pity
I'm illiterate in C. I'll try it. The max line lingth I see. Where do I
set the indent?
A bit of reading on awk and sed were illuminating.
The sed info page vies for the longest entry without telling you
anything with the awk one, which is the verbose and confusing manual in
disguise, full of chapters like "What you don't want to know about ...."
It seems I'm limited to Posix regular expressions, whereas I found perl
ones better to play with.
Mind you I did manage to remove all my control fields with a single
's///g' expression, which cheered me up. Awk looks the business, but the
guy never follows a thread - he jumps all over the place.
--
With best Regards,
Declan Moriarty.
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page