Check-in [51f17cd0ae]
Not logged in
Overview
Comment:Style/cosmetic changes to C files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | origin/devel
Files: files | file ages | folders
SHA1: 51f17cd0aea117ad5517a445a40c1570aceb546e
User & Date: quentin@minster.io on 2014-03-17 21:55:02
Other Links: branch diff | manifest | tags
Context
2014-03-17
22:10
Update meta files * Add self to AUTHORS * Cosmetic changes to README * Update TODOs Leaf check-in: 743c61fc2e user: quentin@minster.io tags: trunk, origin/devel
21:55
Style/cosmetic changes to C files check-in: 51f17cd0ae user: quentin@minster.io tags: trunk, origin/devel
21:54
Regenerate config.h.in using autoheader check-in: 32a8974959 user: quentin@minster.io tags: trunk, origin/devel
Changes

Modified tclreadline.c from [8e0b5f7ca4] to [ba99704a3e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 /* ==================================================================
    FILE: tclreadline.c
    $Id$
    ---
    tclreadline -- gnu readline for tcl
    http://www.zellner.org/tclreadline/
    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    This software is copyright under the BSD license.
    ================================================================== */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <tcl.h>
#include <stdio.h>
|
|
|
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 /* ================================================================== *
  * FILE: tclreadline.c
  * $Id$
  * ---
  * tclreadline -- gnu readline for tcl
  * http://www.zellner.org/tclreadline/
  * Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
  * This software is copyright under the BSD license.
  * ================================================================== */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <tcl.h>
#include <stdio.h>
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

67

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
static const char* tclrl_version_str = TCLRL_VERSION_STR;
static const char* tclrl_patchlevel_str = TCLRL_PATCHLEVEL_STR;

#define MALLOC(size) malloc(size)
#define FREE(ptr) free(ptr); ptr = NULL

enum {
    _CMD_SET     = (1 << 0),
    _CMD_GET     = (1 << 1)
};


typedef struct cmds_t {
    struct cmds_t* prev;
    char**         cmd;
    struct cmds_t* next;
} cmds_t;


#define ISWHITE(c) ((' ' == c) || ('\t' == c) || ('\n' == c))


/* forward declarations. */

static char* stripleft(char* in);
static char* stripright(char* in);
static char* stripwhite(char* in);
static int TclReadlineLineComplete(void);
static void TclReadlineTerminate(int state);
static char* TclReadlineQuote(char* text, char* quotechars);
static int TclReadlineCmd(ClientData clientData, Tcl_Interp *interp, int objc,
                   Tcl_Obj *CONST objv[]);
static void TclReadlineReadHandler(ClientData clientData, int mask);
static void TclReadlineLineCompleteHandler(char* ptr);
static int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile);
static int blank_line(char* str);
static char** TclReadlineCompletion(char* text, int start, int end);
static char* TclReadline0generator(char* text, int state);
static char* TclReadlineKnownCommands(char* text, int state, int mode);
static int TclReadlineParse(char** args, int maxargs, char* buf);


enum {
    LINE_PENDING = -1,
    LINE_EOF = (1 << 8),
    LINE_COMPLETE = (1 << 9)
};

/**
 * global variables
 */
static int tclrl_state = TCL_OK;
static char* tclrl_eof_string = (char*) NULL;
static char* tclrl_custom_completer = (char*) NULL;
static char* tclrl_last_line = (char*) NULL;
static int tclrl_use_builtin_completer = 1;
static int tclrl_history_length = -1;
Tcl_Interp* tclrl_interp = (Tcl_Interp*) NULL;

static char* tclrl_license =
"   Copyright (c) 1998 - 2000, Johannes Zellner <johannes@zellner.org>\n"
"   All rights reserved.\n"
"   \n"
"   Redistribution and use in source and binary forms, with or without\n"
"   modification, are permitted provided that the following conditions\n"







|
|












>
|
>
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|



|
|






|
|
|
|
|
|
|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
static const char* tclrl_version_str = TCLRL_VERSION_STR;
static const char* tclrl_patchlevel_str = TCLRL_PATCHLEVEL_STR;

#define MALLOC(size) malloc(size)
#define FREE(ptr) free(ptr); ptr = NULL

enum {
    _CMD_SET = (1 << 0),
    _CMD_GET = (1 << 1)
};


typedef struct cmds_t {
    struct cmds_t* prev;
    char**         cmd;
    struct cmds_t* next;
} cmds_t;


#define ISWHITE(c) ((' ' == c) || ('\t' == c) || ('\n' == c))

/**
 * forward declarations
 */
static char*  stripleft(char* in);
static char*  stripright(char* in);
static char*  stripwhite(char* in);
static int    TclReadlineLineComplete(void);
static void   TclReadlineTerminate(int state);
static char*  TclReadlineQuote(char* text, char* quotechars);
static int    TclReadlineCmd(ClientData clientData, Tcl_Interp *interp, int objc,
                             Tcl_Obj *CONST objv[]);
static void   TclReadlineReadHandler(ClientData clientData, int mask);
static void   TclReadlineLineCompleteHandler(char* ptr);
static int    TclReadlineInitialize(Tcl_Interp* interp, char* historyfile);
static int    blank_line(char* str);
static char** TclReadlineCompletion(char* text, int start, int end);
static char*  TclReadline0generator(char* text, int state);
static char*  TclReadlineKnownCommands(char* text, int state, int mode);
static int    TclReadlineParse(char** args, int maxargs, char* buf);


enum {
    LINE_PENDING  = -1,
    LINE_EOF      = (1 << 8),
    LINE_COMPLETE = (1 << 9)
};

/**
 * global variables
 */
static int   tclrl_state                 = TCL_OK;
static char* tclrl_eof_string            = (char*) NULL;
static char* tclrl_custom_completer      = (char*) NULL;
static char* tclrl_last_line             = (char*) NULL;
static int   tclrl_use_builtin_completer = 1;
static int   tclrl_history_length        = -1;
Tcl_Interp*  tclrl_interp                = (Tcl_Interp*) NULL;

static char* tclrl_license =
"   Copyright (c) 1998 - 2000, Johannes Zellner <johannes@zellner.org>\n"
"   All rights reserved.\n"
"   \n"
"   Redistribution and use in source and binary forms, with or without\n"
"   modification, are permitted provided that the following conditions\n"

Modified tclreadline.h.in from [d85f8fea8d] to [bcab9b4af6].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 /* ==================================================================
    FILE: tclreadline.h.in
    $Id$
    ---
    tclreadline -- gnu readline for tcl
    http://www.zellner.org/tclreadline/
    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    This software is copyright under the BSD license.
    ================================================================== */

#ifndef TCLREADLINE_H_
#define TCLREADLINE_H_

#include <tcl.h>

#define TCLRL_LIBRARY        "@TCLRL_DIR@"
|
|
|
|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 /* ================================================================== *
  * FILE: tclreadline.h.in
  * $Id$
  * ---
  * tclreadline -- gnu readline for tcl
  * http://www.zellner.org/tclreadline/
  * Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
  * This software is copyright under the BSD license.
  * ================================================================== */

#ifndef TCLREADLINE_H_
#define TCLREADLINE_H_

#include <tcl.h>

#define TCLRL_LIBRARY        "@TCLRL_DIR@"

Modified tclshrl.c from [c7e5e71138] to [bbacf8add5].

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

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 /* ==================================================================
    FILE: tclshrl.c
    $Id$
    ---
    tclreadline -- gnu readline for tcl
    http://www.zellner.org/tclreadline/
    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    This software is copyright under the BSD license.
    ================================================================== */

#ifdef HAVE_CONFIG_H
#   include "config.h"
#endif


#include <tcl.h>
#include <tclreadline.h>

#if 0
#include <assert.h>
#endif

extern int Tclreadline_Init(Tcl_Interp *interp);
extern int Tclreadline_SafeInit(Tcl_Interp *interp);

int
TclreadlineAppInit(Tcl_Interp* interp)
{
    char file[0xff];
    int status;
#if 0
    assert(Tcl_InitStubs(interp, TCL_VERSION, 0));
#endif
    if (TCL_ERROR == Tcl_Init(interp)) {
        return TCL_ERROR;
    }
    if (TCL_ERROR == Tclreadline_Init(interp)) {
        return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "tclreadline",
    Tclreadline_Init, Tclreadline_SafeInit);
#if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION == 4)
    tcl_RcFileName = "~/.tclshrc";
#else
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
#endif
    sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY);
    if ((status = Tcl_EvalFile(interp, file))) {
        fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
        exit (1);
    }
    return TCL_OK;
}

int
main(int argc, char *argv[])
{
    Tcl_Main(argc, argv, TclreadlineAppInit);
    return 0;
}
|
|
|
|
|
|
|
|
|


|


>



<
<
<
<








<
<
<







|








|








|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18




19
20
21
22
23
24
25
26



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 /* ================================================================== *
  * FILE: tclshrl.c
  * $Id$
  * ---
  * tclreadline -- gnu readline for tcl
  * http://www.zellner.org/tclreadline/
  * Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
  * This software is copyright under the BSD license.
  * ================================================================== */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <stdlib.h>
#include <tcl.h>
#include <tclreadline.h>





extern int Tclreadline_Init(Tcl_Interp *interp);
extern int Tclreadline_SafeInit(Tcl_Interp *interp);

int
TclreadlineAppInit(Tcl_Interp* interp)
{
    char file[0xff];
    int status;



    if (TCL_ERROR == Tcl_Init(interp)) {
        return TCL_ERROR;
    }
    if (TCL_ERROR == Tclreadline_Init(interp)) {
        return TCL_ERROR;
    }
    Tcl_StaticPackage(interp, "tclreadline",
                      Tclreadline_Init, Tclreadline_SafeInit);
#if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION == 4)
    tcl_RcFileName = "~/.tclshrc";
#else
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
#endif
    sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY);
    if ((status = Tcl_EvalFile(interp, file))) {
        fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
        exit (EXIT_FAILURE);
    }
    return TCL_OK;
}

int
main(int argc, char *argv[])
{
    Tcl_Main(argc, argv, TclreadlineAppInit);
    return EXIT_SUCCESS;
}

Modified wishrl.c from [d3a28cc973] to [9a235afaa7].

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

15
16
17
18
19
20
21
 /* ==================================================================
    FILE: wishrl.c
    $Id$
    ---
    tclreadline -- gnu readline for tcl
    http://www.zellner.org/tclreadline/
    Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
    This software is copyright under the BSD license.
    ================================================================== */

#ifdef HAVE_CONFIG_H
#   include "config.h"
#endif


#include <tcl.h>
#include <tk.h>
#include <tclreadline.h>

extern int Tclreadline_Init(Tcl_Interp *interp);
extern int Tclreadline_SafeInit(Tcl_Interp *interp);

|
|
|
|
|
|
|
|
|


|


>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 /* ================================================================== *
  * FILE: wishrl.c
  * $Id$
  * ---
  * tclreadline -- gnu readline for tcl
  * http://www.zellner.org/tclreadline/
  * Copyright (c) 1998 - 2014, Johannes Zellner <johannes@zellner.org>
  * This software is copyright under the BSD license.
  * ================================================================== */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <stdlib.h>
#include <tcl.h>
#include <tk.h>
#include <tclreadline.h>

extern int Tclreadline_Init(Tcl_Interp *interp);
extern int Tclreadline_SafeInit(Tcl_Interp *interp);

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    tcl_RcFileName = "~/.wishrc";
#else
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
#endif
    sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY);
    if ((status = Tcl_EvalFile(interp, file))) {
        fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
        exit (1);
    }
    return TCL_OK;
}

int
main(int argc, char *argv[])
{
    Tk_Main(argc, argv, TclreadlineAppInit);
    return 0;
}







|








|

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    tcl_RcFileName = "~/.wishrc";
#else
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
#endif
    sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY);
    if ((status = Tcl_EvalFile(interp, file))) {
        fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file);
        exit (EXIT_FAILURE);
    }
    return TCL_OK;
}

int
main(int argc, char *argv[])
{
    Tk_Main(argc, argv, TclreadlineAppInit);
    return EXIT_SUCCESS;
}