Remove trailing whitespace.
[deliverable/binutils-gdb.git] / gdb / python / py-cmd.c
index 26823c7ffff34da99f57486366c910a20b732546..c0e9d9696b8c33609ddddcf7d96ece4643d92cf0 100644 (file)
@@ -45,6 +45,7 @@ static struct cmdpy_completer completers[] =
   { "COMPLETE_LOCATION", location_completer },
   { "COMPLETE_COMMAND", command_completer },
   { "COMPLETE_SYMBOL", make_symbol_completion_list_fn },
+  { "COMPLETE_EXPRESSION", expression_completer },
 };
 
 #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0]))
@@ -244,7 +245,6 @@ cmdpy_completer (struct cmd_list_element *command,
       PyErr_Clear ();
       goto done;
     }
-  make_cleanup_py_decref (resultobj);
 
   result = NULL;
   if (PyInt_Check (resultobj))
@@ -300,6 +300,7 @@ cmdpy_completer (struct cmd_list_element *command,
 
  done:
 
+  Py_XDECREF (resultobj);
   do_cleanups (cleanup);
 
   return result;
@@ -307,14 +308,14 @@ cmdpy_completer (struct cmd_list_element *command,
 
 /* Helper for cmdpy_init which locates the command list to use and
    pulls out the command name.
-   
+
    NAME is the command name list.  The final word in the list is the
    name of the new command.  All earlier words must be existing prefix
    commands.
 
    *BASE_LIST is set to the final prefix command's list of
    *sub-commands.
-   
+
    START_LIST is the list in which the search starts.
 
    This function returns the xmalloc()d name of the new command.  On
@@ -463,16 +464,16 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
     return -1;
 
   pfx_name = NULL;
-  if (is_prefix != NULL) 
+  if (is_prefix != NULL)
     {
       cmp = PyObject_IsTrue (is_prefix);
       if (cmp == 1)
        {
          int i, out;
-         
+       
          /* Make a normalized form of the command name.  */
          pfx_name = xmalloc (strlen (name) + 2);
-         
+       
          i = 0;
          out = 0;
          while (name[i])
@@ -564,14 +565,14 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
 
 /* Initialize the 'commands' code.  */
 
-void
+int
 gdbpy_initialize_commands (void)
 {
   int i;
 
   cmdpy_object_type.tp_new = PyType_GenericNew;
   if (PyType_Ready (&cmdpy_object_type) < 0)
-    return;
+    return -1;
 
   /* Note: alias and user are special; pseudo appears to be unused,
      and there is no reason to expose tui or xdb, I think.  */
@@ -592,20 +593,26 @@ gdbpy_initialize_commands (void)
       || PyModule_AddIntConstant (gdb_module, "COMMAND_MAINTENANCE",
                                  class_maintenance) < 0
       || PyModule_AddIntConstant (gdb_module, "COMMAND_USER", class_user) < 0)
-    return;
+    return -1;
 
   for (i = 0; i < N_COMPLETERS; ++i)
     {
       if (PyModule_AddIntConstant (gdb_module, completers[i].name, i) < 0)
-       return;
+       return -1;
     }
 
-  Py_INCREF (&cmdpy_object_type);
-  PyModule_AddObject (gdb_module, "Command",
-                     (PyObject *) &cmdpy_object_type);
+  if (gdb_pymodule_addobject (gdb_module, "Command",
+                             (PyObject *) &cmdpy_object_type) < 0)
+    return -1;
 
   invoke_cst = PyString_FromString ("invoke");
+  if (invoke_cst == NULL)
+    return -1;
   complete_cst = PyString_FromString ("complete");
+  if (complete_cst == NULL)
+    return -1;
+
+  return 0;
 }
 
 \f
This page took 0.025346 seconds and 4 git commands to generate.