/[pspp]/pspp/src/command.c
ViewVC logotype

Diff of /pspp/src/command.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by blp, Mon Nov 15 09:51:22 2004 UTC revision 1.19 by jmd, Sat Feb 5 12:42:57 2005 UTC
# Line 79  static const struct command commands[] = Line 79  static const struct command commands[] =
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. */

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26