From a8c10f9282a6a33698e363124f6ac7da4ac4ed65 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Thu, 16 May 2013 15:07:31 +0200
Subject: [PATCH] Temporary fix of examples/simple (need to fix liblabcomm)...

---
 examples/simple/compile.sh        | 19 ++++++++++++++++---
 examples/simple/example_decoder.c | 24 ++++++++++++++----------
 examples/simple/example_encoder.c |  2 +-
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/examples/simple/compile.sh b/examples/simple/compile.sh
index cd7729c..564eba5 100644
--- a/examples/simple/compile.sh
+++ b/examples/simple/compile.sh
@@ -1,12 +1,25 @@
-(cd ../../lib/c; make -e LABCOMM_NO_EXPERIMENTAL=true)
+#(cd ../../lib/c; make -e LABCOMM_NO_EXPERIMENTAL=true)
 (cd ../../compiler ; ant jar)
 
+mkdir -p gen
 java -jar ../../compiler/labComm.jar --java=gen --c=gen/simple.c --h=gen/simple.h  --python=gen/simple.py simple.lc 
 
 javac -cp ../../lib/java:. gen/*.java Encoder.java Decoder.java
 
-gcc -o example_encoder -L ../../lib/c -I . -I ../../lib/c example_encoder.c gen/simple.c -llabcomm
-gcc -o example_decoder -L ../../lib/c -I . -I ../../lib/c example_decoder.c gen/simple.c -llabcomm
+gcc -Wall -Werror -I . -I ../../lib/c \
+    -DLABCOMM_FD_OMIT_VERSION \
+    -DLABCOMM_ENCODER_LINEAR_SEARCH \
+     gen/simple.c  ../../lib/c/labcomm.c \
+    ../../lib/c/labcomm_dynamic_buffer_writer.c \
+    ../../lib/c/labcomm_fd_writer.c \
+    -o example_encoder example_encoder.c 
+gcc -Wall -Werror -I . -I ../../lib/c \
+    -DLABCOMM_FD_OMIT_VERSION \
+    -DLABCOMM_ENCODER_LINEAR_SEARCH \
+     gen/simple.c  ../../lib/c/labcomm.c \
+    ../../lib/c/labcomm_dynamic_buffer_writer.c \
+    ../../lib/c/labcomm_fd_reader.c \
+    -o example_decoder example_decoder.c
 
 #gcc -o example_encoder -I . -I ../../lib/c example_encoder.c gen/simple.c ../../lib/c/labcomm.c ../../lib/c/labcomm_fd_reader_writer.c
 
diff --git a/examples/simple/example_decoder.c b/examples/simple/example_decoder.c
index 79a6767..c34e19b 100644
--- a/examples/simple/example_decoder.c
+++ b/examples/simple/example_decoder.c
@@ -19,37 +19,39 @@ static void handle_simple_IntString(simple_IntString *v,void *context) {
 
 static void handle_simple_TwoArrays(simple_TwoArrays *d,void *context) {
   printf("Got TwoArrays:");
-    int i;
+  int i,j;
     for(i=0; i<2; i++) {
         printf("%d ",d->fixed.a[i]);
     }
     printf("\n");
-    for(i=0; i<d->variable.n_1; i++) {
-        printf("%d ",d->variable.a[0+2*i]);
-        printf("%d ",d->variable.a[1+2*i]);
+    for(i=0; i<2; i++) {
+      for(j=0; j<d->variable.n_1; j++) {
+	printf("%d ",d->variable.a[i *d->variable.n_1 + j]);
+      }
+      printf("\n");
     }
     printf("\n");
 }
 
 static void handle_simple_TwoFixedArrays(simple_TwoFixedArrays *d,void *context) {
   printf("Got TwoFixedArrays:");
-    int i;
+  int i,j;
     for(i=0; i<2; i++) {
         printf("%d ",d->a.a[i]);
     }
     printf("\n");
-    for(i=0; i<3; i++) {
-        printf("%d ",d->b.a[0+2*i]);
-        printf("%d ",d->b.a[1+2*i]);
+    for(i=0; i<2; i++) {
+      for(j=0; j<3; j++) {
+	printf("%d ",d->b.a[i][j]);
+      }
+      printf("\n");
     }
-    printf("\n");
 }
 
 int main(int argc, char *argv[]) {
   int fd;
   struct labcomm_decoder *decoder;
   void  *context = NULL;
-  int i, j;
 
   char *filename = argv[1];
   printf("C decoder reading from %s\n", filename);
@@ -70,4 +72,6 @@ int main(int argc, char *argv[]) {
   labcomm_decoder_run(decoder);
   printf("--- End Of File ---:\n");
   labcomm_decoder_free(decoder);
+
+  return 0;
 }
diff --git a/examples/simple/example_encoder.c b/examples/simple/example_encoder.c
index b516a3a..4a6e98b 100644
--- a/examples/simple/example_encoder.c
+++ b/examples/simple/example_encoder.c
@@ -8,7 +8,6 @@
 int main(int argc, char *argv[]) {
   int fd;
   struct labcomm_encoder *encoder;
-  int i, j;
 
   char *filename = argv[1];
   printf("C encoder writing to %s\n", filename);
@@ -65,4 +64,5 @@ int main(int argc, char *argv[]) {
   labcomm_encoder_register_simple_TwoFixedArrays(encoder);
   labcomm_encode_simple_TwoFixedArrays(encoder, &tfa);
 
+  return 0;
 }
-- 
GitLab