diff --git a/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java b/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java index f9c1a6798..6c5cc0587 100644 --- a/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java +++ b/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java @@ -2626,14 +2626,14 @@ private final int _finishLongTextAscii(int len) throws IOException { char[] outBuf = _textBuffer.emptyAndGetCurrentSegment(); final byte[] input = _inputBuffer; + int outPtr = 0; while (len > 0) { // load as much input as possible int size = Math.min(len, Math.min(outBuf.length, input.length)); if (!_tryToLoadToHaveAtLeast(size)) { return len; } - int outEnd = size; - int outPtr = 0; + int outEnd = size + outPtr; int inPtr = _inputPtr; int i = 0; // Tight loop to copy into the output buffer, bail if a non-ascii char is found @@ -2651,9 +2651,11 @@ private final int _finishLongTextAscii(int len) throws IOException _inputPtr = inPtr; if (outPtr >= outBuf.length) { outBuf = _textBuffer.finishCurrentSegment(); + outPtr = 0; } len -= size; } + _textBuffer.setCurrentLength(outPtr); return len; } diff --git a/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseLongAsciiTextTest.java b/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseLongAsciiTextTest.java new file mode 100644 index 000000000..bb0b9c813 --- /dev/null +++ b/cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseLongAsciiTextTest.java @@ -0,0 +1,36 @@ +package com.fasterxml.jackson.dataformat.cbor.parse; + + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.dataformat.cbor.CBORParser; +import com.fasterxml.jackson.dataformat.cbor.CBORTestBase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ParseLongAsciiTextTest extends CBORTestBase { + + + @Test + public void testLongNonChunkedAsciiText() throws IOException { + CBORParser p = cborFactory().createParser(this.getClass().getResourceAsStream("/data/macbeth-snippet-non-chunked.cbor")); + + assertEquals(JsonToken.VALUE_STRING, p.nextToken()); + String expected = new String(readResource("/data/macbeth-snippet.txt"), "UTF-8"); + assertEquals(expected, p.getText()); + + } + + @Test + public void testLongChunkedAsciiText() throws IOException { + CBORParser p = cborFactory().createParser(this.getClass().getResourceAsStream("/data/macbeth-snippet-chunked.cbor")); + + assertEquals(JsonToken.VALUE_STRING, p.nextToken()); + String expected = new String(readResource("/data/macbeth-snippet.txt"), StandardCharsets.UTF_8); + assertEquals(expected, p.getText()); + } + +} diff --git a/cbor/src/test/resources/data/macbeth-snippet-chunked.cbor b/cbor/src/test/resources/data/macbeth-snippet-chunked.cbor new file mode 100644 index 000000000..c7d7da6a0 --- /dev/null +++ b/cbor/src/test/resources/data/macbeth-snippet-chunked.cbor @@ -0,0 +1,296 @@ +yœ--- +Act I, Scene + +A desert place. +--- + +First Witch. When shall we three meet again +In thunder, lightning, or in rain? +Second Witch. When the hurlyburly's done, +When the battle's lost and won. +Third Witch. That will be ere the set of sun. +First Witch. Where the place? +Second Witch. Upon the heath. +Third Witch. There to meet with Macbeth. +First Witch. I come, Graymalkin! +Second Witch. Paddock calls. +Third Witch. Anon. +All. Fair is foul, and foul is fair: +Hover through the fog and filthy air. + +--- +Act I, Scene + +A camp near Forres. +--- + +Duncan. What bloody man is that? He can report, +As seemeth by his plight, of the revolt +The newest state. +Malcolm. This is the sergeant +Who like a good and hardy soldier fought +'Gainst my captivity. Hail, brave friend! +Say to the king the knowledge of the broil +As thou didst leave it. +Sergeant. Doubtful it stood; +As two spent swimmers, that do cling together +And choke their art. The merciless Macdonwald- +Worthy to be a rebel, for to that +The multiplying villanies of nature +Do swarm upon him-from the western isles +Of kerns and gallowglasses is supplied; +And fortune, on his damned quarrel smiling, +Show'd like a rebel's whore: but all's too weak: +For brave Macbeth-well he deserves that name- +Disdaining fortune, with his brandish'd steel, +Which smoked with bloody execution, +Like valour's minion carved out his passage +Till he faced the slave; +Which ne'er shook hands, nor bade farewell to him, +Till he unseam'd him from the nave to the chaps, +And fix'd his head upon our battlements. +Duncan. O valiant cousin! worthy gentleman! +Sergeant. As whence the sun 'gins his reflection +Shipwrecking storms and direful thunders break, +So from that spring whence comfort seem'd to come +Discomfort swells. Mark, king of Scotland, mark: +No sooner justice had with valour arm'd +Compell'd these skipping kerns to trust their heels, +But the Norweyan lord surveying vantage, +With furbish'd arms and new supplies of men +Began a fresh assault. +Duncan. Dismay'd not this +Our captains, Macbeth and Banquo? +Sergeant. Yes; +As sparrows eagles, or the hare the lion. +If I say sooth, I must report they were +As cannons overcharged with double cracks, so they +Doubly redoubled strokes upon the foe: +Except they meant to bathe in reeking wounds, +Or memorise another Golgotha, +I cannot tell. +But I am faint, my gashes cry for help. +Duncan. So well thy words become thee as thy wounds; +They smack of honour both. Go get him surgeons. +[Exit Sergeant, attended] +Who comes here? +[Enter ROSS] + +Malcolm. The worthy thane of Ross. +Lennox. What a haste looks through his eyes! So should he look +That seems to speak things strange. +Ross. God save the king! +Duncan. Whence camest thou, worthy thane? +Ross. From Fife, great king; +Where the Norweyan banners flout the sky +And fan our people cold. Norway himself, +With terrible numbers, +Assisted by that most disloyal traitor +The thane of Cawdor, began a dismal conflict; +Till that Bellona's bridegroom, lapp'd in proof, +Confronted him with self-comparisons, +Point against point rebellious, arm 'gainst arm. +Curbing his lavish spirit: and, to conclude, +The victory fell on us. +Duncan. Great happiness! +Ross. That now +Sweno, the Norways' king, craves composition: +Nor would we deign him burial of his men +Till he disbursed at Saint Colme's inch +Ten thousand dollars to our general use. +Duncan. No more that thane of Cawdor shall deceive +Our bosom interest: go pronounce his present death, +And with his former title greet Macbeth. +Ross. I'll see it done. +Duncan. What he hath lost noble Macbeth hath won. +[Exeunt] + +--- +Act I, Scene + +A heath near Forres. + +--- +[Thunder. Enter the three Witches] + +First Witch. Where hast thou been, sister? +Second Witch. Killing swine. +Third Witch. Sister, where thou? +First Witch. A sailor's wife had chestnuts in her lap, +And munch'd, and munch'd, and munch'd:- +'Give me,' quoth I: +'Aroint thee, witch!' the rump-fed ronyon cries. +Her husband's to Aleppo gone, master o' the Tiger: +Butyœ in a sieve I'll thither sail, +And, like a rat without a tail, +I'll do, I'll do, and I'll do. +Second Witch. I'll give thee a wind. +First Witch. Thou'rt kind. +Third Witch. And I another. +First Witch. I myself have all the other, +And the very ports they blow, +All the quarters that they know +I' the shipman's card. +I will drain him dry as hay: +Sleep shall neither night nor day +Hang upon his pent-house lid; +He shall live a man forbid: +Weary se'nnights nine times nine +Shall he dwindle, peak and pine: +Though his bark cannot be lost, +Yet it shall be tempest-tost. +Look what I have. +Second Witch. Show me, show me. +First Witch. Here I have a pilot's thumb, +Wreck'd as homeward he did come. +[Drum within] + +Third Witch. A drum, a drum! +Macbeth doth come. +All. The weird sisters, hand in hand, +Posters of the sea and land, +Thus do go about, about: +Thrice to thine and thrice to mine +And thrice again, to make up nine. +Peace! the charm's wound up. +[Enter MACBETH and BANQUO] + +Macbeth. So foul and fair a day I have not seen. +Banquo. How far is't call'd to Forres? What are these +So wither'd and so wild in their attire, +That look not like the inhabitants o' the earth, +And yet are on't? Live you? or are you aught +That man may question? You seem to understand me, +By each at once her chappy finger laying +Upon her skinny lips: you should be women, +And yet your beards forbid me to interpret +That you are so. +Macbeth. Speak, if you can: what are you? +First Witch. All hail, Macbeth! hail to thee, thane of Glamis! +Second Witch. All hail, Macbeth, hail to thee, thane of Cawdor! +Third Witch. All hail, Macbeth, thou shalt be king hereafter! +Banquo. Good sir, why do you start; and seem to fear +Things that do sound so fair? I' the name of truth, +Are ye fantastical, or that indeed +Which outwardly ye show? My noble partner +You greet with present grace and great prediction +Of noble having and of royal hope, +That he seems rapt withal: to me you speak not. +If you can look into the seeds of time, +And say which grain will grow and which will not, +Speak then to me, who neither beg nor fear +Your favours nor your hate. +First Witch. Hail! +Second Witch. Hail! +Third Witch. Hail! +First Witch. Lesser than Macbeth, and greater. +Second Witch. Not so happy, yet much happier. +Third Witch. Thou shalt get kings, though thou be none: +So all hail, Macbeth and Banquo! +First Witch. Banquo and Macbeth, all hail! +Macbeth. Stay, you imperfect speakers, tell me more: +By Sinel's death I know I am thane of Glamis; +But how of Cawdor? the thane of Cawdor lives, +A prosperous gentleman; and to be king +Stands not within the prospect of belief, +No more than to be Cawdor. Say from whence +You owe this strange intelligence? or why +Upon this blasted heath you stop our way +With such prophetic greeting? Speak, I charge you. +[Witches vanish] + +Banquo. The earth hath bubbles, as the water has, +And these are of them. Whither are they vanish'd? +Macbeth. Into the air; and what seem'd corporal melted +As breath into the wind. Would they had stay'd! +Banquo. Were such things here as we do speak about? +Or have we eaten on the insane root +That takes the reason prisoner? +Macbeth. Your children shall be kings. +Banquo. You shall be king. +Macbeth. And thane of Cawdor too: went it not so? +Banquo. To the selfsame tune and words. Who's here? +[Enter ROSS and ANGUS] + +Ross. The king hath happily received, Macbeth, +The news of thy success; and when he reads +Thy personal venture in the rebels' fight, +His wonders and his praises do contend +Which should be thine or his: silenced with that, +In viewing o'er the rest o' the selfsame day, +He finds thee in the stout Norweyan ranks, +Nothing afeard of what thyself didst make, +Strange images of death. As thick as hail +Came post with post; and every one did bear +Thy praises in his kingdom's great defence, +And pour'd them down before him. +Angus. We are sent +To give thee from our royal master thanks; +Only to herald thee into his sight, +Not pay thee. +Ross. And, for an eary Þnest of a greater honour, +He bade me, from him, call thee thane of Cawdor: +In which addition, hail, most worthy thane! +For it is thine. +Banquo. What, can the devil speak true? +Macbeth. The thane of Cawdor lives: why do you dress me +In borrow'd robes? +Angus. Who was the thane lives yet; +But under heavy judgment bears that life +Which he deserves to lose. Whether he was combined +With those of Norway, or did line the rebel +With hidden help and vantage, or that with both +He labour'd in his country's wreck, I know not; +But treasons capital, confess'd and proved, +Have overthrown him. +Macbeth. [Aside] Glamis, and thane of Cawdor! +The greatest is behind. +[To ROSS and ANGUS] +Thanks for your pains. +[To BANQUO] +Do you not hope your children shall be kings, +When those that gave the thane of Cawdor to me +Promised no less to them? +Banquo. That trusted home +Might yet enkindle you unto the crown, +Besides the thane of Cawdor. But 'tis strange: +And oftentimes, to win us to our harm, +The instruments of darkness tell us truths, +Win us with honest trifles, to betray's +In deepest consequence. +Cousins, a word, I pray you. +Macbeth. [Aside]. Two truths are told, +As happy prologues to the swelling act +Of the imperial theme.-I thank you, gentlemen. +[Aside] This supernatural soliciting] +Cannot be ill, cannot be good: if ill, +Why hath it given me earnest of success, +Commencing in a truth? I am thane of Cawdor: +If good, why do I yield to that suggestion +Whose horrid image doth unfix my hair +And make my seated heart knock at my ribs, +Against the use of nature? Present fears +Are less than horrible imaginings: +My thought, whose murder yet is but fantastical, +Shakes so my single state of man that function +Is smother'd in surmise, and nothing is +But what is not. +Banquo. Look, how our partner's rapt. +Macbeth. [Aside] If chance will have me king, why, chance may crown me, +Without my stir. +Banquo. New horrors come upon him, +Like our strange garments, cleave not to their mould +But with the aid of use. +Macbeth. [Aside] Come what come may, +Time and the hour runs through the roughest day. +Banquo. Worthy Macbeth, we stay upon your leisure. +Macbeth. Give me your favour: my dull brain was wrought +With things forgotten. Kind gentlemen, your pains +Are register'd where every day I turn +The leaf to read them. Let us toward the king. +Think upon what hath chanced, and, at more time, +The interim having weigh'd it, let us speak +Our free hearts each to other. +Banquo. Very gladly. +Macbeth. Till then, enough. Come, friends. +ÿ \ No newline at end of file diff --git a/cbor/src/test/resources/data/macbeth-snippet-non-chunked.cbor b/cbor/src/test/resources/data/macbeth-snippet-non-chunked.cbor new file mode 100644 index 000000000..dfbcfa169 --- /dev/null +++ b/cbor/src/test/resources/data/macbeth-snippet-non-chunked.cbor @@ -0,0 +1,295 @@ +y)--- +Act I, Scene + +A desert place. +--- + +First Witch. When shall we three meet again +In thunder, lightning, or in rain? +Second Witch. When the hurlyburly's done, +When the battle's lost and won. +Third Witch. That will be ere the set of sun. +First Witch. Where the place? +Second Witch. Upon the heath. +Third Witch. There to meet with Macbeth. +First Witch. I come, Graymalkin! +Second Witch. Paddock calls. +Third Witch. Anon. +All. Fair is foul, and foul is fair: +Hover through the fog and filthy air. + +--- +Act I, Scene + +A camp near Forres. +--- + +Duncan. What bloody man is that? He can report, +As seemeth by his plight, of the revolt +The newest state. +Malcolm. This is the sergeant +Who like a good and hardy soldier fought +'Gainst my captivity. Hail, brave friend! +Say to the king the knowledge of the broil +As thou didst leave it. +Sergeant. Doubtful it stood; +As two spent swimmers, that do cling together +And choke their art. The merciless Macdonwald- +Worthy to be a rebel, for to that +The multiplying villanies of nature +Do swarm upon him-from the western isles +Of kerns and gallowglasses is supplied; +And fortune, on his damned quarrel smiling, +Show'd like a rebel's whore: but all's too weak: +For brave Macbeth-well he deserves that name- +Disdaining fortune, with his brandish'd steel, +Which smoked with bloody execution, +Like valour's minion carved out his passage +Till he faced the slave; +Which ne'er shook hands, nor bade farewell to him, +Till he unseam'd him from the nave to the chaps, +And fix'd his head upon our battlements. +Duncan. O valiant cousin! worthy gentleman! +Sergeant. As whence the sun 'gins his reflection +Shipwrecking storms and direful thunders break, +So from that spring whence comfort seem'd to come +Discomfort swells. Mark, king of Scotland, mark: +No sooner justice had with valour arm'd +Compell'd these skipping kerns to trust their heels, +But the Norweyan lord surveying vantage, +With furbish'd arms and new supplies of men +Began a fresh assault. +Duncan. Dismay'd not this +Our captains, Macbeth and Banquo? +Sergeant. Yes; +As sparrows eagles, or the hare the lion. +If I say sooth, I must report they were +As cannons overcharged with double cracks, so they +Doubly redoubled strokes upon the foe: +Except they meant to bathe in reeking wounds, +Or memorise another Golgotha, +I cannot tell. +But I am faint, my gashes cry for help. +Duncan. So well thy words become thee as thy wounds; +They smack of honour both. Go get him surgeons. +[Exit Sergeant, attended] +Who comes here? +[Enter ROSS] + +Malcolm. The worthy thane of Ross. +Lennox. What a haste looks through his eyes! So should he look +That seems to speak things strange. +Ross. God save the king! +Duncan. Whence camest thou, worthy thane? +Ross. From Fife, great king; +Where the Norweyan banners flout the sky +And fan our people cold. Norway himself, +With terrible numbers, +Assisted by that most disloyal traitor +The thane of Cawdor, began a dismal conflict; +Till that Bellona's bridegroom, lapp'd in proof, +Confronted him with self-comparisons, +Point against point rebellious, arm 'gainst arm. +Curbing his lavish spirit: and, to conclude, +The victory fell on us. +Duncan. Great happiness! +Ross. That now +Sweno, the Norways' king, craves composition: +Nor would we deign him burial of his men +Till he disbursed at Saint Colme's inch +Ten thousand dollars to our general use. +Duncan. No more that thane of Cawdor shall deceive +Our bosom interest: go pronounce his present death, +And with his former title greet Macbeth. +Ross. I'll see it done. +Duncan. What he hath lost noble Macbeth hath won. +[Exeunt] + +--- +Act I, Scene + +A heath near Forres. + +--- +[Thunder. Enter the three Witches] + +First Witch. Where hast thou been, sister? +Second Witch. Killing swine. +Third Witch. Sister, where thou? +First Witch. A sailor's wife had chestnuts in her lap, +And munch'd, and munch'd, and munch'd:- +'Give me,' quoth I: +'Aroint thee, witch!' the rump-fed ronyon cries. +Her husband's to Aleppo gone, master o' the Tiger: +But in a sieve I'll thither sail, +And, like a rat without a tail, +I'll do, I'll do, and I'll do. +Second Witch. I'll give thee a wind. +First Witch. Thou'rt kind. +Third Witch. And I another. +First Witch. I myself have all the other, +And the very ports they blow, +All the quarters that they know +I' the shipman's card. +I will drain him dry as hay: +Sleep shall neither night nor day +Hang upon his pent-house lid; +He shall live a man forbid: +Weary se'nnights nine times nine +Shall he dwindle, peak and pine: +Though his bark cannot be lost, +Yet it shall be tempest-tost. +Look what I have. +Second Witch. Show me, show me. +First Witch. Here I have a pilot's thumb, +Wreck'd as homeward he did come. +[Drum within] + +Third Witch. A drum, a drum! +Macbeth doth come. +All. The weird sisters, hand in hand, +Posters of the sea and land, +Thus do go about, about: +Thrice to thine and thrice to mine +And thrice again, to make up nine. +Peace! the charm's wound up. +[Enter MACBETH and BANQUO] + +Macbeth. So foul and fair a day I have not seen. +Banquo. How far is't call'd to Forres? What are these +So wither'd and so wild in their attire, +That look not like the inhabitants o' the earth, +And yet are on't? Live you? or are you aught +That man may question? You seem to understand me, +By each at once her chappy finger laying +Upon her skinny lips: you should be women, +And yet your beards forbid me to interpret +That you are so. +Macbeth. Speak, if you can: what are you? +First Witch. All hail, Macbeth! hail to thee, thane of Glamis! +Second Witch. All hail, Macbeth, hail to thee, thane of Cawdor! +Third Witch. All hail, Macbeth, thou shalt be king hereafter! +Banquo. Good sir, why do you start; and seem to fear +Things that do sound so fair? I' the name of truth, +Are ye fantastical, or that indeed +Which outwardly ye show? My noble partner +You greet with present grace and great prediction +Of noble having and of royal hope, +That he seems rapt withal: to me you speak not. +If you can look into the seeds of time, +And say which grain will grow and which will not, +Speak then to me, who neither beg nor fear +Your favours nor your hate. +First Witch. Hail! +Second Witch. Hail! +Third Witch. Hail! +First Witch. Lesser than Macbeth, and greater. +Second Witch. Not so happy, yet much happier. +Third Witch. Thou shalt get kings, though thou be none: +So all hail, Macbeth and Banquo! +First Witch. Banquo and Macbeth, all hail! +Macbeth. Stay, you imperfect speakers, tell me more: +By Sinel's death I know I am thane of Glamis; +But how of Cawdor? the thane of Cawdor lives, +A prosperous gentleman; and to be king +Stands not within the prospect of belief, +No more than to be Cawdor. Say from whence +You owe this strange intelligence? or why +Upon this blasted heath you stop our way +With such prophetic greeting? Speak, I charge you. +[Witches vanish] + +Banquo. The earth hath bubbles, as the water has, +And these are of them. Whither are they vanish'd? +Macbeth. Into the air; and what seem'd corporal melted +As breath into the wind. Would they had stay'd! +Banquo. Were such things here as we do speak about? +Or have we eaten on the insane root +That takes the reason prisoner? +Macbeth. Your children shall be kings. +Banquo. You shall be king. +Macbeth. And thane of Cawdor too: went it not so? +Banquo. To the selfsame tune and words. Who's here? +[Enter ROSS and ANGUS] + +Ross. The king hath happily received, Macbeth, +The news of thy success; and when he reads +Thy personal venture in the rebels' fight, +His wonders and his praises do contend +Which should be thine or his: silenced with that, +In viewing o'er the rest o' the selfsame day, +He finds thee in the stout Norweyan ranks, +Nothing afeard of what thyself didst make, +Strange images of death. As thick as hail +Came post with post; and every one did bear +Thy praises in his kingdom's great defence, +And pour'd them down before him. +Angus. We are sent +To give thee from our royal master thanks; +Only to herald thee into his sight, +Not pay thee. +Ross. And, for an earnest of a greater honour, +He bade me, from him, call thee thane of Cawdor: +In which addition, hail, most worthy thane! +For it is thine. +Banquo. What, can the devil speak true? +Macbeth. The thane of Cawdor lives: why do you dress me +In borrow'd robes? +Angus. Who was the thane lives yet; +But under heavy judgment bears that life +Which he deserves to lose. Whether he was combined +With those of Norway, or did line the rebel +With hidden help and vantage, or that with both +He labour'd in his country's wreck, I know not; +But treasons capital, confess'd and proved, +Have overthrown him. +Macbeth. [Aside] Glamis, and thane of Cawdor! +The greatest is behind. +[To ROSS and ANGUS] +Thanks for your pains. +[To BANQUO] +Do you not hope your children shall be kings, +When those that gave the thane of Cawdor to me +Promised no less to them? +Banquo. That trusted home +Might yet enkindle you unto the crown, +Besides the thane of Cawdor. But 'tis strange: +And oftentimes, to win us to our harm, +The instruments of darkness tell us truths, +Win us with honest trifles, to betray's +In deepest consequence. +Cousins, a word, I pray you. +Macbeth. [Aside]. Two truths are told, +As happy prologues to the swelling act +Of the imperial theme.-I thank you, gentlemen. +[Aside] This supernatural soliciting] +Cannot be ill, cannot be good: if ill, +Why hath it given me earnest of success, +Commencing in a truth? I am thane of Cawdor: +If good, why do I yield to that suggestion +Whose horrid image doth unfix my hair +And make my seated heart knock at my ribs, +Against the use of nature? Present fears +Are less than horrible imaginings: +My thought, whose murder yet is but fantastical, +Shakes so my single state of man that function +Is smother'd in surmise, and nothing is +But what is not. +Banquo. Look, how our partner's rapt. +Macbeth. [Aside] If chance will have me king, why, chance may crown me, +Without my stir. +Banquo. New horrors come upon him, +Like our strange garments, cleave not to their mould +But with the aid of use. +Macbeth. [Aside] Come what come may, +Time and the hour runs through the roughest day. +Banquo. Worthy Macbeth, we stay upon your leisure. +Macbeth. Give me your favour: my dull brain was wrought +With things forgotten. Kind gentlemen, your pains +Are register'd where every day I turn +The leaf to read them. Let us toward the king. +Think upon what hath chanced, and, at more time, +The interim having weigh'd it, let us speak +Our free hearts each to other. +Banquo. Very gladly. +Macbeth. Till then, enough. Come, friends. diff --git a/cbor/src/test/resources/data/macbeth-snippet.txt b/cbor/src/test/resources/data/macbeth-snippet.txt new file mode 100644 index 000000000..fcecb3436 --- /dev/null +++ b/cbor/src/test/resources/data/macbeth-snippet.txt @@ -0,0 +1,295 @@ +--- +Act I, Scene + +A desert place. +--- + +First Witch. When shall we three meet again +In thunder, lightning, or in rain? +Second Witch. When the hurlyburly's done, +When the battle's lost and won. +Third Witch. That will be ere the set of sun. +First Witch. Where the place? +Second Witch. Upon the heath. +Third Witch. There to meet with Macbeth. +First Witch. I come, Graymalkin! +Second Witch. Paddock calls. +Third Witch. Anon. +All. Fair is foul, and foul is fair: +Hover through the fog and filthy air. + +--- +Act I, Scene + +A camp near Forres. +--- + +Duncan. What bloody man is that? He can report, +As seemeth by his plight, of the revolt +The newest state. +Malcolm. This is the sergeant +Who like a good and hardy soldier fought +'Gainst my captivity. Hail, brave friend! +Say to the king the knowledge of the broil +As thou didst leave it. +Sergeant. Doubtful it stood; +As two spent swimmers, that do cling together +And choke their art. The merciless Macdonwald- +Worthy to be a rebel, for to that +The multiplying villanies of nature +Do swarm upon him-from the western isles +Of kerns and gallowglasses is supplied; +And fortune, on his damned quarrel smiling, +Show'd like a rebel's whore: but all's too weak: +For brave Macbeth-well he deserves that name- +Disdaining fortune, with his brandish'd steel, +Which smoked with bloody execution, +Like valour's minion carved out his passage +Till he faced the slave; +Which ne'er shook hands, nor bade farewell to him, +Till he unseam'd him from the nave to the chaps, +And fix'd his head upon our battlements. +Duncan. O valiant cousin! worthy gentleman! +Sergeant. As whence the sun 'gins his reflection +Shipwrecking storms and direful thunders break, +So from that spring whence comfort seem'd to come +Discomfort swells. Mark, king of Scotland, mark: +No sooner justice had with valour arm'd +Compell'd these skipping kerns to trust their heels, +But the Norweyan lord surveying vantage, +With furbish'd arms and new supplies of men +Began a fresh assault. +Duncan. Dismay'd not this +Our captains, Macbeth and Banquo? +Sergeant. Yes; +As sparrows eagles, or the hare the lion. +If I say sooth, I must report they were +As cannons overcharged with double cracks, so they +Doubly redoubled strokes upon the foe: +Except they meant to bathe in reeking wounds, +Or memorise another Golgotha, +I cannot tell. +But I am faint, my gashes cry for help. +Duncan. So well thy words become thee as thy wounds; +They smack of honour both. Go get him surgeons. +[Exit Sergeant, attended] +Who comes here? +[Enter ROSS] + +Malcolm. The worthy thane of Ross. +Lennox. What a haste looks through his eyes! So should he look +That seems to speak things strange. +Ross. God save the king! +Duncan. Whence camest thou, worthy thane? +Ross. From Fife, great king; +Where the Norweyan banners flout the sky +And fan our people cold. Norway himself, +With terrible numbers, +Assisted by that most disloyal traitor +The thane of Cawdor, began a dismal conflict; +Till that Bellona's bridegroom, lapp'd in proof, +Confronted him with self-comparisons, +Point against point rebellious, arm 'gainst arm. +Curbing his lavish spirit: and, to conclude, +The victory fell on us. +Duncan. Great happiness! +Ross. That now +Sweno, the Norways' king, craves composition: +Nor would we deign him burial of his men +Till he disbursed at Saint Colme's inch +Ten thousand dollars to our general use. +Duncan. No more that thane of Cawdor shall deceive +Our bosom interest: go pronounce his present death, +And with his former title greet Macbeth. +Ross. I'll see it done. +Duncan. What he hath lost noble Macbeth hath won. +[Exeunt] + +--- +Act I, Scene + +A heath near Forres. + +--- +[Thunder. Enter the three Witches] + +First Witch. Where hast thou been, sister? +Second Witch. Killing swine. +Third Witch. Sister, where thou? +First Witch. A sailor's wife had chestnuts in her lap, +And munch'd, and munch'd, and munch'd:- +'Give me,' quoth I: +'Aroint thee, witch!' the rump-fed ronyon cries. +Her husband's to Aleppo gone, master o' the Tiger: +But in a sieve I'll thither sail, +And, like a rat without a tail, +I'll do, I'll do, and I'll do. +Second Witch. I'll give thee a wind. +First Witch. Thou'rt kind. +Third Witch. And I another. +First Witch. I myself have all the other, +And the very ports they blow, +All the quarters that they know +I' the shipman's card. +I will drain him dry as hay: +Sleep shall neither night nor day +Hang upon his pent-house lid; +He shall live a man forbid: +Weary se'nnights nine times nine +Shall he dwindle, peak and pine: +Though his bark cannot be lost, +Yet it shall be tempest-tost. +Look what I have. +Second Witch. Show me, show me. +First Witch. Here I have a pilot's thumb, +Wreck'd as homeward he did come. +[Drum within] + +Third Witch. A drum, a drum! +Macbeth doth come. +All. The weird sisters, hand in hand, +Posters of the sea and land, +Thus do go about, about: +Thrice to thine and thrice to mine +And thrice again, to make up nine. +Peace! the charm's wound up. +[Enter MACBETH and BANQUO] + +Macbeth. So foul and fair a day I have not seen. +Banquo. How far is't call'd to Forres? What are these +So wither'd and so wild in their attire, +That look not like the inhabitants o' the earth, +And yet are on't? Live you? or are you aught +That man may question? You seem to understand me, +By each at once her chappy finger laying +Upon her skinny lips: you should be women, +And yet your beards forbid me to interpret +That you are so. +Macbeth. Speak, if you can: what are you? +First Witch. All hail, Macbeth! hail to thee, thane of Glamis! +Second Witch. All hail, Macbeth, hail to thee, thane of Cawdor! +Third Witch. All hail, Macbeth, thou shalt be king hereafter! +Banquo. Good sir, why do you start; and seem to fear +Things that do sound so fair? I' the name of truth, +Are ye fantastical, or that indeed +Which outwardly ye show? My noble partner +You greet with present grace and great prediction +Of noble having and of royal hope, +That he seems rapt withal: to me you speak not. +If you can look into the seeds of time, +And say which grain will grow and which will not, +Speak then to me, who neither beg nor fear +Your favours nor your hate. +First Witch. Hail! +Second Witch. Hail! +Third Witch. Hail! +First Witch. Lesser than Macbeth, and greater. +Second Witch. Not so happy, yet much happier. +Third Witch. Thou shalt get kings, though thou be none: +So all hail, Macbeth and Banquo! +First Witch. Banquo and Macbeth, all hail! +Macbeth. Stay, you imperfect speakers, tell me more: +By Sinel's death I know I am thane of Glamis; +But how of Cawdor? the thane of Cawdor lives, +A prosperous gentleman; and to be king +Stands not within the prospect of belief, +No more than to be Cawdor. Say from whence +You owe this strange intelligence? or why +Upon this blasted heath you stop our way +With such prophetic greeting? Speak, I charge you. +[Witches vanish] + +Banquo. The earth hath bubbles, as the water has, +And these are of them. Whither are they vanish'd? +Macbeth. Into the air; and what seem'd corporal melted +As breath into the wind. Would they had stay'd! +Banquo. Were such things here as we do speak about? +Or have we eaten on the insane root +That takes the reason prisoner? +Macbeth. Your children shall be kings. +Banquo. You shall be king. +Macbeth. And thane of Cawdor too: went it not so? +Banquo. To the selfsame tune and words. Who's here? +[Enter ROSS and ANGUS] + +Ross. The king hath happily received, Macbeth, +The news of thy success; and when he reads +Thy personal venture in the rebels' fight, +His wonders and his praises do contend +Which should be thine or his: silenced with that, +In viewing o'er the rest o' the selfsame day, +He finds thee in the stout Norweyan ranks, +Nothing afeard of what thyself didst make, +Strange images of death. As thick as hail +Came post with post; and every one did bear +Thy praises in his kingdom's great defence, +And pour'd them down before him. +Angus. We are sent +To give thee from our royal master thanks; +Only to herald thee into his sight, +Not pay thee. +Ross. And, for an earnest of a greater honour, +He bade me, from him, call thee thane of Cawdor: +In which addition, hail, most worthy thane! +For it is thine. +Banquo. What, can the devil speak true? +Macbeth. The thane of Cawdor lives: why do you dress me +In borrow'd robes? +Angus. Who was the thane lives yet; +But under heavy judgment bears that life +Which he deserves to lose. Whether he was combined +With those of Norway, or did line the rebel +With hidden help and vantage, or that with both +He labour'd in his country's wreck, I know not; +But treasons capital, confess'd and proved, +Have overthrown him. +Macbeth. [Aside] Glamis, and thane of Cawdor! +The greatest is behind. +[To ROSS and ANGUS] +Thanks for your pains. +[To BANQUO] +Do you not hope your children shall be kings, +When those that gave the thane of Cawdor to me +Promised no less to them? +Banquo. That trusted home +Might yet enkindle you unto the crown, +Besides the thane of Cawdor. But 'tis strange: +And oftentimes, to win us to our harm, +The instruments of darkness tell us truths, +Win us with honest trifles, to betray's +In deepest consequence. +Cousins, a word, I pray you. +Macbeth. [Aside]. Two truths are told, +As happy prologues to the swelling act +Of the imperial theme.-I thank you, gentlemen. +[Aside] This supernatural soliciting] +Cannot be ill, cannot be good: if ill, +Why hath it given me earnest of success, +Commencing in a truth? I am thane of Cawdor: +If good, why do I yield to that suggestion +Whose horrid image doth unfix my hair +And make my seated heart knock at my ribs, +Against the use of nature? Present fears +Are less than horrible imaginings: +My thought, whose murder yet is but fantastical, +Shakes so my single state of man that function +Is smother'd in surmise, and nothing is +But what is not. +Banquo. Look, how our partner's rapt. +Macbeth. [Aside] If chance will have me king, why, chance may crown me, +Without my stir. +Banquo. New horrors come upon him, +Like our strange garments, cleave not to their mould +But with the aid of use. +Macbeth. [Aside] Come what come may, +Time and the hour runs through the roughest day. +Banquo. Worthy Macbeth, we stay upon your leisure. +Macbeth. Give me your favour: my dull brain was wrought +With things forgotten. Kind gentlemen, your pains +Are register'd where every day I turn +The leaf to read them. Let us toward the king. +Think upon what hath chanced, and, at more time, +The interim having weigh'd it, let us speak +Our free hearts each to other. +Banquo. Very gladly. +Macbeth. Till then, enough. Come, friends.