VirtualBox

Changeset 2306 in kBuild for trunk/src


Ignore:
Timestamp:
Mar 1, 2009 7:55:50 AM (16 years ago)
Author:
bird
Message:

kash: better CRLF hack for backtick.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/expand.c

    r2304 r2306  
    419419        int saveherefd;
    420420        int quotes = flag & (EXP_FULL | EXP_CASE);
     421#ifdef SH_DEAL_WITH_CRLF
     422        int pending_cr = 0;
     423#endif
    421424
    422425        INTOFF;
     
    448451                }
    449452                lastc = *p++;
     453#ifdef SH_DEAL_WITH_CRLF
     454                if (pending_cr) {
     455                        pending_cr = 0;
     456                        if (lastc != '\n') {
     457                                if (quotes && syntax[(int)'\r'] == CCTL)
     458                                        STPUTC(psh, CTLESC, dest);
     459                                STPUTC(psh, '\r', dest);
     460                        }
     461                }
     462                if (lastc == '\r')
     463                        pending_cr = '\r';
     464                else
     465#endif
    450466                if (lastc != '\0') {
    451467                        if (quotes && syntax[(int)lastc] == CCTL)
     
    454470                }
    455471        }
     472#ifdef SH_DEAL_WITH_CRLF
     473        if (pending_cr) {
     474                if (quotes && syntax[(int)'\r'] == CCTL)
     475                        STPUTC(psh, CTLESC, dest);
     476                STPUTC(psh, '\r', dest);
     477        }
     478#endif
    456479
    457480        /* Eat all trailing newlines */
    458481        p = stackblock(psh) + startloc;
    459         while (dest > p && dest[-1] == '\n') {
     482        while (dest > p && dest[-1] == '\n')
    460483                STUNPUTC(psh, dest);
    461 #ifdef SH_DEAL_WITH_CRLF
    462                 if (dest > p && dest[-1] == '\r')
    463                         STUNPUTC(psh, dest);
    464 #endif
    465         }
    466484
    467485        if (in.fd >= 0)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette