Author: kjs
Date: Thu Apr 12 03:37:59 2007
New Revision: 18161

Modified:
   trunk/compilers/pirc/src/pastout.c
   trunk/compilers/pirc/src/pirmain.c

Log:
compilers/pirc:
* fixed pirmain: when calling 'pirc -o' , it fails. This is now fixed.
* add a line of comments.

Modified: trunk/compilers/pirc/src/pastout.c
==============================================================================
--- trunk/compilers/pirc/src/pastout.c  (original)
+++ trunk/compilers/pirc/src/pastout.c  Thu Apr 12 03:37:59 2007
@@ -280,6 +280,7 @@
     vtable->expression   = past_expr;
     vtable->op_end       = past_close;
 
+    /* allocate the emit_data structure and initialize it */
     vtable->data = (emit_data *)malloc(sizeof(emit_data));
     if (vtable->data == NULL) {
         fprintf(stderr, "Failed to allocate memory for vtable data\n");

Modified: trunk/compilers/pirc/src/pirmain.c
==============================================================================
--- trunk/compilers/pirc/src/pirmain.c  (original)
+++ trunk/compilers/pirc/src/pirmain.c  Thu Apr 12 03:37:59 2007
@@ -9,13 +9,13 @@
 */
 #include <stdio.h>
 #include <stdlib.h>
-#include "pirparser.h"
-#include "pirout.h"    /* for PIR output  */
-#include "pastout.h"   /* for PAST output */
-#include "pirvtable.h" /* vtable api      */
-#include "jsonout.h"   /* for json output */
-#include "pbcout.h"    /* for PBC output  */
-#include "pirutil.h"
+#include "pirparser.h" /* the parser        */
+#include "pirout.h"    /* for PIR output    */
+#include "pastout.h"   /* for PAST output   */
+#include "pirvtable.h" /* vtable api        */
+#include "jsonout.h"   /* for json output   */
+#include "pbcout.h"    /* for PBC output    */
+#include "pirutil.h"   /* utility functions */
 
 
 /* define output type: what kind of semantic routines
@@ -112,13 +112,18 @@
                 output = OUTPUT_PBC;
                 break;
             case 'o':
-                argv++; /* next argument */
-                argc--;
-                /* store a pointer to the output file name, it's there during 
the
-                 * whole program's lifetime, as it's an argument to main(), so 
no need
-                 * to clone the string
-                 */
-                outputfile = argv[0];
+                if (argc > 0) {
+                    argv++; /* next argument */
+                    argc--;
+                    /* store a pointer to the output file name, it's there 
during the
+                     * whole program's lifetime, as it's an argument to 
main(), so no need
+                     * to clone the string
+                     */
+                    outputfile = argv[0];
+                }
+                else {
+                    print_help();
+                }
                 break;
             default:
                 fprintf(stderr, "Unknown option: '%c'\n", opt);

Reply via email to