]> git.pld-linux.org Git - packages/xfig.git/blob - xfig-f_read.patch
- perl -pi -e "s/^\%\{_datadir\}\/pixmaps/\%\{_pixmapsdir\}/"
[packages/xfig.git] / xfig-f_read.patch
1 diff -Nur xfig.3.2.3c.orig/f_read.c xfig.3.2.3c/f_read.c
2 --- xfig.3.2.3c/f_read.c.orig   Mon Jul  3 23:36:56 2000
3 +++ xfig.3.2.3c/f_read.c        Thu Nov  9 18:12:53 2000
4 @@ -73,8 +73,6 @@
5  
6  /* max number of comments that can be stored with each object */
7  #define MAXCOMMENTS    50
8 -/* max length of any comment */
9 -#define MAXCOMMLEN     200
10  /* input buffer length */
11  #define        BUF_SIZE        1024
12  
13 @@ -455,12 +453,11 @@
14             if (num_object) {
15                 file_msg("Color definitions must come before other objects (line %d).",
16                         line_no);
17 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
18             }
19             break;
20         case O_POLYLINE:
21             if ((l = read_lineobject(fp)) == NULL)
22 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
23 +               continue;
24             if (ll)
25                 ll = (ll->next = l);
26             else
27 @@ -469,7 +466,7 @@
28             break;
29         case O_SPLINE:
30             if ((s = read_splineobject(fp)) == NULL)
31 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
32 +               continue;
33             if (ls)
34                 ls = (ls->next = s);
35             else
36 @@ -478,7 +475,7 @@
37             break;
38         case O_ELLIPSE:
39             if ((e = read_ellipseobject()) == NULL)
40 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
41 +               continue;
42             if (le)
43                 le = (le->next = e);
44             else
45 @@ -487,7 +484,7 @@
46             break;
47         case O_ARC:
48             if ((a = read_arcobject(fp)) == NULL)
49 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
50 +               continue;
51             if (la)
52                 la = (la->next = a);
53             else
54 @@ -496,7 +493,7 @@
55             break;
56         case O_TEXT:
57             if ((t = read_textobject(fp)) == NULL)
58 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
59 +               continue;
60             if (lt)
61                 lt = (lt->next = t);
62             else
63 @@ -505,7 +502,7 @@
64             break;
65         case O_COMPOUND:
66             if ((c = read_compoundobject(fp)) == NULL)
67 -               return (num_object != 0? 0: BAD_FORMAT);        /* ok if any objects have been read */
68 +               continue;
69             if (lc)
70                 lc = (lc->next = c);
71             else
72 @@ -625,13 +622,15 @@
73      check_color(&a->fill_color);
74      fix_fillstyle(a);  /* make sure that black/white have legal fill styles */
75  
76 +    a->comments = attach_comments();           /* attach any comments */
77 +
78      /* forward arrow */
79      if (fa) {
80         if (read_line(fp) == -1)
81 -           return NULL;
82 +           return a;
83         if (sscanf(buf, "%d%d%f%f%f", &type, &style, &thickness, &wd, &ht) != 5) {
84             file_msg(Err_incomp, "arc", line_no);
85 -           return NULL;
86 +           return a;
87         }
88         /* throw away any arrow heads on pie-wedge arcs */
89         if (a->type == T_OPEN_ARC) {
90 @@ -643,10 +642,10 @@
91      /* backward arrow */
92      if (ba) {
93         if (read_line(fp) == -1)
94 -           return NULL;
95 +           return a;
96         if (sscanf(buf, "%d%d%f%f%f", &type, &style, &thickness, &wd, &ht) != 5) {
97             file_msg(Err_incomp, "arc", line_no);
98 -           return NULL;
99 +           return a;
100         }
101         /* throw away any arrow heads on pie-wedge arcs */
102         if (a->type == T_OPEN_ARC) {
103 @@ -654,7 +653,6 @@
104             a->back_arrow = new_arrow(type, style, thickness, wd, ht);
105         }
106      }
107 -    a->comments = attach_comments();           /* attach any comments */
108      return a;
109  }
110  
111 @@ -693,65 +691,53 @@
112      while (read_line(fp) > 0) {
113         if (sscanf(buf, "%d", &object) != 1) {
114             file_msg(Err_incomp, "compound", line_no);
115 -           free_compound(&com);
116 +           free((char *) com);
117             return NULL;
118         }
119         switch (object) {
120         case O_POLYLINE:
121 -           if ((l = read_lineobject(fp)) == NULL) {
122 -               free_line(&l);
123 -               return NULL;
124 -           }
125 +           if ((l = read_lineobject(fp)) == NULL)
126 +               continue;
127             if (ll)
128                 ll = (ll->next = l);
129             else
130                 ll = com->lines = l;
131             break;
132         case O_SPLINE:
133 -           if ((s = read_splineobject(fp)) == NULL) {
134 -               free_spline(&s);
135 -               return NULL;
136 -           }
137 +           if ((s = read_splineobject(fp)) == NULL)
138 +               continue;
139             if (ls)
140                 ls = (ls->next = s);
141             else
142                 ls = com->splines = s;
143             break;
144         case O_ELLIPSE:
145 -           if ((e = read_ellipseobject()) == NULL) {
146 -               free_ellipse(&e);
147 -               return NULL;
148 -           }
149 +           if ((e = read_ellipseobject()) == NULL)
150 +               continue;
151             if (le)
152                 le = (le->next = e);
153             else
154                 le = com->ellipses = e;
155             break;
156         case O_ARC:
157 -           if ((a = read_arcobject(fp)) == NULL) {
158 -               free_arc(&a);
159 -               return NULL;
160 -           }
161 +           if ((a = read_arcobject(fp)) == NULL)
162 +               continue;
163             if (la)
164                 la = (la->next = a);
165             else
166                 la = com->arcs = a;
167             break;
168         case O_TEXT:
169 -           if ((t = read_textobject(fp)) == NULL) {
170 -               free_text(&t);
171 -               return NULL;
172 -           }
173 +           if ((t = read_textobject(fp)) == NULL)
174 +               continue;
175             if (lt)
176                 lt = (lt->next = t);
177             else
178                 lt = com->texts = t;
179             break;
180         case O_COMPOUND:
181 -           if ((c = read_compoundobject(fp)) == NULL) {
182 -               free_compound(&c);
183 -               return NULL;
184 -           }
185 +           if ((c = read_compoundobject(fp)) == NULL)
186 +               continue;
187             if (lc)
188                 lc = (lc->next = c);
189             else
190 @@ -761,9 +747,10 @@
191             return com;
192         default:
193             file_msg("Incorrect object code at line %d.", line_no);
194 -           return NULL;
195 +           continue;
196         }                       /* switch */
197 -    }
198 +    } /* while (read_line(fp) > 0) */
199 +
200      if (feof(fp))
201         return com;
202      else
203 @@ -902,14 +889,17 @@
204      if (l->type == T_PICTURE) {
205         char s1[PATH_MAX];
206  
207 -       if (read_line(fp) == -1)
208 +       if (read_line(fp) == -1) {
209 +           free((char *) l);
210             return NULL;
211 +       }
212         if ((l->pic = create_pic()) == NULL) {
213             free((char *) l);
214             return NULL;
215         }
216         if (sscanf(buf, "%d %s", &l->pic->flipped, s1) != 2) {
217             file_msg(Err_incomp, "Picture Object", line_no);
218 +           free((char *) l);
219             return NULL;
220         }
221         /* if path is relative, convert it to absolute path */
222 @@ -928,8 +918,10 @@
223      } else
224         l->pic = NULL;
225  
226 -    if ((p = create_point()) == NULL)
227 +    if ((p = create_point()) == NULL) {
228 +       free((char *) l);
229         return NULL;
230 +    }
231  
232      l->points = p;
233      p->next = NULL;
234 @@ -1117,6 +1109,7 @@
235              count_lines_correctly(fp);
236              if (fscanf(fp, "%f%f%f%f", &lx, &ly, &rx, &ry) != 4) {
237                file_msg(Err_incomp, "spline", line_no);
238 +             free_splinestorage(s);
239                return NULL;
240              }
241            }
242 @@ -1336,6 +1329,7 @@
243                             /* allow exactly 3 digits following the \ for the octal value */
244                             if (sscanf(&s[l+1],"%3o",&num)!=1) {
245                                 file_msg("Error in parsing text string on line.",line_no);
246 +                               free((char *) t);
247                                 return NULL;
248                             }
249                             buf[n++]= (unsigned char) num;      /* put char in */
250 @@ -1357,10 +1351,9 @@
251         t->type = T_LEFT_JUSTIFIED;
252      }
253  
254 -    if (strlen(s) <= 1)
255 -       {
256 +    if (strlen(s) <= 1) {
257         s[0]=' ';s[1]=0;
258 -       }
259 +    }
260      /* skip first blank from input file by starting at s[1] */
261      if ((t->cstring = new_string(strlen(&s[1]))) == NULL) {
262         free((char *) t);
263 @@ -1457,11 +1450,12 @@
264  {
265      int                    i;
266  
267 +    i=strlen(buf);
268      /* see if we've allocated space for this comment */
269 -    if (comments[numcom] == 0)
270 -       if ((comments[numcom] = (char*) new_string(MAXCOMMLEN)) == NULL)
271 +    if (comments[numcom])
272 +       free(comments[numcom]);
273 +    if ((comments[numcom] = (char*) new_string(i+1)) == NULL)
274             return -1;
275 -    i=strlen(buf);
276      /* remove any newline */
277      if (buf[i-1] == '\n')
278         buf[i-1] = '\0';
This page took 0.639343 seconds and 3 git commands to generate.