<commit_before>;; strlen [Strings]
;;  Determines the length of a zero delimited string.
;; Inputs:
;;  HL: String pointer
;; Outputs:
;;  BC: String length
strlen:
    push af
    push hl
        xor a
        ld b, a
        ld c, a
        cpir
        ; bc = -bc
        xor a \ sub c \ ld c, a \ sbc a, a \ sub b \ ld b, a
        dec bc
    pop hl
    pop af
    ret
    
;; strcmp [Strings]
;;  Determines if two strings are equal, and checks alphabetical sort order.
;; Inputs:
;;  HL: String pointer
;;  DE: String pointer
;; Outputs:
;;  Z: Set if equal, reset if not equal
;;  C: Set if string HL is alphabetically earlier than string DE
strcmp:
    ld a, (de)
    or a
    jr z, .end
    cp (hl)
    jr nz, .exit
    inc hl
    inc de
    jr strcmp
.end:
    ld a, (hl)
    or a
.exit:
    ccf
    ret
    
;; strcmp_sort [Strings]
;;  Compares strings at ((HL)) and ((DE)).  That is, calls indirect16HLDE,
;;  then calls strcmp.
;; Inputs:
;;  HL: Pointer to string pointer
;;  DE: Pointer to string pointer
;; Outputs:
;;  Z: Set if equal, reset if not equal
;;  C: Set if string (HL) is alphabetically earlier than string (DE)
;; Notes:
;;  This routine is extremely useful as the callback for the [[callbackSort]] routine.
;;  It allows sorting a list of pointers to strings by the strings' sort order.
strcmp_sort:
    push hl
    push de
        call indirect16HLDE
        call strcmp
_:  pop de
    pop hl
    ret
    
;; strcpy [Strings]
;;  Copies a string.
;; Inputs:
;;  HL: String pointer
;;  DE: Destination
strcpy:
    push de
    push hl
    ex de, hl
_:  ld a, (de)
    ld (hl), a
    or a
    jr z, _
    inc hl \ inc de
    jr -_
_:  pop de
    pop hl
    ret
    
;; strchr [Strings]
;;  Returns a pointer on the first occurence of a character in a string.
;; Inputs:
;;  HL: string pointer
;;  B: character to search
;; Outputs:
;;  HL: pointer on first occurence of character in string in case of success
;;  Z: set if character found
;; Notes:
;;  Destroys A
strchr:
.loop:
    ld a, (hl)
    or a
    jr z, .noCharFound
    cp b
    ret z
    inc hl
    jr .loop
.noCharFound:
    inc a
    ret
    
;; strtoi [Strings]
;;  Converts an ASCII-encoded unsigned decimal into a word of variable size.
;; Inputs:
;;  HL: pointer on ASCII-encoded decimal
;;  B: maximum number of digits to convert
;; Outputs:
;;  DEHL: converted word
;;  Z: set on success, reset on error
;; Notes:
;;  The routine will ignore leading zeroes to produce a number composed by a 
;;  maximum of 10 digits, the maximal value being 4,294,967,295. If a 10-digits
;;  number with a greater value is encountered, no error will be thrown but the
;;  number won't be converted as expected.
;;  Besides, the routine supports negative numbers that starts with the character '-'.<commit_msg>Fix strtoi documentation<commit_after>;; strlen [Strings]
;;  Determines the length of a zero delimited string.
;; Inputs:
;;  HL: String pointer
;; Outputs:
;;  BC: String length
strlen:
    push af
    push hl
        xor a
        ld b, a
        ld c, a
        cpir
        ; bc = -bc
        xor a \ sub c \ ld c, a \ sbc a, a \ sub b \ ld b, a
        dec bc
    pop hl
    pop af
    ret
    
;; strcmp [Strings]
;;  Determines if two strings are equal, and checks alphabetical sort order.
;; Inputs:
;;  HL: String pointer
;;  DE: String pointer
;; Outputs:
;;  Z: Set if equal, reset if not equal
;;  C: Set if string HL is alphabetically earlier than string DE
strcmp:
    ld a, (de)
    or a
    jr z, .end
    cp (hl)
    jr nz, .exit
    inc hl
    inc de
    jr strcmp
.end:
    ld a, (hl)
    or a
.exit:
    ccf
    ret
    
;; strcmp_sort [Strings]
;;  Compares strings at ((HL)) and ((DE)).  That is, calls indirect16HLDE,
;;  then calls strcmp.
;; Inputs:
;;  HL: Pointer to string pointer
;;  DE: Pointer to string pointer
;; Outputs:
;;  Z: Set if equal, reset if not equal
;;  C: Set if string (HL) is alphabetically earlier than string (DE)
;; Notes:
;;  This routine is extremely useful as the callback for the [[callbackSort]] routine.
;;  It allows sorting a list of pointers to strings by the strings' sort order.
strcmp_sort:
    push hl
    push de
        call indirect16HLDE
        call strcmp
_:  pop de
    pop hl
    ret
    
;; strcpy [Strings]
;;  Copies a string.
;; Inputs:
;;  HL: String pointer
;;  DE: Destination
strcpy:
    push de
    push hl
    ex de, hl
_:  ld a, (de)
    ld (hl), a
    or a
    jr z, _
    inc hl \ inc de
    jr -_
_:  pop de
    pop hl
    ret
    
;; strchr [Strings]
;;  Returns a pointer on the first occurence of a character in a string.
;; Inputs:
;;  HL: string pointer
;;  B: character to search
;; Outputs:
;;  HL: pointer on first occurence of character in string in case of success
;;  Z: set if character found
;; Notes:
;;  Destroys A
strchr:
.loop:
    ld a, (hl)
    or a
    jr z, .noCharFound
    cp b
    ret z
    inc hl
    jr .loop
.noCharFound:
    inc a
    ret
    
;; strtoi [Strings]
;;  Converts an ASCII-encoded signed decimal into a word of variable size.
;; Inputs:
;;  HL: pointer on ASCII-encoded decimal
;;  B: maximum number of digits to convert
;; Outputs:
;;  DEHL: converted word
;;  Z: set on success, reset on error
;; Notes:
;;  The routine will ignore leading zeroes to produce a number composed by a 
;;  maximum of 10 digits, the maximal value being 4,294,967,295. If a 10-digits
;;  number with a greater value is encountered, no error will be thrown but the
;;  number won't be converted as expected.
;;  Besides, the routine supports negative numbers that starts with the character '-'.
{'fraction_non_alphanumeric': 0.09440371893438226, 'fraction_numerical': 0.006436617200071518, 'mean_word_length': 2.4509561998766194, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4468257', 'n_tokens_mistral': 1935, 'n_tokens_neox': 1844, 'n_words': 828}