ADTast-experimentalpthread-emulation
Last change
on this file since dd33c1f was
789f279,
checked in by Thierry Delisle <tdelisle@…>, 2 years ago
|
More standard lib visibility
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[8157bde] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // range_iterator.cfa -- |
---|
| 8 | // |
---|
| 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Tue Nov 30 13:06:22 2021 |
---|
| 11 | // Last Modified By : |
---|
| 12 | // Last Modified On : |
---|
| 13 | // Update Count : |
---|
| 14 | // |
---|
| 15 | |
---|
[58b2638] | 16 | #include "range_iterator.hfa" |
---|
[8157bde] | 17 | |
---|
[58b2638] | 18 | #include <stdio.h> |
---|
[8157bde] | 19 | |
---|
[58b2638] | 20 | #include <fstream.hfa> |
---|
| 21 | |
---|
[789f279] | 22 | #include "bits/defs.hfa" |
---|
| 23 | |
---|
| 24 | void main(RangeIter & this) libcfa_public { |
---|
[8157bde] | 25 | for() { |
---|
| 26 | this._start = -1; |
---|
| 27 | this._stop = -1; |
---|
| 28 | int start_len = -1, stop_len = -1; |
---|
[58b2638] | 29 | int ret = sscanf(this.text, "%u%n-%u%n", &this._start, &start_len, &this._stop, &stop_len); |
---|
[8157bde] | 30 | switch(ret) { |
---|
| 31 | case 0: |
---|
| 32 | // Not a range, maybe a comma? |
---|
| 33 | if(this.text[0] == ',') { |
---|
| 34 | this.text ++; |
---|
| 35 | continue; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | serr | "Error: unexpected character in next range: '" | this.text |"'"; |
---|
| 39 | exit(2); |
---|
| 40 | case 1: |
---|
| 41 | this.text += start_len; |
---|
| 42 | // Only one value, push it! |
---|
| 43 | this.com = this._start; |
---|
| 44 | suspend; |
---|
| 45 | break; |
---|
| 46 | case 2: |
---|
| 47 | if(this._start > this._stop) { |
---|
| 48 | serr | "Error: next range out of order '" | this.text |"'"; |
---|
| 49 | exit(2); |
---|
| 50 | } |
---|
| 51 | this.text += stop_len; |
---|
[58b2638] | 52 | for(this.com = this._start; this.com <= this._stop; this.com++) { |
---|
[8157bde] | 53 | suspend; |
---|
| 54 | } |
---|
| 55 | break; |
---|
| 56 | default: |
---|
| 57 | serr | "Error reading next block: '" | this.text |"', returned" | ret; |
---|
| 58 | exit(2); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | if(this.text[0] == '\0') break; |
---|
| 62 | } |
---|
[8e658241] | 63 | this.com = -1; |
---|
[8157bde] | 64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.