You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2013/07/06 13:58:35 UTC

svn commit: r1500245 - in /tcl/rivet/trunk: ChangeLog src/parser/parserPkgInit.c src/parser/rivetParser.c

Author: mxmanghi
Date: Sat Jul  6 11:58:35 2013
New Revision: 1500245

URL: http://svn.apache.org/r1500245
Log:
    * src/parser/parserPkgInit.c: commands are created through the RIVET_OBJ_CMD macro


Modified:
    tcl/rivet/trunk/ChangeLog
    tcl/rivet/trunk/src/parser/parserPkgInit.c
    tcl/rivet/trunk/src/parser/rivetParser.c

Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1500245&r1=1500244&r2=1500245&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Sat Jul  6 11:58:35 2013
@@ -1,3 +1,6 @@
+2013-07-06 Massimo Manghi <mx...@apache.org>
+    * src/parser/parserPkgInit.c: commands are created through the RIVET_OBJ_CMD macro
+
 2013-07-05 Massimo Manghi <mx...@apache.org>
     * configure.ac: changed the default path for installation dir 
     * doc/xml/commands.xml: add manual page for command ::rivet::xml

Modified: tcl/rivet/trunk/src/parser/parserPkgInit.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/parser/parserPkgInit.c?rev=1500245&r1=1500244&r2=1500245&view=diff
==============================================================================
--- tcl/rivet/trunk/src/parser/parserPkgInit.c (original)
+++ tcl/rivet/trunk/src/parser/parserPkgInit.c Sat Jul  6 11:58:35 2013
@@ -10,7 +10,7 @@
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
 
-   	http://www.apache.org/licenses/LICENSE-2.0
+        http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,6 +27,7 @@
 #endif
 
 #include <tcl.h>
+#include "rivet.h"
 #include "rivetParser.h"
 
 /*
@@ -54,13 +55,13 @@ Parse_Rivet(
 
     if (objc != 2)
     {
-	Tcl_WrongNumArgs(interp, 1, objv, "filename");
-	return TCL_ERROR;
+        Tcl_WrongNumArgs(interp, 1, objv, "filename");
+        return TCL_ERROR;
     }
 
     if (Rivet_GetRivetFile(Tcl_GetString(objv[1]),
-			   1, outbuf, interp) == TCL_ERROR) {
-	return TCL_ERROR;
+                           1, outbuf, interp) == TCL_ERROR) {
+        return TCL_ERROR;
     }
     Tcl_SetObjResult(interp, outbuf);
     Tcl_DecrRefCount(outbuf);
@@ -72,21 +73,21 @@ Parse_Rivet(
  *
  * Parse_RivetData --
  *
- * 	Takes a Rivet script as an argument, and returns the parsed
- * 	tcl script version.
+ *      Takes a Rivet script as an argument, and returns the parsed
+ *      tcl script version.
  *
  * Results:
- *	A normal Tcl result.
+ *      A normal Tcl result.
  *
  * Side Effects:
- *	None.
+ *      None.
  *
  *-----------------------------------------------------------------------------
  */
 
 static int
 Parse_RivetData(ClientData clientData, Tcl_Interp *interp,
-		int objc, Tcl_Obj *CONST objv[])
+                int objc, Tcl_Obj *CONST objv[])
 {
     Tcl_Obj *outbuf;
 
@@ -94,8 +95,8 @@ Parse_RivetData(ClientData clientData, T
 
     if (objc != 2)
     {
-	Tcl_WrongNumArgs(interp, 1, objv, "data");
-	return TCL_ERROR;
+        Tcl_WrongNumArgs(interp, 1, objv, "data");
+        return TCL_ERROR;
     }
     Tcl_IncrRefCount(outbuf);
 
@@ -103,7 +104,7 @@ Parse_RivetData(ClientData clientData, T
 
     if (Rivet_Parser(outbuf, objv[1]) == 0)
     {
-	Tcl_AppendToObj(outbuf, "\"\n", 2);
+        Tcl_AppendToObj(outbuf, "\"\n", 2);
     }
 
     Tcl_SetObjResult(interp, outbuf);
@@ -117,25 +118,16 @@ EXTERN int
 Rivetparser_Init( Tcl_Interp *interp )
 {
 #ifdef USE_TCL_STUBS
-    if (Tcl_InitStubs(interp, "8.5", 0) == NULL) { 
+    if (Tcl_InitStubs(interp, "8.5", 0) == NULL)
 #else
-	if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL) { 
-#endif    
-	    return TCL_ERROR;
+    if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL)
+#endif
+    {   
+        return TCL_ERROR;
     }
 
-    Tcl_CreateObjCommand(interp,
-			 "rivet::parserivet",
-			 Parse_Rivet,
-			 NULL,
-			 (Tcl_CmdDeleteProc *)NULL);
-
-    Tcl_CreateObjCommand(interp,
-			 "rivet::parserivetdata",
-			 Parse_RivetData,
-			 NULL,
-			 (Tcl_CmdDeleteProc *)NULL);
-
+    RIVET_OBJ_CMD("parserivet",Parse_Rivet);
+    RIVET_OBJ_CMD("parserivetdata",Parse_RivetData);
     return Tcl_PkgProvide( interp, "rivetparser", "0.2" );
 }
 
@@ -156,16 +148,16 @@ Rivetparser_SafeInit( Tcl_Interp *interp
 #ifdef USE_TCL_STUBS
     if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) { 
 #else
-	if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) { 
+    if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) { 
 #endif    
-	    return TCL_ERROR;
+        return TCL_ERROR;
     }
 
     Tcl_CreateObjCommand(interp,
-			 "rivet::parserivetdata",
-			 Parse_RivetData,
-			 NULL,
-			 (Tcl_CmdDeleteProc *)NULL);
+                         "rivet::parserivetdata",
+                         Parse_RivetData,
+                         NULL,
+                         (Tcl_CmdDeleteProc *)NULL);
 
     return Tcl_PkgProvide( interp, "rivetparser", "0.2" );
 }

Modified: tcl/rivet/trunk/src/parser/rivetParser.c
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/src/parser/rivetParser.c?rev=1500245&r1=1500244&r2=1500245&view=diff
==============================================================================
--- tcl/rivet/trunk/src/parser/rivetParser.c (original)
+++ tcl/rivet/trunk/src/parser/rivetParser.c Sat Jul  6 11:58:35 2013
@@ -12,7 +12,7 @@
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
 
-   	http://www.apache.org/licenses/LICENSE-2.0
+        http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -57,22 +57,22 @@ Rivet_GetTclFile(char *filename, Tcl_Obj
     Tcl_Channel chan = Tcl_OpenFileChannel(interp, filename, "r", 0644);
     if (chan == (Tcl_Channel) NULL)
     {
-	Tcl_ResetResult(interp);
-	Tcl_AppendResult(interp, "couldn't read file \"", filename,
-			 "\": ", Tcl_PosixError(interp), (char *) NULL);
-	return TCL_ERROR;
+        Tcl_ResetResult(interp);
+        Tcl_AppendResult(interp, "couldn't read file \"", filename,
+                         "\": ", Tcl_PosixError(interp), (char *) NULL);
+        return TCL_ERROR;
     }
     result = Tcl_ReadChars(chan, outbuf, -1, 1);
     if (result < 0)
     {
-	Tcl_Close(interp, chan);
-	Tcl_AppendResult(interp, "couldn't read file \"", filename,
-			 "\": ", Tcl_PosixError(interp), (char *) NULL);
-	return TCL_ERROR;
+        Tcl_Close(interp, chan);
+        Tcl_AppendResult(interp, "couldn't read file \"", filename,
+                         "\": ", Tcl_PosixError(interp), (char *) NULL);
+        return TCL_ERROR;
     }
 
     if (Tcl_Close(interp, chan) != TCL_OK)
-	return TCL_ERROR;
+        return TCL_ERROR;
 
     return TCL_OK;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org