allow specification of the input file name on the command line
authorpmf <pmf@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 13 Aug 2008 15:40:54 +0000 (15:40 +0000)
committerpmf <pmf@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 13 Aug 2008 15:40:54 +0000 (15:40 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@3009 04897980-b3bd-0310-b5e0-8ef037075253

trunk/masters-pmf/java_speed_test/c/main.c
trunk/masters-pmf/java_speed_test/java/read_trace.java

index 08baaf62b78b76cca7f6da8c5a2318fb135735c4..de666de84537bd2669f2cad5424560e77e4c4482 100644 (file)
@@ -15,11 +15,26 @@ int main(int argc, char **argv)
        int result;
        FILE *fp;
        int print = 0;
+       int i;
+       char *filename = NULL;
+
+       if(argc > 1) {
+               for(i=1; i<argc; i++) {
+                       if(!strcmp(argv[i], "-p")) {
+                               print = 1;
+                       }
+                       else {
+                               filename = argv[i];
+                       }
+               }
+       }
 
-       if(argc >= 2 && !strcmp(argv[1], "-p"))
-               print = 1;
+       if(filename == NULL) {
+               fprintf(stderr, "No trace file specified\n");
+               return 1;
+       }
 
-       fp = fopen("../trace.dat", "r");
+       fp = fopen(filename, "r");
        if(fp == NULL) {
                perror("fopen");
                return 1;
index 91f48fd5cc7c19bc8c54f4ef9fdf99126d2dc468..aacb08eb164835161b21c9ea6dbbbdd377b35b02 100644 (file)
@@ -3,9 +3,25 @@ import java.io.*;
 public class read_trace {
        public static void main(String[] args) {
                int tmp = 0;
+               boolean print = false;
+               String filename = "";
+
+               for(String s : args) {
+                       if(s.equals("-p")) {
+                               print = true;
+                       }
+                       else {
+                               filename = s;
+                       }
+               }
+               
+               if(filename.equals("")) {
+                       System.out.println("error: no filename specified");
+                       return;
+               }
 
                try {
-                       FileInputStream file_input = new FileInputStream ("../trace.dat");
+                       FileInputStream file_input = new FileInputStream (filename);
                        BufferedInputStream buffered_input = new BufferedInputStream(file_input);
                        DataInputStream data_input = new DataInputStream (buffered_input);
                        
This page took 0.025033 seconds and 4 git commands to generate.