...
|
...
|
@@ -651,14 +651,14 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
|
651
|
651
|
{
|
652
|
652
|
off_t offset = *roffset;
|
653
|
653
|
uint16_t nchars, nlines, content;
|
654
|
|
- uint8_t ppfs, csb;
|
|
654
|
+ uint8_t ppfs, ifsc, csb;
|
655
|
655
|
int i, c, l, sp = 0, term = 0, ret = CL_SUCCESS;
|
656
|
656
|
#if HWP3_VERIFY
|
657
|
657
|
uint16_t match;
|
658
|
658
|
#endif
|
659
|
659
|
#if HWP3_DEBUG
|
660
|
660
|
/* other paragraph info */
|
661
|
|
- uint8_t ifsc, flags, istyle;
|
|
661
|
+ uint8_t flags, istyle;
|
662
|
662
|
uint16_t fsize;
|
663
|
663
|
uint32_t special;
|
664
|
664
|
|
...
|
...
|
@@ -689,14 +689,15 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
|
689
|
689
|
|
690
|
690
|
nlines = le16_to_host(nlines);
|
691
|
691
|
|
|
692
|
+ if (fmap_readn(map, &ifsc, offset+PI_IFSC, sizeof(ifsc)) != sizeof(ifsc))
|
|
693
|
+ return CL_EREAD;
|
|
694
|
+
|
692
|
695
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: ppfs %u\n", level, p, ppfs);
|
693
|
696
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: nchars %u\n", level, p, nchars);
|
694
|
697
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: nlines %u\n", level, p, nlines);
|
|
698
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: ifsc %u\n", level, p, ifsc);
|
695
|
699
|
|
696
|
700
|
#if HWP3_DEBUG
|
697
|
|
- if (fmap_readn(map, &ifsc, offset+PI_IFSC, sizeof(ifsc)) != sizeof(ifsc))
|
698
|
|
- return CL_EREAD;
|
699
|
|
-
|
700
|
701
|
if (fmap_readn(map, &flags, offset+PI_FLAGS, sizeof(flags)) != sizeof(flags))
|
701
|
702
|
return CL_EREAD;
|
702
|
703
|
|
...
|
...
|
@@ -709,7 +710,6 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
|
709
|
709
|
if (fmap_readn(map, &fsize, offset+12, sizeof(fsize)) != sizeof(fsize))
|
710
|
710
|
return CL_EREAD;
|
711
|
711
|
|
712
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d]: ifsc %u\n", level, p, ifsc);
|
713
|
712
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: flags %x\n", level, p, flags);
|
714
|
713
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: spcl %x\n", level, p, special);
|
715
|
714
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: istyle %u\n", level, p, istyle);
|
...
|
...
|
@@ -730,40 +730,42 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
|
730
|
730
|
else
|
731
|
731
|
offset += HWP3_PARAINFO_SIZE_L;
|
732
|
732
|
|
733
|
|
- /* line information blocks - TODO - check how multiple line data is handled */
|
734
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d] line information starts @ offset %llu\n", level, p, (long long unsigned)offset);
|
|
733
|
+ /* line information blocks */
|
735
|
734
|
#if HWP3_DEBUG
|
736
|
|
- if (fmap_readn(map, &loff, offset+PLI_LOFF, sizeof(loff)) != sizeof(loff))
|
737
|
|
- return CL_EREAD;
|
|
735
|
+ for (i = 0; (i < nlines) && (offset < map->len); i++) {
|
|
736
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line %d information starts @ offset %llu\n", level, p, i, (long long unsigned)offset);
|
|
737
|
+ if (fmap_readn(map, &loff, offset+PLI_LOFF, sizeof(loff)) != sizeof(loff))
|
|
738
|
+ return CL_EREAD;
|
738
|
739
|
|
739
|
|
- if (fmap_readn(map, &lcor, offset+PLI_LCOR, sizeof(lcor)) != sizeof(lcor))
|
740
|
|
- return CL_EREAD;
|
|
740
|
+ if (fmap_readn(map, &lcor, offset+PLI_LCOR, sizeof(lcor)) != sizeof(lcor))
|
|
741
|
+ return CL_EREAD;
|
741
|
742
|
|
742
|
|
- if (fmap_readn(map, &lhei, offset+PLI_LHEI, sizeof(lhei)) != sizeof(lhei))
|
743
|
|
- return CL_EREAD;
|
|
743
|
+ if (fmap_readn(map, &lhei, offset+PLI_LHEI, sizeof(lhei)) != sizeof(lhei))
|
|
744
|
+ return CL_EREAD;
|
744
|
745
|
|
745
|
|
- if (fmap_readn(map, &lpag, offset+PLI_LPAG, sizeof(lpag)) != sizeof(lpag))
|
746
|
|
- return CL_EREAD;
|
|
746
|
+ if (fmap_readn(map, &lpag, offset+PLI_LPAG, sizeof(lpag)) != sizeof(lpag))
|
|
747
|
+ return CL_EREAD;
|
|
748
|
+
|
|
749
|
+ loff = le16_to_host(loff);
|
|
750
|
+ lcor = le16_to_host(lcor);
|
|
751
|
+ lhei = le16_to_host(lhei);
|
|
752
|
+ lpag = le16_to_host(lpag);
|
747
|
753
|
|
748
|
|
- loff = le16_to_host(loff);
|
749
|
|
- lcor = le16_to_host(lcor);
|
750
|
|
- lhei = le16_to_host(lhei);
|
751
|
|
- lpag = le16_to_host(lpag);
|
|
754
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line %d: loff %u\n", level, p, i, loff);
|
|
755
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line %d: lcor %x\n", level, p, i, lcor);
|
|
756
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line %d: lhei %u\n", level, p, i, lhei);
|
|
757
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line %d: lpag %u\n", level, p, i, lpag);
|
752
|
758
|
|
753
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line 0: loff %u\n", level, p, loff);
|
754
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line 0: lcor %x\n", level, p, lcor);
|
755
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line 0: lhei %u\n", level, p, lhei);
|
756
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d]: Line 0: lpag %u\n", level, p, lpag);
|
|
759
|
+ offset += HWP3_LINEINFO_SIZE;
|
|
760
|
+ }
|
|
761
|
+#else
|
|
762
|
+ offset += (nlines * HWP3_LINEINFO_SIZE);
|
757
|
763
|
#endif
|
758
|
|
- offset += HWP3_LINEINFO_SIZE;
|
759
|
764
|
|
760
|
|
- /* character shape data - may not be present if no byte flag is detected */
|
761
|
|
- /* NOTE: each character shape data represents at least one character including the terminator */
|
762
|
|
- /* peek at next character to check if character shape data is present */
|
763
|
|
- if (fmap_readn(map, &csb, offset, sizeof(csb)) != sizeof(csb))
|
764
|
|
- return CL_EREAD;
|
|
765
|
+ if (offset >= map->len)
|
|
766
|
+ return CL_EFORMAT;
|
765
|
767
|
|
766
|
|
- if (csb == 0) {
|
|
768
|
+ if (ifsc) {
|
767
|
769
|
for (i = 0, c = 0; i < nchars; i++) {
|
768
|
770
|
/* examine byte for cs data type */
|
769
|
771
|
if (fmap_readn(map, &csb, offset, sizeof(csb)) != sizeof(csb))
|
...
|
...
|
@@ -803,7 +805,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
|
803
|
803
|
|
804
|
804
|
hwp3_debug("HWP3.x: Paragraph[%d, %d]: detected %d CS block(s) and %d characters\n", level, p, c, i);
|
805
|
805
|
} else {
|
806
|
|
- hwp3_debug("HWP3.x: Paragraph[%d, %d]: no character shape data detected\n", level, p);
|
|
806
|
+ hwp3_debug("HWP3.x: Paragraph[%d, %d]: no separate character shape data detected\n", level, p);
|
807
|
807
|
}
|
808
|
808
|
|
809
|
809
|
if (!term)
|