home *** CD-ROM | disk | FTP | other *** search
- .he spltscan.doc
- Character handling functions similar to those in Honeywell's TEX.
-
- 1. split(instring,col,starl,starr)
- 2. splitr(instring,col,starl,starr)
- 3. match=scan(instring,pat,starl,starm,starr)
- 4. match=scann(instring,pat,starl,starm,starr)
- 5. match=scanr(instring,pat,starl,starm,starr)
- 6. match=scannr(instring,pat,starl,starm,starr)
-
- General notes:
-
- instring is the input string to be split or scanned.
- It must be terminated by '\0'.
- starl,starm and starr are output strings. They
- will be terminated by '\0'.
- col, input to split and splitr, is an integer.
- pat, input to the scan functions, is the pattern to
- be matched and must be terminated by '\0'. If
- pat's first character is '_' (CLASC), then it
- indicates a class match instead of a literal
- match. The classes available are:
- _a alphabetic. 52 ascii upper and lower.
- _n numeric. digits 0-9.
- _an alphanumeric. 52 alpha and the 10 digits.
- _lc lower case. 26 ascii lower case alpha.
- _uc upper case. 26 ascii upper case alpha.
- match, output by scan functions, is 0 (FALSE) or 1 (TRUE).
-
- Specific details on each function follow.
- .pa
- è1. split(instring,col,starl,starr)
-
- normal case
- 0 < col <= strlen(instring)
- starl will contain the leftmost col characters
- of instring. starr will contain the rest.
-
- special cases
- (a) if instring is null (instring[0]=='\0')
- then starl and starr will be null.
- (b) if col>strlen(instring) then starl will
- contain all of instring and starr will be null.
- (c) if col <=0 then starr will contain all of
- instring and starl will be null.
-
-
- 2. splitr(instring,col,starl,starr)
-
- normal case
- 0 < col <= strlen(instring)
- starr will contain the rightmost col characters
- of instring. starl will contain the rest.
-
- special cases
- (a) if instring is null, then starl and starr will be
- null.
- (b) if col>strlen(instring), then starr will contain
- all of instring and starl will be null.
- (c) if col<=0 then starr will be null and starl
- will contain all of instring.
- .pa
- è3. match=scan(instring,pat,starl,starm,starr)
-
- normal case: where pat is a string
- ááááááááááIµáá pa⌠á i≤á iεá instring¼áá star∞á wil∞á contaiεá thσ ì
- áááááááááácharacter≤ t∩ thσ lef⌠ oµ it¼á starφ wil∞ contaiεá pat¼ ì
- áááááááááástar≥á wil∞á contaiε thσ character≤ t∩ thσ righ⌠ oµá i⌠ ì
- ááááááááááanΣ matcΦ wil∞ bσ ▒ (TRUE)«á Iµ pa⌠ isn'⌠ iε instring¼ ì
- áááááááááástar∞á wil∞ contaiε instring¼á starφ anΣ star≥ wil∞á bσ ì
- áááááááááánull and match will be 0 (FALSE).
-
- normal case: where pat is a class
- ááááááááááIµá aε occurrencσ oµ thσ clas≤ i≤á iεá instring¼á star∞ ì
- ááááááááááwil∞á contaiεá thσ character≤ t∩ thσ lef⌠ oµ thσá firs⌠ ì
- ááááááááááoccurrence¼á starφ wil∞ bσ null¼ star≥ wil∞ contaiε thσ ì
- áááááááááárest¼á anΣ matcΦ wil∞ bσ ░ (FALSE)« Iµ therσ isn'⌠ an∙ ì
- ááááááááááoccurrencσ oµ thσ clas≤ iε instring¼ star∞ wil∞ contaiε ì
- ááááááááááinstring¼á starφ anΣ star≥ wil∞ bσ nul∞ anΣ matcΦá wil∞ ì
- áááááááááábe 0 (FALSE).
-
- special cases
- (a) if instring is null, starl, starm and starr will
- be null and match will be 0 (FALSE).
- (b) if pat is null and instring isn't null, starl
- will contain instring, starm and starr will be
- null and match will be 0 (FALSE).
- .pa
- è4. match=scann(instring,pat,starl,starm,starr)
-
- normal case: where pat is a string
- áááááááááápa⌠ mus⌠ bσ ß singlσ character« Iµ pa⌠ i≤ iε instring║ ì
- áááááááááástar∞á wil∞á contaiεá an∙ leadinτ occurrence≤á oµá pat¼ ì
- áááááááááástarφá wil∞á bσ null¼á star≥ wil∞ contaiε thσá res⌠á oµ ì
- ááááááááááinstrinτá anΣ matcΦ wil∞ bσ ▒ (TRUE⌐ iµ star≥á i≤á nul∞ ì
- áááááááááá(e.g«á iµá eacΦá oµ thσ character≤ oµ instrinτá matche≤ ì
- áááááááááápat⌐á anΣá ░á (FALSE⌐á otherwise«áá Iµá pa⌠á isn'⌠á iε ì
- ááááááááááinstring║á star∞á anΣ starφ wil∞ bσ null¼á star≥á wil∞ ì
- áááááááááácontain instring and match will be 0 (FALSE).
-
- normal case: where pat is a class
- ááááááááááIµ instrinτ contain≤ aε occurrencσ oµ thσá class¼á theε ì
- áááááááááástar∞á wil∞á contaiεá al∞ leadinτá occurrence≤á oµá thσ ì
- ááááááááááclass¼á starφ wil∞ bσ null¼ star≥ wil∞ contaiε thσ res⌠ ì
- ááááááááááoµá instring¼á anΣá matcΦ wil∞ bσ ▒ (TRUE⌐ iµ star≥á i≤ ì
- áááááááááánul∞á (e.g«á iµá al∞ character≤ oµ instrinτá matcΦá thσ ì
- ááááááááááclass⌐á anΣ ░ (FALSE⌐ otherwise«á Iµ instrinτá doesn'⌠ ì
- áááááááááácontaiεá an∙ occurrencσ oµ thσ class¼á star∞ anΣá starφ ì
- ááááááááááwil∞á bσ null¼á star≥ wil∞ contaiε instrinτá anΣá matcΦ ì
- ááááááááááwill be 0 (FALSE).
-
- special cases
- (a) If instring and/or pat is null, starl, starm
- and starr will be null. match will be 0 (FALSE).
- In contrast, TEX considers it an error if pat is
- null here and doesn't bother to return any
- values (it just issues the warning message).
- .pa
- è5. match=scanr(instring,pat,starl,starm,starr)
-
- normal case: where pat is a string
- ááááááááááIµ pa⌠ i≤ iε instring¼ star∞ wil∞ contaiε character≤ t∩ ì
- ááááááááááthσ lef⌠ oµ pat¼á starφ wil∞ contaiε pa⌠ anΣ star≥ wil∞ ì
- áááááááááácontaiε character≤ t∩ thσ righ⌠ oµ pat¼á anΣ matcΦ wil∞ ì
- áááááááááábσ ▒ (TRUE)« Iµ pa⌠ isn'⌠ iε instring¼ star∞ anΣ starφ ì
- ááááááááááwil∞á bσá null¼á star≥ wil∞ contaiε instrinτ anΣá matcΦ ì
- ááááááááááwill be 0 (FALSE).
-
- normal case: where pat is a class
- ááááááááááIµ instrinτ contain≤ aε occurrencσ oµ thσ class¼á star∞ ì
- ááááááááááwil∞ contaiε thσ rightmos⌠ occurrencσ oµ thσ clas≤á anΣ ì
- ááááááááááan∙á character≤ t∩ thσ lef⌠ oµ it¼á starφ wil∞ bσ null¼ ì
- áááááááááástar≥ wil∞ contaiε thσ res⌠ oµ instrinτ anΣ matcΦá wil∞ ì
- áááááááááábσáá ▒á (TRUE)«áá Iµá instrinτá doesn'⌠á contaiεáá an∙ ì
- ááááááááááoccurrencσ oµ thσ class¼á star∞ anΣ starφ wil∞ bσ null¼ ì
- áááááááááástar≥á wil∞á contaiεá instrinτá anΣá matcΦá wil∞á bσá ░ ì
- áááááááááá(FALSE).
-
- special cases
- (a) If instring is null, then starl, starm and starr
- will be null. match will be 0 (FALSE).
- (b) If pat is null and instring isn't, then starl
- and starm will be null. starr will contain
- instring and match will be 0 (FALSE).
- .pa
- è6. match=scannr(instring,pat,starl,starm,starr)
-
- normal case: where pat is a string
- áááááááááápa⌠ mus⌠ bσ ß singlσ character« Iµ pa⌠ i≤ iε instring¼ ì
- áááááááááástar∞ wil∞ contaiε thσ rightmos⌠ characte≥ tha⌠ doesn'⌠ ì
- áááááááááámatcΦá pa⌠ anΣ al∞ character≤ t∩ thσ lef⌠ oµ it¼á starφ ì
- ááááááááááwil∞á bσá null¼á anΣá star≥ wil∞ contaiεá thσá res⌠á oµ ì
- ááááááááááinstring«á matcΦ wil∞ bσ ▒ (TRUE⌐ iµ star≥ isn'⌠á nul∞ ì
- áááááááááá(e.g« iµ al∞ thσ character≤ oµ instrinτ matcΦ pat)¼ anΣ ì
- áááááááááá░ (FALSE⌐ iµ star≥ i≤ null«á Iµ pa⌠ isn'⌠ iε instring¼ ì
- áááááááááástar∞á wil∞ contaiε instring¼á starφ anΣ star≥ wil∞á bσ ì
- áááááááááánull and match will be 0 (FALSE).
-
- normal case: where pat is a class
- ááááááááááIµ instrinτ contain≤ aε occurrencσ oµ thσ class¼á star∞ ì
- ááááááááááwil∞ contaiε thσ rightmos⌠ characte≥ tha⌠ doesn'⌠ matcΦ ì
- ááááááááááthσ clas≤ anΣ al∞ character≤ t∩ thσ lef⌠ oµ it«á starφ ì
- ááááááááááwil∞ bσ null¼á star≥ wil∞ contaiε thσ res⌠ oµ instring« ì
- ááááááááááIµá star≥á isn'⌠ nul∞ (e.g«á iµ al∞ thσá character≤á oµ ì
- ááááááááááinstrinτá matcΦ thσ class⌐ theε matcΦ wil∞ bσ ▒ (TRUE)« ì
- ááááááááááIµ star≥ i≤ null¼ matcΦ wil∞ bσ ░ (FALSE)« Iµ instrinτ ì
- áááááááááádoesn'⌠ contaiε an∙ occurrencσ oµ thσ class¼ star∞ wil∞ ì
- áááááááááácontaiεá instring¼á starφá anΣ star≥ wil∞ bσá nul∞á anΣ ì
- áááááááááámatch will be 0 (FALSE).
-
- special cases
- ááááááááááIµ instriε and/o≥ pa⌠ i≤ null¼á starl¼á starφ anΣ star≥ ì
- ááááááááááwil∞ bσ null«á matcΦ wil∞ bσ ░ (FALSE)«á Iε contrast¼ ì
- ááááááááááTE╪á consider≤ i⌠ aε erro≥ iµ pa⌠ i≤ nul∞ anΣ issue≤á ß ì
- áááááááááámessage without bothering to set any variables.