~ubuntu-branches/ubuntu/lucid/mc/lucid

« back to all changes in this revision

Viewing changes to src/command.c

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-09-16 10:38:59 UTC
  • mfrom: (3.1.6 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080916103859-2uwn8w61xk5mbxxq
Tags: 2:4.6.2~git20080311-4
Corrected fix for odt2txt issue (Closes: #492019) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Command line widget.
2
 
   Copyright (C) 1995 Miguel de Icaza
 
2
   Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 
3
   2007 Free Software Foundation, Inc.
3
4
 
4
5
   This program is free software; you can redistribute it and/or modify
5
6
   it under the terms of the GNU General Public License as published by
22
23
*/
23
24
 
24
25
#include <config.h>
 
26
 
25
27
#include <errno.h>
26
28
#include <string.h>
 
29
 
27
30
#include "global.h"             /* home_dir */
28
31
#include "tty.h"
29
32
#include "widget.h"             /* WInput */
209
212
        return MSG_HANDLED;
210
213
    } else {
211
214
        char *command, *s;
212
 
        size_t i, j;
 
215
        size_t i, j, cmd_len;
213
216
 
214
217
        if (!vfs_current_is_local ()) {
215
218
            message (1, MSG_ERROR,
227
230
            return MSG_NOT_HANDLED;
228
231
        }
229
232
#endif
230
 
 
231
 
        command = g_malloc (strlen (cmd) + 1);
 
233
        cmd_len = strlen (cmd);
 
234
        command = g_malloc (cmd_len + 1);
232
235
        command[0] = 0;
233
 
        for (i = j = 0; i < strlen (cmd); i++) {
 
236
        for (i = j = 0; i < cmd_len; i++) {
234
237
            if (cmd[i] == '%') {
235
238
                i++;
236
239
                s = expand_format (NULL, cmd[i], 1);
237
 
                command = g_realloc (command, strlen (command) + strlen (s)
238
 
                                     + strlen (cmd) - i + 1);
239
 
                strcat (command, s);
 
240
                command = g_realloc (command, j + strlen (s) + cmd_len - i + 1);
 
241
                strcpy (command + j, s);
240
242
                g_free (s);
241
243
                j = strlen (command);
242
244
            } else {
262
264
}
263
265
 
264
266
static cb_ret_t
265
 
command_callback (WInput *cmd, widget_msg_t msg, int parm)
 
267
command_callback (Widget *w, widget_msg_t msg, int parm)
266
268
{
 
269
    WInput *cmd = (WInput *) w;
 
270
 
267
271
    switch (msg) {
268
272
    case WIDGET_FOCUS:
269
273
        /* Never accept focus, otherwise panels will be unselected */
277
281
        /* fall through */
278
282
 
279
283
    default:
280
 
        return input_callback (cmd, msg, parm);
 
284
        return input_callback (w, msg, parm);
281
285
    }
282
286
}
283
287
 
289
293
    cmd = input_new (y, x, DEFAULT_COLOR, cols, "", "cmdline");
290
294
 
291
295
    /* Add our hooks */
292
 
    cmd->widget.callback = (callback_fn) command_callback;
 
296
    cmd->widget.callback = command_callback;
293
297
    cmd->completion_flags |= INPUT_COMPLETE_COMMANDS;
294
298
 
295
299
    return cmd;