Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > b8a83605ea8c288760ff961eac1fe0b4 > files > 12

gcl-2.6.8.20090701cvs-3mdv2010.1.src.rpm

diff -p -up gcl-2.6.8/o/plt.c.orig gcl-2.6.8/o/plt.c
--- gcl-2.6.8/o/plt.c.orig	2009-11-27 18:52:04.751077008 -0200
+++ gcl-2.6.8/o/plt.c	2009-11-27 19:01:42.670306171 -0200
@@ -132,19 +132,33 @@ parse_plt() {
     return 0;
   if (!(f=fopen(b1,"r")))
     FEerror("Cannot open map file", 0);
-  for (i=j=0,li=Cnil;fgets(b,sizeof(b),f);) {
+#define NOTHING		0	/* initial state */
+#define PLT		1	/* reading plt */
+#define NEWLINE		2	/* waiting empty line after .iplt */
+#define IPLT		3	/* reading iplt */
+  for (i=NOTHING,j=0,li=Cnil;fgets(b,sizeof(b),f);) {
     if (!memchr(b,10,sizeof(b)-1))
       FEerror("plt buffer too small", 0);
-    if ((memcmp(b," .plt",5) || memcmp(b," .iplt",6)) && !i)
+    if (i == NOTHING) {
+      if (memcmp(b," .plt", 5) == 0)
+	i = PLT;
+      else if (memcmp(b," .iplt", 6) == 0)
+	i = NEWLINE;
       continue;
-    if (*b=='\r' || *b=='\n') {
-      i=0;
+    }
+    if (*b == '\r' || *b == '\n') {
+      if (i == NEWLINE)
+	i = IPLT;
+      else
+	i = NOTHING;
       continue;
-    } else
-      if (!i) {
-	i=1;
-	continue;
-      }
+    }
+    if (b[1] != ' ') {
+    /* there is at least one "annotation" line before actual iplt information */
+      if (i != NEWLINE)
+	i = NOTHING;
+      continue;
+    }
     if (sscanf(b,"%lx%n",&u,&n)!=1)
       FEerror("Cannot read address", 0);
     for (c=b+n;*c==32;c++);
@@ -155,6 +169,10 @@ parse_plt() {
     li=make_cons(make_cons(st,fi),li);
     j++;
   }
+#undef IPLT
+#undef NEWLINE
+#undef PLT
+#undef NOTHING
   fclose(f);
   unlink(b1);
   ar=fSmake_vector1_1(j,aet_object,Cnil);