Diff
Not logged in

Differences From Artifact [9a72d128cc]:

To Artifact [3dffb52a3c]:


1
2
3
4
5
6
7
8
9
10
11
12

 /* ==================================================================

    FILE: "/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Sun Aug 29 15:04:07 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

    tclreadline -- gnu readline for tcl
    Copyright (C) 1999  Johannes Zellner





|







1
2
3
4
5
6
7
8
9
10
11
12

 /* ==================================================================

    FILE: "/home/joze/src/tclreadline/tclreadline.c"
    LAST MODIFICATION: "Tue Aug 31 03:22:55 1999 (joze)"
    (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
    $Id$
    ---

    tclreadline -- gnu readline for tcl
    Copyright (C) 1999  Johannes Zellner

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
        /**
         * TODO: status == 2 ...
         */
        
        if (expansion && *expansion)
            add_history(expansion);

        Tcl_AppendResult(interp, expansion, (char*) NULL);

        FREE(tclrl_line);
        FREE(expansion);
        return tclrl_state;
    } else if (c == 'i'  && strncmp(argv[1], "initialize", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;







|







220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
        /**
         * TODO: status == 2 ...
         */
        
        if (expansion && *expansion)
            add_history(expansion);

        Tcl_SetResult(interp, expansion, TCL_VOLATILE);

        FREE(tclrl_line);
        FREE(expansion);
        return tclrl_state;
    } else if (c == 'i'  && strncmp(argv[1], "initialize", length) == 0) {
        if (3 != argc)
            goto BAD_COMMAND;
463
464
465
466
467
468
469

470
471
472
473
474
475
476
    return 1;
}

char**
TclReadlineCompletion(char* text, int start, int end)
{
    char** matches = (char**) NULL;


#if 0
    fprintf(stderr, "DEBUG> TclReadlineCompletion: text=|%s|\n", text);
    fprintf(stderr, "DEBUG> TclReadlineCompletion: start=|%d|\n", start);
    fprintf(stderr, "DEBUG> TclReadlineCompletion: end=|%d|\n", end);
#endif








>







463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
    return 1;
}

char**
TclReadlineCompletion(char* text, int start, int end)
{
    char** matches = (char**) NULL;
    rl_attempted_completion_over = 0;

#if 0
    fprintf(stderr, "DEBUG> TclReadlineCompletion: text=|%s|\n", text);
    fprintf(stderr, "DEBUG> TclReadlineCompletion: start=|%d|\n", start);
    fprintf(stderr, "DEBUG> TclReadlineCompletion: end=|%d|\n", end);
#endif

547
548
549
550
551
552
553
554
555
556
557






558
559
560
561
562
563
564
565
566
567
#endif
            return matches;
        }
        obj = Tcl_GetObjResult(tclrl_interp);
        Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv);
        /* fprintf (stderr, "(TclReadlineCompletion) objc = %d\n", objc); */
        if (objc) {
            int i, length /* not used */;
            matches = (char**) MALLOC(sizeof(char*) * (objc + 1));
            for (i = 0; i < objc; i++) {
                matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length));






                /*
                fprintf (stderr, "(TclReadlineCompletion) matches[%d] = |%s|\n",
                    i, matches[i]);
                */
            }
            matches[i] = (char*) NULL; /* terminate */
        }
        Tcl_ResetResult(tclrl_interp); /* clear result space */
    }








|



>
>
>
>
>
>

|
|







548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
#endif
            return matches;
        }
        obj = Tcl_GetObjResult(tclrl_interp);
        Tcl_ListObjGetElements(tclrl_interp, obj, &objc, &objv);
        /* fprintf (stderr, "(TclReadlineCompletion) objc = %d\n", objc); */
        if (objc) {
            int i, length;
            matches = (char**) MALLOC(sizeof(char*) * (objc + 1));
            for (i = 0; i < objc; i++) {
                matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length));
                if (1 == objc && !strlen(matches[i])) {
                    rl_attempted_completion_over = 1;
                    FREE(matches[i]);
                    FREE(matches);
                    return (char**) NULL;
                }
                /*
                fprintf (stderr, "(TclReadlineCompletion) len[%s]=%d\n",
                    matches[i], strlen(matches[i]));
                */
            }
            matches[i] = (char*) NULL; /* terminate */
        }
        Tcl_ResetResult(tclrl_interp); /* clear result space */
    }