79 |
#undef DEFCMD |
#undef DEFCMD |
80 |
#undef UNIMPL |
#undef UNIMPL |
81 |
|
|
82 |
|
|
83 |
|
/* Complete the line using the name of a command, |
84 |
|
* based upon the current prg_state |
85 |
|
*/ |
86 |
|
char * |
87 |
|
pspp_completion_function (const char *text, int state) |
88 |
|
{ |
89 |
|
static int skip=0; |
90 |
|
const struct command *cmd = 0; |
91 |
|
|
92 |
|
for(;;) |
93 |
|
{ |
94 |
|
if ( state + skip >= sizeof(commands)/ sizeof(struct command)) |
95 |
|
{ |
96 |
|
skip = 0; |
97 |
|
return 0; |
98 |
|
} |
99 |
|
|
100 |
|
cmd = &commands[state + skip]; |
101 |
|
|
102 |
|
if ( cmd->transition[pgm_state] == STATE_ERROR ) |
103 |
|
{ |
104 |
|
skip++; |
105 |
|
continue; |
106 |
|
} |
107 |
|
|
108 |
|
if ( text == 0 || 0 == strncasecmp (cmd->name, text, strlen(text))) |
109 |
|
{ |
110 |
|
break; |
111 |
|
} |
112 |
|
|
113 |
|
skip++; |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
return xstrdup(cmd->name); |
118 |
|
|
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
#define COMMAND_CNT (sizeof commands / sizeof *commands) |
#define COMMAND_CNT (sizeof commands / sizeof *commands) |
124 |
|
|
125 |
/* Command parser. */ |
/* Command parser. */ |