Ignore:
Timestamp:
Apr 8, 2007, 10:41:34 AM (18 years ago)
Author:
bird
Message:

Ported FreeBSD /usr/bin/rev to OS/2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bsdmisc/rev/rev.c

    r3033 r3034  
    6464{
    6565        const char *filename;
     66#ifdef __OS2__ /* Currently missing putwchar and fgetwln, too bad the the DBCS guys... */
     67        static char line[48*1024];
     68        char *p, *t;
     69#else
    6670        wchar_t *p, *t;
     71#endif
    6772        FILE *fp;
    6873        size_t len;
     
    9499                        filename = *argv++;
    95100                }
     101#ifdef __OS2__
     102                while ((p = fgets(line, sizeof(line), fp)) != NULL) {
     103                        len = strlen(line);
     104                        if (p[len - 1] == '\n')
     105                                --len;
     106                        t = p + len - 1;
     107                        for (t = p + len - 1; t >= p; --t)
     108                                putchar(*t);
     109                        putchar('\n');
     110                }
     111#else
    96112                while ((p = fgetwln(fp, &len)) != NULL) {
    97113                        if (p[len - 1] == '\n')
     
    102118                        putwchar('\n');
    103119                }
     120#endif
    104121                if (ferror(fp)) {
    105122                        warn("%s", filename);
Note: See TracChangeset for help on using the changeset viewer.