Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 7/17/84; site link.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!link!brf From: brf@link.UUCP (Bruce Fowler) Newsgroups: net.sources Subject: A program to list files from bottom to top Message-ID: <351@link.UUCP> Date: Thu, 5-Sep-85 22:32:37 EDT Article-I.D.: link.351 Posted: Thu Sep 5 22:32:37 1985 Date-Received: Sat, 7-Sep-85 04:06:06 EDT Organization: AT&T Bell Laboratories - Holmdel, NJ Lines: 116 $ cat spoon >/dev/bug # Gag on that, line eater! O.K ... I CAN'T STAND IT ANYMORE ... ALL THAT CREATIVITY! Here is the *ultimate* way to invert the lines in a file: $ tip | tip Enjoy! Bruce Fowler ^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v "The Twilight Zone - Love it or Leave it..." ____ ==> [ unzip here ] |____)-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8-8- /* tip.c - tip section of text sideways (90 degrees counterclockwise) */ #include #define TXTSIDE 80 /* number of rows and columns maximum */ int incval; /* column increment, 1 or 2 */ int padflag; /* to keep leading blank lines */ main(argc, argv ) int argc; char *argv[]; { char *p; /* for flag arg analysis */ int nrfiles; /* how many files processed */ FILE *fp; /* files to process */ /* analyze flags and do each file argument */ incval = 1; padflag = 0; nrfiles = 0; while (--argc > 0 ) { /* process each argument */ p = *++argv; if (*p == '-' ) { /* suck up flags */ while (*++p != '\0' ) switch (*p ) { /* s and d are opposite */ case 'd': /* pretend input is double spaced */ incval = 2; break; case 's': /* stop double spacing */ incval = 1; break; /* p and n are opposite */ case 'p': /* keep padding at left (top) */ padflag = 1; break; case 'n': /* left justify output */ padflag = 0; break; default: fputs("usage: tip [-dspn] [] ...\n", stderr ); exit(1 ); } } else { nrfiles++; /* file name provided */ if ((fp = fopen(*argv,"r" )) == NULL ) { fputs("tip: can't open ", stderr ); fputs(*argv, stderr ); putc('\n', stderr ); } else { tip(fp ); /* process new file */ fclose(fp ); } } } if (nrfiles == 0 ) { /* no file args -- process std input */ tip(stdin); } } tip(input ) /* writes to stdout - truncates and pads as necessary */ FILE *input; { char pix[TXTSIDE][TXTSIDE]; int len[TXTSIDE]; /* size of useful data in each line */ int i,j; /* row and column, what else? */ int c; /* as in Current Character */ int jinc; /* row increment */ /* initialize array of linesizes */ for (i=0; i ' ' && c <= '~' ) { pix[i][j] = c; if (len[i]=0 && len[i]<0; i-- ); /* print out the result */ for ( ; i>=0 && len[i]!=(-2); i-- ) { for (j=0; j<=len[i]; j++ ) putchar(pix[i][j] ); putchar('\n' ); } }