Changeset 15e50b0 in git


Ignore:
Timestamp:
15/01/14 06:15:16 (6 years ago)
Author:
Olly Betts <olly@…>
Branches:
line_contents, master, stereo, travis-osx
Children:
53966d3
Parents:
3d3fb6c
git-author:
Olly Betts <olly@…> (15/01/14 06:14:20)
git-committer:
Olly Betts <olly@…> (15/01/14 06:15:16)
Message:

src/img.c: Simplify reading of labels in 3d v1 and v2 files.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r3d3fb6c r15e50b0  
     1Wed Jan 15 06:13:44 GMT 2014  Olly Betts <olly@survex.com>
     2
     3        * src/img.c: Simplify reading of labels in 3d v1 and v2 files.
     4
    15Wed Jan 15 06:11:12 GMT 2014  Olly Betts <olly@survex.com>
    26
  • src/img.c

    r3d3fb6c r15e50b0  
    16271627   long opt;
    16281628
     1629   again: /* label to goto if we get a cross */
    16291630   pimg->label = pimg->label_buf;
    1630 
    1631    again: /* label to goto if we get a cross */
    16321631   pimg->label[0] = '\0';
    16331632
     
    16631662      goto again;
    16641663    case 2: case 3: {
    1665       char *q;
    1666       int ch;
     1664      size_t len;
    16671665      result = img_LABEL;
    1668       ch = GETC(pimg->fh);
    1669       if (ch == EOF) {
     1666      if (!fgets(pimg->label_buf, pimg->buf_len, pimg->fh)) {
    16701667         img_errno = feof(pimg->fh) ? IMG_BADFORMAT : IMG_READERROR;
    16711668         return img_BAD;
    16721669      }
    1673       if (ch != '\\') ungetc(ch, pimg->fh);
    1674       fgets(pimg->label_buf, pimg->buf_len, pimg->fh);
    1675       if (feof(pimg->fh)) {
     1670      if (pimg->label[0] == '\\') pimg->label++;
     1671      len = strlen(pimg->label);
     1672      if (len == 0 || pimg->label[len - 1] != '\n') {
    16761673         img_errno = IMG_BADFORMAT;
    16771674         return img_BAD;
    16781675      }
    1679       if (ferror(pimg->fh)) {
    1680          img_errno = IMG_READERROR;
    1681          return img_BAD;
    1682       }
    1683       q = pimg->label_buf + strlen(pimg->label_buf) - 1;
    1684       if (*q != '\n') {
    1685          img_errno = IMG_BADFORMAT;
    1686          return img_BAD;
    1687       }
    16881676      /* Ignore empty labels in some .3d files (caused by a bug) */
    1689       if (q == pimg->label_buf) goto again;
    1690       *q = '\0';
     1677      if (len == 1) goto again;
     1678      pimg->label[len - 1] = '\0';
    16911679      pimg->flags = img_SFLAG_UNDERGROUND; /* no flags given... */
    16921680      if (opt == 2) goto done;
     
    17661754
    17671755   if (result == img_LABEL && pimg->survey_len) {
    1768       if (strncmp(pimg->label_buf, pimg->survey, pimg->survey_len + 1) != 0)
     1756      if (strncmp(pimg->label, pimg->survey, pimg->survey_len + 1) != 0)
    17691757         goto again;
    17701758      pimg->label += pimg->survey_len + 1;
Note: See TracChangeset for help on using the changeset viewer.