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
6 /* max number of comments that can be stored with each object */
8 -/* max length of any comment */
9 -#define MAXCOMMLEN 200
10 /* input buffer length */
15 file_msg("Color definitions must come before other objects (line %d).",
17 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
21 if ((l = read_lineobject(fp)) == NULL)
22 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
30 if ((s = read_splineobject(fp)) == NULL)
31 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
39 if ((e = read_ellipseobject()) == NULL)
40 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
48 if ((a = read_arcobject(fp)) == NULL)
49 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
57 if ((t = read_textobject(fp)) == NULL)
58 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
66 if ((c = read_compoundobject(fp)) == NULL)
67 - return (num_object != 0? 0: BAD_FORMAT); /* ok if any objects have been read */
73 check_color(&a->fill_color);
74 fix_fillstyle(a); /* make sure that black/white have legal fill styles */
76 + a->comments = attach_comments(); /* attach any comments */
80 if (read_line(fp) == -1)
83 if (sscanf(buf, "%d%d%f%f%f", &type, &style, &thickness, &wd, &ht) != 5) {
84 file_msg(Err_incomp, "arc", line_no);
88 /* throw away any arrow heads on pie-wedge arcs */
89 if (a->type == T_OPEN_ARC) {
93 if (read_line(fp) == -1)
96 if (sscanf(buf, "%d%d%f%f%f", &type, &style, &thickness, &wd, &ht) != 5) {
97 file_msg(Err_incomp, "arc", line_no);
101 /* throw away any arrow heads on pie-wedge arcs */
102 if (a->type == T_OPEN_ARC) {
104 a->back_arrow = new_arrow(type, style, thickness, wd, ht);
107 - a->comments = attach_comments(); /* attach any comments */
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);
121 - if ((l = read_lineobject(fp)) == NULL) {
125 + if ((l = read_lineobject(fp)) == NULL)
133 - if ((s = read_splineobject(fp)) == NULL) {
137 + if ((s = read_splineobject(fp)) == NULL)
142 ls = com->splines = s;
145 - if ((e = read_ellipseobject()) == NULL) {
149 + if ((e = read_ellipseobject()) == NULL)
154 le = com->ellipses = e;
157 - if ((a = read_arcobject(fp)) == NULL) {
161 + if ((a = read_arcobject(fp)) == NULL)
169 - if ((t = read_textobject(fp)) == NULL) {
173 + if ((t = read_textobject(fp)) == NULL)
181 - if ((c = read_compoundobject(fp)) == NULL) {
185 + if ((c = read_compoundobject(fp)) == NULL)
193 file_msg("Incorrect object code at line %d.", line_no);
198 + } /* while (read_line(fp) > 0) */
203 @@ -902,14 +889,17 @@
204 if (l->type == T_PICTURE) {
207 - if (read_line(fp) == -1)
208 + if (read_line(fp) == -1) {
212 if ((l->pic = create_pic()) == NULL) {
216 if (sscanf(buf, "%d %s", &l->pic->flipped, s1) != 2) {
217 file_msg(Err_incomp, "Picture Object", line_no);
221 /* if path is relative, convert it to absolute path */
226 - if ((p = create_point()) == NULL)
227 + if ((p = create_point()) == 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);
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);
249 buf[n++]= (unsigned char) num; /* put char in */
250 @@ -1357,10 +1351,9 @@
251 t->type = T_LEFT_JUSTIFIED;
254 - if (strlen(s) <= 1)
256 + if (strlen(s) <= 1) {
260 /* skip first blank from input file by starting at s[1] */
261 if ((t->cstring = new_string(strlen(&s[1]))) == NULL) {
263 @@ -1457,11 +1450,12 @@
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)
276 /* remove any newline */
277 if (buf[i-1] == '\n')