Annotation of researchv10no/cmd/upas/libc/regsub.c, revision 1.1.1.1

1.1       root        1: #include "regprog.h"
                      2: #define NULL 0
                      3: 
                      4: /* substitute into one string using the matches from the last regexec() */
                      5: extern void
                      6: regsub (sp, dp, mp, ms)
                      7:        char *sp;       /* source string */
                      8:        char *dp;       /* destination string */
                      9:        regsubexp *mp;  /* subexpression elements */
                     10:        int ms;         /* number of elements pointed to by mp */
                     11: {
                     12:        char *ssp;
                     13:        register int i;
                     14: 
                     15:        while (*sp != '\0') {
                     16:                if (*sp == '\\') {
                     17:                        switch (*++sp) {
                     18:                        case '0':
                     19:                        case '1':
                     20:                        case '2':
                     21:                        case '3':
                     22:                        case '4':
                     23:                        case '5':
                     24:                        case '6':
                     25:                        case '7':
                     26:                        case '8':
                     27:                        case '9':
                     28:                                i = *sp-'0';
                     29:                                if (mp[i].sp != NULL && mp!=NULL && ms>i)
                     30:                                        for (ssp = mp[i].sp;
                     31:                                             ssp < mp[i].ep;
                     32:                                             ssp++)
                     33:                                                *dp++ = *ssp;
                     34:                                break;
                     35:                        case '\\':
                     36:                                *dp++ = '\\';
                     37:                                break;
                     38:                        case '\0':
                     39:                                sp--;
                     40:                                break;
                     41:                        default:
                     42:                                *dp++ = *sp;
                     43:                                break;
                     44:                        }
                     45:                } else if (*sp == '&') {                                
                     46:                        if (mp[0].sp != NULL && mp!=NULL && ms>0)
                     47:                        if (mp[0].sp != NULL)
                     48:                                for (ssp = mp[0].sp;
                     49:                                     ssp < mp[0].ep; ssp++)
                     50:                                        *dp++ = *ssp;
                     51:                } else
                     52:                        *dp++ = *sp;
                     53:                sp++;
                     54:        }
                     55:        *dp = '\0';
                     56: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.