Skip to content

Commit 8ed8e05

Browse files
ti_Detect* should return all if NULL string
1 parent 61ba572 commit 8ed8e05

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/fileioc/fileioc.asm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,10 @@ _: ld (DetectType_SMC),a \.r
852852
add hl,de
853853
or a,a
854854
sbc hl,de
855-
jr z,finish
856-
ld hl,(ix+6)
855+
jr nz,+_ ; if null, then detect everything
856+
ld hl,fdetectall \.r
857+
ld (ix+9),hl
858+
_: ld hl,(ix+6)
857859
ld hl,(hl)
858860
add hl,bc
859861
or a,a
@@ -941,6 +943,9 @@ _: ld a,(hl)
941943
ld (de),a
942944
ret
943945

946+
fdetectall:
947+
.db 0
948+
944949
;-------------------------------------------------------------------------------
945950
_GetTokenString:
946951
; Returns pointer to next token string

src/fileioc/fileioc.h

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,39 @@ int ti_Close(const ti_var_t slot);
8686
* Returns the name of the file(s) that contains the string as the first part of the variable;
8787
* which can then be used with ti_Open and other functions
8888
*
89-
* seach_pos should be set to NULL to begin a search, and is then updated with each call
89+
* seach_pos should be set to NULL to begin a search, and is updated with each call
9090
*
9191
* @code
92-
* uint8_t *search_pos = NULL;
9392
* char *var_name;
94-
* while((var_name = ti_Detect( &search_pos, "my_data" )) != NULL) {
93+
* uint8_t *search_pos = NULL;
94+
* while((var_name = ti_Detect(&search_pos, "my_data")) != NULL) {
9595
* ...do something with the name or search_pos...
9696
* }
9797
* @endcode
98-
* @note If the return value is NULL, either the variable wasn't found in the current search span, or there are no more variables to find
99-
* @note If detection_string is NULL, return is NULL as well
98+
* @param curr_search_posistion Current offset in the VAT
99+
* @param detection_string String to search for (NULL to search for all)
100+
* @note If the return value is NULL, there are no more variables to find
100101
*/
101102
char *ti_Detect(void **curr_search_posistion, const char *detection_string);
103+
104+
/**
105+
* Returns the name of the file(s) that contains the string as the first part of the variable;
106+
* which can then be used with ti_OpenVar and other functions
107+
*
108+
* seach_pos should be set to NULL to begin a search, and is updated with each call
109+
*
110+
* @code
111+
* char *var_name;
112+
* uint8_t *search_pos = NULL;
113+
* while((var_name = ti_Detect(&search_pos, "my_data", TI_PRGM_TYPE)) != NULL) {
114+
* ...do something with the name or search_pos...
115+
* }
116+
* @endcode
117+
* @param curr_search_posistion Current offset in the VAT
118+
* @param detection_string String to search for (NULL to search for all)
119+
* @param var_type Type of variable to detect
120+
* @note If the return value is NULL, there are no more variables to find
121+
*/
102122
char *ti_DetectVar(void **curr_search_posistion, const char *detection_string, uint8_t var_type);
103123

104124
/**
@@ -416,3 +436,4 @@ equ_t *ti_AllocEqu(unsigned len, void (*malloc_routine)(size_t));
416436
#define ti_AppVar TI_APPVAR_TYPE
417437

418438
#endif
439+

0 commit comments

Comments
 (0)