LIBSTR LIBe%STR DOC1STRCAT AS `STRCAT OBJSTRCHR AS STRCHR OBJSTRCMP AS STRCMP OBJ!STRCMPI AS +STRCMPI OBJSTRCPY AS (STRCPY OBJ.STRCSPN C 1STRCSPN OBJŠSTRDUP AS @STRDUP OBJESTRLEN AS ^STRLEN OBJŽSTRLWR AS ISTRLWR OBJ2STRNCAT AS bSTRNCAT OBJZSTRNCMP AS LSTRNCMP OBJPSTRNCMPIAS RSTRNCMPIOBJ/STRNCPY AS \STRNCPY OBJŒSTRNSET AS CSTRNSET OBJSTRPBRK C STRPBRK OBJSTRRCHR AS GSTRRCHR OBJSTRREV AS "STRREV OBJ*STRSET AS NSTRSET OBJUSTRSPN C KSTRSPN OBJ4STRTOK C 6STRTOK OBJ<STRUPR AS &STRUPR OBJ3TOLWR AS VTOLWR OBJWTOUPR AS XTOUPR OBJYÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ psect text global rcsv, cret, _index, _strchr _strchr: _index: call rcsv jr 3f 1: inc hl 3: ld a,(hl) cp e 4: jp z,cret or a jr nz,1b ld hl,0 jr 4b  Z80textÍ#~»Ê· ÷!õ"rcsv "crettext=text_indextext_strchrcretrcsvunsigned char * strpbrk(s1, s2) register unsigned char *s1, *s2; { while (*s1) { if (strchr(s2, *s1)) return s1; ++s1; } return (unsigned char *)0; }  Z80textÍT]y°Ê·(ù{ ñ"rcsv"crettext,text_strnsetcretrcsv Z80*textÁáÑÕåÅ~ÍO͹ #· ï!É!Ð%É"tolwr "tolwrtext!text_strcmpitolwr psect text global _strcmp _strcmp: pop bc pop hl pop de push de push hl push bc 1: ld a,(de) cp (hl) jr nz,2f inc de inc hl or a jr nz,1b ld hl,0 ret 2: ld hl,1 ret nc dec h ret  Z80textÍ~» MD#· öi`Ã"rcsv"crettext?text_rindextext_strrchrcretrcsv Z80FtextÍ!9ùÝNÝFÅýáýn&åÝnÝf åÍÁÁ}´(ýåáÃý#ý~· Ü!Ã""csv!"_strchr-"cret;"crettextq_strchrtext_strpbrkcretcsvindir1textl2textl3/textl5 Z80"textÁáÑÕåž #· ÷!É!Ð%Étexttext_strcmp psect text global _strrev _strrev: pop de pop hl push hl push de push hl ;2 copies of start ptr push hl 1: ld a,(hl) or a jr z,2f inc hl jr 1b 2: pop de ;start ptr push hl sbc hl,de ;zero length string? pop hl jr nz,3f ;no sret: pop hl ;else return original ptr ret 3: dec hl push hl or a sbc hl,de ;end - start pop hl jr z,sret jr c,sret ld c,(hl) ld a,(de) ld (hl),a ld a,c ld (de),a inc de jr 3b end  psect text global _strupr, toupr _strupr: pop de pop hl push hl push de ld d,h ld e,l 1: ld a,(de) or a ret z call toupr ld (de),a inc de jr 1b  psect text global _strcpy _strcpy: pop bc pop hl pop de push de push hl push bc ld b,h ld c,l 1: ld a,(de) ld (bc),a inc de inc bc or a jr nz,1b ret  Z801textÑáåÕåå~·(#ùÑåíRá áÉ+å·íRá(ö8ôNwyîtext#text_strrevtextsret psect text global _strcmpi, tolwr _strcmpi: pop bc pop hl pop de push de push hl push bc 1: ld a,(hl) call tolwr ld c,a ld a,(de) call tolwr cp c jr nz,2f inc de inc hl or a jr nz,1b ld hl,0 ret 2: ld hl,1 ret nc dec h ret  Z80textÁáÑÕåÅDM· ùÉtexttext_strcpy Z802textÍy°( ~ÍO͹ #· ê!Ã!Ò%Ã2"rcsv "tolwr"tolwr"cret#"cret'"crettext9text_strcmpicretrcsvtolwrstrcspn(s1, s2) register unsigned char *s1, *s2; { int n = 0; while (!strchr(s2, *s1++)) ++n; } ETMEM OBJTIME Z80textÑáåÕT]·ÈÍö  "tolwrtext text_strlwrtolwr Z80textÑáåÕT]·ÈÍö  "touprtext text_struprtoupr Z80LtextÍÅÝNÝFÅýáÝ6þÝ6ÿ ÝnþÝfÿ#ÝuþÝtÿýåá#åýá+n&åÝnÝf åÍÁÁ}´ ×Ã"csv8"_strchrA"crettextb_strchrtext_strspncretcsvindir$textl2textl3unsigned char * strtok(srcstr, brkstr) register unsigned char *srcstr, *brkstr; { static unsigned char *p; unsigned char *p1; if (!srcstr) if (!p) return (unsigned char *)0; else srcstr = p; else p = srcstr; while (strchr(brkstr, *srcstr)) /* skip break characters */ ++srcstr; if (!*srcstr) return (unsigned char *)0; p1 = srcstr; /* p1 = first non-break char */ while (*srcstr) { /* skip to first break char */ if (strchr(brkstr, *srcstr)) { *srcstr = '\0'; p = srcstr+1; /* p = start of next token */ return p1; /* return start of this token */ } ++srcstr; } p = (unsigned char *)0; /* remember that this is last token */ return p1; }  Z80•textÍÅÝNÝFÅýáÅá}´ *}´ !Ãý*ý"ý#ýn&åÝnÝf åÍÁÁ}´ èý~·(ÐýåáÝuþÝtÿ,ýn&åÝnÝf åÍÁÁ}´(ý6ýåá#"ÝnþÝfÿÃý#ý~· Î!çI"csvbss"cret"bss(bss<"_strchrc"_strchrtbss}"cretbssbsstextÔbssF4textL1stextL2_strchrtext_strtokcretcsvindirtextl10Utextl11textl13&textl2 textl3.textl6,textl7 psect text global _strdup, _strlen, rcsv, cret _strdup: pop de pop hl push hl push de push hl call _strlen pop de push hl pop bc add hl,de ex de,hl ld a,c or b ret z push hl ldir ex de,hl ld (hl),0 pop hl ret  psect text global _strnset, rcsv, cret _strnset: call rcsv ld d,h ld e,l 1: ld a,c or b 2: jp z,cret ld a,(de) or a jr z,2b ld a,e ld (de),a inc de dec bc jr 1b  Z80!textÑáåÕåÍÑåÁëy°Èåí°ë6áÉ "_strlentext:text_strdup_strlencretrcsv psect text global rcsv, cret, _rindex, _strrchr _strrchr: _rindex: call rcsv ld bc,0 ;assume not found 1: ld a,(hl) cp e jr nz,2f ld c,l ld b,h 2: inc hl or a jr nz,1b ld l,c ld h,b jp cret  psect text global _strlwr, tolwr _strlwr: pop de pop hl push hl push de ld d,h ld e,l 1: ld a,(de) or a ret z call tolwr ld (de),a inc de jr 1b strspn(s1, s2) register unsigned char *s1, *s2; { int n = 0; while (strchr(s2, *s1++)) ++n; }  psect text global _strncmp, rcsv, cret _strncmp: call rcsv 1: ld a,c or b jr z,3f dec bc ld a,(de) cp (hl) jr nz,2f inc de inc hl or a jr nz,1b 3: ld hl,0 jp cret 2: ld hl,1 jp nc,cret dec h jp cret  psect text global _strset, rcsv, cret _strset: call rcsv ld d,h ld e,l 1: ld a,(de) or a jp z,cret ld a,e ld (de),a inc de jr 1b  Z80*textÍy°( ¾ #· ò!Ã!Ò%à "rcsv"cret"cret"crettext,text_strncmpcretrcsv psect text global _strcmpi, tolwr, rcsv, cret _strcmpi: call rcsv 1: ld a,c or b jr z,3f dec bc ld a,(hl) call tolwr ld c,a ld a,(de) call tolwr cp c jr nz,2f inc de inc hl or a jr nz,1b 3: ld hl,0 jp cret 2: ld hl,1 jp nc,cret dec h jp cret  Z80textÍT]·Ê{ö"rcsv"crettext+text_strsetcretrcsv psect text global tolwr tolwr: cp 'A' ret c cp 'Z'+1 ret nc add a,'a'-'A' ret  Z80textþAØþ[ÐÆ Étexttexttolwr psect text global toupr toupr: cp 'a' ret c cp 'z'+1 ret nc sub 'a'-'A' ret  Z80textþaØþ{ÐÖ Étexttexttoupr Z80&textÍå~·(#ùy°( w#· ô6áÃ"rcsv"crettext,text_strncatcretrcsv psect text global _strncpy, rcsv, cret _strncpy: call rcsv push hl 1: ld a,c or b jr z,2f dec bc ld a,(de) ld (hl),a inc de inc hl or a jr nz,1b 2: pop hl jp cret  psect text global _strlen _strlen: pop hl pop de push de push hl ld hl,0 1: ld a,(de) or a ret z inc hl inc de jr 1b  psect text global _strcat _strcat: pop bc pop hl pop de push de push hl push bc ld b,h ld c,l 1: ld a,(bc) or a jr z,2f inc bc jr 1b 2: ld a,(de) ld (bc),a or a ret z inc de inc bc jr 2b  psect text global _strncat, rcsv, cret _strncat: call rcsv push hl 1: ld a,(hl) or a jr z,2f inc hl jr 1b 2: ld a,c or b jr z,3f dec bc ld a,(de) ld (hl),a inc de inc hl or a jr nz,2b 3: ld (hl),0 pop hl jp cret û”STRCHR.OBJ_index_strchrcretrcsv„STRNSET.OBJ_strnsetcretrcsvˆSTRCMPI.OBJ_strcmpitolwr˜STRRCHR.OBJ_rindex_strrchrcretrcsv%STRPBRK.OBJ_strchr_strpbrkcretcsvindir ]STRCMP.OBJ_strcmp |STRREV.OBJ_strrev TSTRCPY.OBJ_strcpyÈSTRNCMPI.OBJ_strcmpicretrcsvtolwrmSTRLWR.OBJ_strlwrtolwrmSTRUPR.OBJ_struprtoupr$óSTRSPN.OBJ_strchr_strspncretcsvindir$ñSTRTOK.OBJ_strchr_strtokcretcsvindir‘STRDUP.OBJ_strdup_strlencretrcsv¡STRNCMP.OBJ_strncmpcretrcsv~STRSET.OBJ_strsetcretrcsvKTOLWR.OBJtolwrKTOUPR.OBJtouprSTRNCAT.OBJ_strncatcretrcsv%ôSTRCSPN.OBJ_strchr_strcspncretcsvindir„STRNCPY.OBJ_strncpycretrcsv RSTRLEN.OBJ_strlen [STRCAT.OBJ_strcat Z80textÍ#~»Ê· ÷!õ"rcsv "crettext=text_indextext_strchrcretrcsv Z80textÍT]y°Ê·(ù{ ñ"rcsv"crettext,text_strnsetcretrcsv Z80*textÁáÑÕåÅ~ÍO͹ #· ï!É!Ð%É"tolwr "tolwrtext!text_strcmpitolwr Z80textÍ~» MD#· öi`Ã"rcsv"crettext?text_rindextext_strrchrcretrcsv Z80FtextÍ!9ùÝNÝFÅýáýn&åÝnÝf åÍÁÁ}´(ýåáÃý#ý~· Ü!Ã""csv!"_strchr-"cret;"crettextq_strchrtext_strpbrkcretcsvindir1textl2textl3/textl5 Z80"textÁáÑÕåž #· ÷!É!Ð%Étexttext_strcmp Z801textÑáåÕåå~·(#ùÑåíRá áÉ+å·íRá(ö8ôNwyîtext#text_strrevtextsret Z80textÁáÑÕåÅDM· ùÉtexttext_strcpy Z802textÍy°( ~ÍO͹ #· ê!Ã!Ò%Ã2"rcsv "tolwr"tolwr"cret#"cret'"crettext9text_strcmpicretrcsvtolwr Z80textÑáåÕT]·ÈÍö  "tolwrtext text_strlwrtolwr Z80textÑáåÕT]·ÈÍö  "touprtext text_struprtoupr Z80LtextÍÅÝNÝFÅýáÝ6þÝ6ÿ ÝnþÝfÿ#ÝuþÝtÿýåá#åýá+n&åÝnÝf åÍÁÁ}´ ×Ã"csv8"_strchrA"crettextb_strchrtext_strspncretcsvindir$textl2textl3 Z80•textÍÅÝNÝFÅýáÅá}´ *}´ !Ãý*ý"ý#ýn&åÝnÝf åÍÁÁ}´ èý~·(ÐýåáÝuþÝtÿ,ýn&åÝnÝf åÍÁÁ}´(ý6ýåá#"ÝnþÝfÿÃý#ý~· Î!çI"csvbss"cret"bss(bss<"_strchrc"_strchrtbss}"cretbssbsstextÔbssF4textL1stextL2_strchrtext_strtokcretcsvindirtextl10Utextl11textl13&textl2 textl3.textl6,textl7 Z80!textÑáåÕåÍÑåÁëy°Èåí°ë6áÉ "_strlentext:text_strdup_strlencretrcsv Z80*textÍy°( ¾ #· ò!Ã!Ò%à "rcsv"cret"cret"crettext,text_strncmpcretrcsv Z80textÍT]·Ê{ö"rcsv"crettext+text_strsetcretrcsv Z80textþAØþ[ÐÆ Étexttexttolwr Z80textþaØþ{ÐÖ Étexttexttoupr Z80&textÍå~·(#ùy°( w#· ô6áÃ"rcsv"crettext,text_strncatcretrcsv Z80LtextÍÅÝNÝFÅýáÝ6þÝ6ÿ ÝnþÝfÿ#ÝuþÝtÿýåá#åýá+n&åÝnÝf åÍÁÁ}´(×Ã"csv8"_strchrA"crettextc_strchrtext_strcspncretcsvindir$textl2textl3 Z80textÍåy°( w#· ôáÃ"rcsv"crettext,text_strncpycretrcsv Z80textáÑÕå!·È#ùtexttext_strlen Z80 textÁáÑÕåÅDM ·(ù·Èøtexttext_strcat Z80LtextÍÅÝNÝFÅýáÝ6þÝ6ÿ ÝnþÝfÿ#ÝuþÝtÿýåá#åýá+n&åÝnÝf åÍÁÁ}´(×Ã"csv8"_strchrA"crettextc_strchrtext_strcspncretcsvindir$textl2textl3 Z80textÍåy°( w#· ôáÃ"rcsv"crettext,text_strncpycretrcsv Z80textáÑÕå!·È#ùtexttext_strlen Z80 textÁáÑÕåÅDM ·(ù·Èøtexttext_strcat STRINÇ LIBARAÙ FOÒ HI-TECÈ C V1.0 by Mikå Thompson Thió  distributioî containó twentù onå à functionó  foò  handlinç stringó  undeò thå HÉ-TECÈ Ã compiler® Somå oæ thå functionó  arå direcô  replacementó foò thoså founä iî LIBC.LIB¬ whilå  mosô  oæ thå  otheró  arå UNIØ anä ANSÉ standarä à strinç  functions®  Thå remaininç  functionó  arå  obviouó  enhancementó  tï  anù  strinç librarù  anä arå borroweä froí à compileò librarieó founä oî  thå XENIØ  operatinç system® Á completå descriptioî oæ eacè  functioî anä  itó  origiî ió giveî below® Iî ordeò tï savå mucè  typinç  É havå  abbreviateä thå functioî descriptionó bù noô  defininç  thå argumenô types® However¬ É havå giveî eacè argumenô á namå  whicè arå defineä aó follows:- chaò *s» ­ strinç argumenô (onlù one) chaò *s1» ­ firsô strinç argument     chaò *s2» ­ seconä strinç argument chaò c» ­ characteò argument inô n» ­ specifieó maø numbeò oæ characteró tï process Iî thå ORIGIÎ columî thå followinç functioî originó arå used:- ANSÉ ­ Standarä ANSÉ Ã function. UNIØ ­ Standarä UNIØ Ã function. XENIX ­ Standarä XENIØ Ã function. NONÅ ­ Nï origin® Functionó thaô É havå implemented. Thå descriptioî belo÷ ió divideä bù blanë lineó intï functionallù associateä functions. SYNOPSIS FUNCTIOÎ ORIGIN chaò ªstrcat(s1¬ s2© ANSI chaò *strncat(s1¬ s2¬ n© ANSI chaò *strchr(s¬ c© ANSI chaò *strrchr(s¬ c© ANSI inô strcmp(s1¬ s2© ANSI inô strncmp(s1¬ s2¬ n© ANSI inô strcmpi(s1¬ s2© XENIX inô strncmpi(s1¬ s2¬ n© NONE chaò *strcpy(s1¬ s2© ANSI chaò *strncpy(s1¬ s2¬ n© ANSI Š      int strspn(s1, s2) UNIX      int strcspn(s1, s2) ANSI      char *strlwr(s) XENIX      char *strupr(s) XENIX      char *strset(s, c) XENIX      char *strnset(s, c, n) XENIX      char *strdup(s) XENIX      int strlen(s) ANSI      char *strpbrk(s1, s2) UNIX      char *strrev(s) XENIX      char *strtok(s1, s2) ANSI DESCRIPTION      Strcaô  appendó á copù oæ strinç s² tï thå enä oæ strinç s1®      Strncaô copieó aô mosô î characters® Iô copieó lesó iæ s² ió      shorteò  thaî  î characters®  Botè returî á pointeò  tï  thå      null-terminated result (the original value of s1).      Strchò  (strrchr©  returnó  á pointeò tï  thå  firsô  (last©      occurrencå oæ characteò ã iî strinç s¬ oò NULÌ iæ ã doeó noô      occuò iî thå string® Thå nulì characteò terminatinç á strinç      ió considereä tï bå parô oæ thå string®  Strchò (strrchr© ió      thå  samå  aó indeø (rindex© founä iî manù oldeò  libraries®      Indeø (rindex© caî stilì bå useä sï thaô olä programó maù bå      compileä witè nï modification.      Strcmð compareó itó argumentó anä returnó aî integeò greateò      than¬  equaì  to¬  oò  lesó  thaî  0¬  accordinç  aó  s±  ió      lexicographicallù  greateò than¬ equaì to¬ oò lesó thaî  s2®      Strncmð  makeó  thå samå comparisoî buô lookó aô aô  mosô  î      characteró  (î equaì tï zerï implieó equality)® Strcmpé  anä      strncmpé  arå  thå samå aó strcmð anä  strncmð  respectivly¬      excepô  thaô  thå caså oæ thå characteró beinç  compareä  ió      ignored®  Alì  oæ  theså  routineó  uså  unsigneä  chaò  foò      characteò comparison.      Strcpù  copieó  strinç  s² tï s1¬ stoppinç  afteò  thå  nulì      characteò   haó  beeî  moved®  Strncpù  copieó   exactlù   î      characters¬ truncatinç oò nuì-paddinç s2» thå targeô maù noô      bå  nulì-terminateä iæ thå lengtè oæ s² ió î oò  more®  Botè      returî s1.      Strspî  (strcspn© returnó thå lengtè oæ thå initiaì  segmenô      oæ strinç s± whicè consistó entirelù oæ characteró froí (noô      from© strinç s2. Š     Strupò  (strlwr© convertó eacè characteò iî thå strinç ó  tï      uppeò (lower© caså anä returnó itó argument.      Strseô  copieó  thå characteò ã intï eacè  positioî  iî  thå      strinç  s¬  stoppinç  wheî  thå  nulì-terminatoò  iî  ó   ió      encountered®  Strnseô  copieó  aô mosô  î  characters®  Botè      routineó returî theiò argument.      Strduð  appendó  thå  strinç ó tï itself®  Notå  thaô  usinç      strcaô  tï  dï thå samå thinç maù noô worë  sincå  thå  nulì      terminatoò  iî strinç ó ió ofteî immediatelù overwritteî  bù      thå  firsô  characteò  oæ s¬ thuó  causinç  á  fataì  error¬      becauså  thå  enä  oæ thå strinç ó ió  neveò  found®  Strduð      returnó itó argument.      Strleî returnó thå numbeò oæ noî-nulì characteró iî s®  (Thå      "length¢ oæ á strinç doeó noô counô thå nulì terminator.)      Strpbrë returnó á pointeò tï thå firsô occurrencå iî  strinç      s± oæ anù characteò froí strinç s2¬ oò NULÌ iæ nï  characteò      froí s² existó iî s1.      Strreö reverseó thå strinç ó anä returnó itó argument.      Strtoë  considersthå strinç s± tï consisô oæ á  sequencå  oæ      zerï  oò morå texô tokensspperateä bù spanó oæ onå  oò  morå      characteró  froí  thå seperatoò strinç s2®  Thå  firsô  calì      (witè  pointeò s± specified© returnó á pointeò tï thå  firsô      characteò  oæ thå firsô token¬ anä wilì havå writteî á  NULÌ      characteò intï s± immediatelù followinç thå returneä  token®      Thå  functioî  keepó  tracë oæ itó positioî  iî  thå  strinç      betweeî seperatå calls¬ sï thaô subsequenô calló (whicè musô      bå  madå witè thå firsô argumenô á NULÌ pointer©  wilì  worë      througè thå strinç s± untiì nï tokenó remain® Thå  seperatoò      strinç s² maù bå differenô froí calì tï call® Wheî nï  tokeî      remainó  iî s± á NULÌ ió returned® Strtoë useó  á  staticllù      declareä  pointeò  tï keeð tracë oæ itó positioî iî  s1¬  sï      calló tï strtoë cannoô bå nested.