Difference for plugins/cfpython/cfpython.c from version 1.17 to 1.18


version 1.17 version 1.18
Line 52
 
Line 52
 /*  You should have received a copy of the GNU General Public License        */  /*  You should have received a copy of the GNU General Public License        */
 /*  along with this program; if not, write to the Free Software              */  /*  along with this program; if not, write to the Free Software              */
 /*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */  /*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
 /*                                                                           */ /*****************************************************************************/  /*                                                                           */
   /*****************************************************************************/
   
 /* First let's include the header file needed                                */  /* First let's include the header file needed                                */
   
Line 658
 
Line 659
         return NULL;          return NULL;
 }  }
   
   void freeContext(CFPContext* context)
   {
       Py_XDECREF(context->who);
       Py_XDECREF(context->activator);
       Py_XDECREF(context->third);
       free(context);
   }
   
 static int do_script(CFPContext* context)  static int do_script(CFPContext* context)
 {  {
     FILE*   scriptfile;      FILE*   scriptfile;
       PyObject* built;
     PyObject* dict;      PyObject* dict;
   #if 0
       PyObject* list;
       PyObject* ret;
       int item;
   #endif
   
     scriptfile = fopen(context->script,"r");      scriptfile = fopen(context->script,"r");
     if (scriptfile == NULL)      if (scriptfile == NULL)
Line 671
 
Line 686
     }      }
     pushContext(context);      pushContext(context);
     dict = PyDict_New();      dict = PyDict_New();
     PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins());      built = PyEval_GetBuiltins();
     PyRun_File(scriptfile, context->script, Py_file_input, dict, dict);      PyDict_SetItemString(dict, "__builtins__", built);
       Py_XDECREF(built);
       ret = PyRun_File(scriptfile, context->script, Py_file_input, dict, dict);
     if (PyErr_Occurred())      if (PyErr_Occurred())
     {      {
         PyErr_Print();          PyErr_Print();
     }      }
       Py_XDECREF(ret);
   #if 0
       printf( "cfpython - %d items in heap\n", PyDict_Size(dict));
       list = PyDict_Values(dict);
       for (item = PyList_Size(list) - 1; item >= 0; item--)
       {
           dict = PyList_GET_ITEM(list,item);
           ret = PyObject_Str(dict);
           printf(" ref %s = %d\n",PyString_AsString(ret),dict->ob_refcnt);
           Py_XDECREF(ret);
       }
       Py_DECREF(list);
   #endif
     Py_DECREF(dict);      Py_DECREF(dict);
     fclose(scriptfile);      fclose(scriptfile);
     return 1;      return 1;
Line 797
 
Line 827
     snprintf(context->options, sizeof(context->options), "%s", params);      snprintf(context->options, sizeof(context->options), "%s", params);
     context->returnvalue = 1; /* Default is "command successful" */      context->returnvalue = 1; /* Default is "command successful" */
   
     Py_XINCREF(context->who);  
   
     if (!do_script(context))      if (!do_script(context))
     {      {
         free(context);          freeContext(context);
         return rv;          return rv;
     }      }
   
     context = popContext();      context = popContext();
     rv = context->returnvalue;      rv = context->returnvalue;
     Py_XDECREF(context->who);      freeContext(context);
     Py_XDECREF(context->activator);  
     Py_XDECREF(context->third);  
     free(context);  
     printf("Execution complete");      printf("Execution complete");
     return rv;      return rv;
 }  }
Line 982
 
Line 1007
   
     if (!do_script(context))      if (!do_script(context))
     {      {
         free(context);          freeContext(context);
         return &rv;          return &rv;
     }      }
   
     context = popContext();      context = popContext();
     rv = context->returnvalue;      rv = context->returnvalue;
     Py_XDECREF(context->who);      freeContext(context);
     Py_XDECREF(context->activator);  
     Py_XDECREF(context->third);  
     free(context);  
   
     return &rv;      return &rv;
 }  }
Line 1027
 
Line 1049
   
     if (!do_script(context))      if (!do_script(context))
     {      {
         free(context);          freeContext(context);
         return &rv;          return &rv;
     }      }
   
     context = popContext();      context = popContext();
     rv = context->returnvalue;      rv = context->returnvalue;
     Py_XDECREF(context->who);      freeContext(context);
     Py_XDECREF(context->activator);  
     Py_XDECREF(context->third);  
     free(context);  
     return &rv;      return &rv;
 }  }
   


Legend:
line(s) removed in v.1.17 
line(s) changed
 line(s) added in v.1.18

File made using version 1.98 of cvs2html by leaf at 2011-07-21 16:59