Annotation of researchv10no/cmd/gre/regress.d/lt0.c, revision 1.1

1.1     ! root        1: /*
        !             2: From pegasus.ATT.COM!hansen Tue Oct  9 00:34 EDT 1990
        !             3: Received: by pyxis; Tue Oct  9 00:34 EDT 1990
        !             4: FROM:       [email protected] (t.l.hansen)
        !             5: TO:         research!andrew
        !             6: DATE:        9 Oct 1990   0:27 EDT
        !             7: SUBJECT:    bug in re_reexec()!
        !             8: 
        !             9: Compile and link the following program. The expected output is:
        !            10: 
        !            11: parens = 2
        !            12: matched
        !            13: 0: 0x80881430 - 0x80881445
        !            14: "!nosuchsystem!testing"
        !            15: 1: 0x80886334 - 0xc0020c1c
        !            16: "nosuchsystem"
        !            17: 2: 0xc0020a78 - 0x80883924
        !            18: "testing"
        !            19: 
        !            20: Instead, I get this. (Note the strings after 1: and 2:.)
        !            21: 
        !            22: parens = 2
        !            23: matched
        !            24: 0: 0x80881430 - 0x80881445
        !            25: "!nosuchsystem!testing"
        !            26: 1: 0x80886334 - 0xc0020c1c
        !            27: ""
        !            28: 2: 0xc0020a78 - 0x80883924
        !            29: ""
        !            30: 
        !            31: Can you please look into this soon? If not, let me know so that I can hunt
        !            32: for it. I probably won't be able to find it as quickly as you, though. This
        !            33: showed up within mail and I have an MR haunting me. Thanks.
        !            34: 
        !            35:                                        Tony
        !            36: 
        !            37: ----------------------------------------------------------------
        !            38: */
        !            39: #include <stdio.h>
        !            40: #include <ctype.h>
        !            41: #include "re.h"
        !            42: #include "lre.h"
        !            43: 
        !            44: void prc(c)
        !            45: unsigned char c;
        !            46: {
        !            47:     if (c >= 0200)
        !            48:        {
        !            49:        (void) printf("M-");
        !            50:        c -= 0200;
        !            51:        }
        !            52:     if (isprint(c)) putchar(c);
        !            53:     else
        !            54:        {
        !            55:        putchar('^');
        !            56:        putchar(c ^ 0100);
        !            57:        }
        !            58: }
        !            59: 
        !            60: void pr(i, mb, me)
        !            61: int i;
        !            62: char *mb;
        !            63: char *me;
        !            64: {
        !            65:     (void) printf("%d: %#x - %#x\n", i, mb, me);
        !            66:     putchar('"');
        !            67:     for (; mb < me; mb++)
        !            68:        {
        !            69:        if (!*mb)
        !            70:            break;
        !            71:        prc(*mb);
        !            72:        }
        !            73:     putchar('"');
        !            74:     putchar('\n');
        !            75: }
        !            76: 
        !            77: main()
        !            78: {
        !            79:     re_re *regex;
        !            80:     int i;
        !            81:     unsigned char re_map[256];
        !            82:     static char lname[] = "!nosuchsystem!testing";
        !            83:     static char pat[] = "!([^!]+)!(.+)";
        !            84:     char *match[10][2];
        !            85:     int parens;
        !            86: 
        !            87:     for (i = 0; i < 256; i++)
        !            88:        re_map[i] = i;
        !            89:     regex = re_recomp(pat, pat+strlen(pat), re_map);
        !            90:     parens = re_paren(regex);
        !            91:     (void) printf("parens = %d\n", parens);
        !            92:     if (parens != 2)
        !            93:        return 0;
        !            94:     if (!re_reexec(regex, lname, lname+strlen(lname), match))
        !            95:        {
        !            96:        (void) printf("no match\n");
        !            97:        return 0;
        !            98:        }
        !            99: 
        !           100:     (void) printf("matched\n");
        !           101:     for (i = 0; i <= parens; i++)
        !           102:        pr(i, match[i][0], match[i][1]);
        !           103:     return 0;
        !           104: }

unix.superglobalmegacorp.com

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