236 |
236 |
237 coll = __INST(collection); |
237 coll = __INST(collection); |
238 p = __INST(position); |
238 p = __INST(position); |
239 l = __INST(readLimit); |
239 l = __INST(readLimit); |
240 |
240 |
241 if (__isString(coll) && __bothSmallInteger(p, l)) { |
241 if (__isStringLike(coll) && __bothSmallInteger(p, l)) { |
242 |
242 |
243 pos = __intVal(p); |
243 pos = __intVal(p); |
244 /* make 1-based */ |
244 /* make 1-based */ |
245 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
245 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
246 |
246 |
247 limit = __intVal(l); |
247 limit = __intVal(l); |
248 sz = __qSize(coll) - OHDR_SIZE; |
248 sz = __qSize(coll) - OHDR_SIZE; |
249 if (sz < limit) |
249 if (sz < limit) |
250 limit = sz; |
250 limit = sz; |
251 cp = __stringVal(coll) + pos - 1; |
251 cp = __stringVal(coll) + pos - 1; |
252 |
252 |
253 for (;;) { |
253 for (;;) { |
254 if (pos > limit) break; |
254 if (pos > limit) break; |
255 ch = *cp; |
255 ch = *cp; |
256 |
256 |
257 if (((ch >= 'a') && (ch <= 'z')) || |
257 if (((ch >= 'a') && (ch <= 'z')) || |
258 ((ch >= 'A') && (ch <= 'Z')) || |
258 ((ch >= 'A') && (ch <= 'Z')) || |
259 ((ch >= '0') && (ch <= '9'))) |
259 ((ch >= '0') && (ch <= '9'))) |
260 break; |
260 break; |
261 cp++; |
261 cp++; |
262 pos++; |
262 pos++; |
263 } |
263 } |
264 |
264 |
265 len = 0; |
265 len = 0; |
266 for (;;) { |
266 for (;;) { |
267 if (pos > limit) break; |
267 if (pos > limit) break; |
268 ch = *cp & 0xFF; |
268 ch = *cp & 0xFF; |
269 |
269 |
270 if (! (((ch >= 'a') && (ch <= 'z')) || |
270 if (! (((ch >= 'a') && (ch <= 'z')) || |
271 ((ch >= 'A') && (ch <= 'Z')) || |
271 ((ch >= 'A') && (ch <= 'Z')) || |
272 ((ch >= '0') && (ch <= '9')))) |
272 ((ch >= '0') && (ch <= '9')))) |
273 break; |
273 break; |
274 buffer[len++] = ch; |
274 buffer[len++] = ch; |
275 if (len >= (sizeof(buffer)-1)) { |
275 if (len >= (sizeof(buffer)-1)) { |
276 /* emergency */ |
276 /* emergency */ |
277 break; |
277 break; |
278 } |
278 } |
279 pos++; |
279 pos++; |
280 cp++; |
280 cp++; |
281 } |
281 } |
282 |
282 |
283 /* make ZeroPosition-based */ |
283 /* make ZeroPosition-based */ |
284 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
284 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
285 __INST(position) = __mkSmallInteger(pos); |
285 __INST(position) = __mkSmallInteger(pos); |
286 buffer[len] = '\0'; |
286 buffer[len] = '\0'; |
287 RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil ); |
287 RETURN ( (len != 0) ? __MKSTRING_L(buffer, len) : nil ); |
288 } |
288 } |
289 %} |
289 %} |
290 . |
290 . |
291 ^ super nextAlphaNumericWord |
291 ^ super nextAlphaNumericWord |
292 ! |
292 ! |
399 |
399 |
400 coll = __INST(collection); |
400 coll = __INST(collection); |
401 p = __INST(position); |
401 p = __INST(position); |
402 l = __INST(readLimit); |
402 l = __INST(readLimit); |
403 |
403 |
404 if (__isString(coll) && __bothSmallInteger(p, l)) { |
404 if (__isStringLike(coll) && __bothSmallInteger(p, l)) { |
405 |
405 |
406 pos = __intVal(p); |
406 pos = __intVal(p); |
407 /* make 1-based */ |
407 /* make 1-based */ |
408 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
408 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
409 limit = __intVal(l); |
409 limit = __intVal(l); |
410 sz = __qSize(coll) - OHDR_SIZE; |
410 sz = __qSize(coll) - OHDR_SIZE; |
411 if (sz < limit) |
411 if (sz < limit) |
412 limit = sz; |
412 limit = sz; |
413 cp = __stringVal(coll) + pos - 1; |
413 cp = __stringVal(coll) + pos - 1; |
414 |
414 |
415 for (;;) { |
415 for (;;) { |
416 if (pos > limit) break; |
416 if (pos > limit) break; |
417 ch = *cp; |
417 ch = *cp; |
418 |
418 |
419 if ((ch < '0') || (ch > '9')) break; |
419 if ((ch < '0') || (ch > '9')) break; |
420 val = val * 10 + (ch - '0'); |
420 val = val * 10 + (ch - '0'); |
421 pos++; |
421 pos++; |
422 if (val > (_MAX_INT / 10)) goto oops; |
422 if (val > (_MAX_INT / 10)) goto oops; |
423 cp++; |
423 cp++; |
424 } |
424 } |
425 /* make ZeroPosition-based */ |
425 /* make ZeroPosition-based */ |
426 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
426 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
427 __INST(position) = __mkSmallInteger(pos); |
427 __INST(position) = __mkSmallInteger(pos); |
428 RETURN (__mkSmallInteger(val)); |
428 RETURN (__mkSmallInteger(val)); |
429 } |
429 } |
430 oops: |
430 oops: |
431 value = __mkSmallInteger(val); |
431 value = __mkSmallInteger(val); |
432 %} |
432 %} |
433 . |
433 . |
435 above primitive left off, in case of a large integer ... |
435 above primitive left off, in case of a large integer ... |
436 (instead of doing a super nextDecimalInteger)" |
436 (instead of doing a super nextDecimalInteger)" |
437 |
437 |
438 nextOne := self peek. |
438 nextOne := self peek. |
439 [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[ |
439 [nextOne notNil and:[nextOne isDigitRadix:10]] whileTrue:[ |
440 value = (value * 10) + nextOne digitValue. |
440 value := (value * 10) + nextOne digitValue. |
441 nextOne := self nextPeek |
441 nextOne := self nextPeek |
442 ]. |
442 ]. |
443 ^ value |
443 ^ value |
444 ! |
444 ! |
445 |
445 |
446 nextOrNil |
446 nextOrNil |
648 |
648 |
649 coll = __INST(collection); |
649 coll = __INST(collection); |
650 p = __INST(position); |
650 p = __INST(position); |
651 l = __INST(readLimit); |
651 l = __INST(readLimit); |
652 |
652 |
653 if (__isString(coll) && __bothSmallInteger(p, l)) { |
653 if (__isStringLike(coll) && __bothSmallInteger(p, l)) { |
654 REGISTER unsigned char *chars; |
654 REGISTER unsigned char *chars; |
655 REGISTER unsigned ch; |
655 REGISTER unsigned ch; |
656 REGISTER int pos; |
656 REGISTER int pos; |
657 int limit; |
657 int limit; |
658 int sz; |
658 int sz; |
659 |
659 |
660 pos = __intVal(p); |
660 pos = __intVal(p); |
661 /* make 1-based */ |
661 /* make 1-based */ |
662 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
662 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
663 if (pos <= 0) { |
663 if (pos <= 0) { |
664 RETURN ( nil ); |
664 RETURN ( nil ); |
665 } |
665 } |
666 |
666 |
667 limit = __intVal(l); |
667 limit = __intVal(l); |
668 sz = __qSize(coll) - OHDR_SIZE; |
668 sz = __qSize(coll) - OHDR_SIZE; |
669 if (limit > sz) { |
669 if (limit > sz) { |
670 limit = sz; |
670 limit = sz; |
671 } |
671 } |
672 |
672 |
673 chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
673 chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
674 while (pos <= limit) { |
674 while (pos <= limit) { |
675 pos++; |
675 pos++; |
676 ch = *chars++; |
676 ch = *chars++; |
677 if ((ch > 0x20) |
677 if ((ch > 0x20) |
678 || ((ch != ' ') |
678 || ((ch != ' ') |
679 && (ch != '\t') |
679 && (ch != '\t') |
680 && (ch != '\r') |
680 && (ch != '\r') |
681 && (ch != '\n') |
681 && (ch != '\n') |
682 && (ch != '\f') |
682 && (ch != '\f') |
683 && (ch != 0x0B))) { |
683 && (ch != 0x0B))) { |
684 /* make ZeroPosition-based */ |
684 /* make ZeroPosition-based */ |
685 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
685 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
686 __INST(position) = __mkSmallInteger(pos-1); |
686 __INST(position) = __mkSmallInteger(pos-1); |
687 RETURN ( __MKCHARACTER(ch) ); |
687 RETURN ( __MKCHARACTER(ch) ); |
688 } |
688 } |
689 } |
689 } |
690 /* make ZeroPosition-based */ |
690 /* make ZeroPosition-based */ |
691 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
691 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
692 __INST(position) = __mkSmallInteger(pos); |
692 __INST(position) = __mkSmallInteger(pos); |
693 RETURN ( nil ); |
693 RETURN ( nil ); |
694 } |
694 } |
695 %}. |
695 %}. |
696 ^ super skipSeparators |
696 ^ super skipSeparators |
697 |
697 |
698 " |
698 " |
715 |
715 |
716 coll = __INST(collection); |
716 coll = __INST(collection); |
717 p = __INST(position); |
717 p = __INST(position); |
718 l = __INST(readLimit); |
718 l = __INST(readLimit); |
719 |
719 |
720 if (__isString(coll) && __bothSmallInteger(p, l)) { |
720 if (__isStringLike(coll) && __bothSmallInteger(p, l)) { |
721 REGISTER unsigned char *chars; |
721 REGISTER unsigned char *chars; |
722 REGISTER unsigned ch; |
722 REGISTER unsigned ch; |
723 REGISTER int pos; |
723 REGISTER int pos; |
724 int limit; |
724 int limit; |
725 |
725 |
726 pos = __intVal(p); |
726 pos = __intVal(p); |
727 /* make 1-based */ |
727 /* make 1-based */ |
728 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
728 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
729 if (pos <= 0) { |
729 if (pos <= 0) { |
730 RETURN ( nil ); |
730 RETURN ( nil ); |
731 } |
731 } |
732 |
732 |
733 limit = __intVal(l); |
733 limit = __intVal(l); |
734 if (limit > (__qSize(coll) - OHDR_SIZE)) |
734 if (limit > (__qSize(coll) - OHDR_SIZE)) |
735 limit = __qSize(coll) - OHDR_SIZE; |
735 limit = __qSize(coll) - OHDR_SIZE; |
736 |
736 |
737 chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
737 chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
738 while (pos <= limit) { |
738 while (pos <= limit) { |
739 ch = *chars++; |
739 ch = *chars++; |
740 if (((int)ch > 0x20) |
740 if (((int)ch > 0x20) |
741 || ( |
741 || ( |
742 (ch != ' ') |
742 (ch != ' ') |
743 && (ch != '\t') |
743 && (ch != '\t') |
744 && (ch != '\f') |
744 && (ch != '\f') |
745 && (ch != '\b') |
745 && (ch != '\b') |
746 && (ch != 0x0B))) { |
746 && (ch != 0x0B))) { |
747 /* make ZeroPosition-based */ |
747 /* make ZeroPosition-based */ |
748 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
748 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
749 __INST(position) = __mkSmallInteger(pos); |
749 __INST(position) = __mkSmallInteger(pos); |
750 RETURN ( __MKCHARACTER(ch) ); |
750 RETURN ( __MKCHARACTER(ch) ); |
751 } |
751 } |
752 pos++; |
752 pos++; |
753 } |
753 } |
754 /* make ZeroPosition-based */ |
754 /* make ZeroPosition-based */ |
755 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
755 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
756 __INST(position) = __mkSmallInteger(pos); |
756 __INST(position) = __mkSmallInteger(pos); |
757 RETURN ( nil ); |
757 RETURN ( nil ); |
758 } |
758 } |
759 %} |
759 %} |
760 . |
760 . |
761 ^ super skipSeparatorsExceptCR |
761 ^ super skipSeparatorsExceptCR |
762 ! |
762 ! |
773 |
773 |
774 coll = __INST(collection); |
774 coll = __INST(collection); |
775 p = __INST(position); |
775 p = __INST(position); |
776 l = __INST(readLimit); |
776 l = __INST(readLimit); |
777 |
777 |
778 if (__isString(coll) |
778 if (__isStringLike(coll) |
779 && __isCharacter(anObject) |
779 && __isCharacter(anObject) |
780 && __bothSmallInteger(p, l)) { |
780 && __bothSmallInteger(p, l)) { |
781 REGISTER unsigned char *chars; |
781 REGISTER unsigned char *chars; |
782 REGISTER int pos, limit; |
782 REGISTER int pos, limit; |
783 unsigned ch; |
783 unsigned ch; |
784 int sz; |
784 int sz; |
785 |
785 |
786 pos = __intVal(p); |
786 pos = __intVal(p); |
787 /* make 1-based */ |
787 /* make 1-based */ |
788 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
788 pos = pos + 1 - __intVal( @global(PositionableStream:ZeroPosition)); |
789 if (pos <= 0) { |
789 if (pos <= 0) { |
790 RETURN ( nil ); |
790 RETURN ( nil ); |
791 } |
791 } |
792 |
792 |
793 limit = __intVal(l); |
793 limit = __intVal(l); |
794 sz = __stringSize(coll); |
794 sz = __stringSize(coll); |
795 if (limit > sz) limit = sz; |
795 if (limit > sz) limit = sz; |
796 |
796 |
797 chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
797 chars = (unsigned char *)(__stringVal(coll) + pos - 1); |
798 ch = __intVal(_characterVal(anObject)) & 0xFF; |
798 ch = __intVal(_characterVal(anObject)) & 0xFF; |
799 while (pos < limit) { |
799 while (pos < limit) { |
800 if (*chars == ch) { |
800 if (*chars == ch) { |
801 ch = *++chars; |
801 ch = *++chars; |
802 pos++; |
802 pos++; |
803 /* make ZeroPosition-based */ |
803 /* make ZeroPosition-based */ |
804 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
804 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
805 __INST(position) = __mkSmallInteger(pos); |
805 __INST(position) = __mkSmallInteger(pos); |
806 RETURN ( self ); |
806 RETURN ( self ); |
807 } |
807 } |
808 chars++; |
808 chars++; |
809 pos++; |
809 pos++; |
810 } |
810 } |
811 /* make ZeroPosition-based */ |
811 /* make ZeroPosition-based */ |
812 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
812 pos = pos - 1 + __intVal( @global(PositionableStream:ZeroPosition)); |
813 __INST(position) = __mkSmallInteger(pos+1); |
813 __INST(position) = __mkSmallInteger(pos+1); |
814 RETURN ( nil ); |
814 RETURN ( nil ); |
815 } |
815 } |
816 %}. |
816 %}. |
817 ^ super skipThrough:anObject |
817 ^ super skipThrough:anObject |
818 ! ! |
818 ! ! |
819 |
819 |