diff --git a/programs/develop/libraries/libs-dev/.test/001/test001.asm b/programs/develop/libraries/libs-dev/.test/001/test001.asm index 08724e6d93..13aa0e42a7 100644 --- a/programs/develop/libraries/libs-dev/.test/001/test001.asm +++ b/programs/develop/libraries/libs-dev/.test/001/test001.asm @@ -74,8 +74,6 @@ endp s_key1 db "LeftViewMode",0 s_key2 db "RightViewMode",0 -s_null db "",0 - macro wildcard_test_data label1, label2, label3, [str1, str2, res] { common @@ -170,10 +168,10 @@ START: mov dword[buf],'103' invoke ini.set_str,s_ini,s_sec,s_key2,buf,3 - invoke ini.get_str,s_ini,s_sec,s_key1,buf,1024,s_null + invoke ini.get_str,s_ini,s_sec,s_key1,buf,1024,0 cmp dword[buf],'102' jne exit - invoke ini.get_str,s_ini,s_sec,s_key2,buf,1024,s_null + invoke ini.get_str,s_ini,s_sec,s_key2,buf,1024,0 cmp dword[buf],'103' jne exit diff --git a/programs/develop/libraries/libs-dev/libini/libini.asm b/programs/develop/libraries/libs-dev/libini/libini.asm index d64fd154a3..61bd42545b 100644 --- a/programs/develop/libraries/libs-dev/libini/libini.asm +++ b/programs/develop/libraries/libs-dev/libini/libini.asm @@ -17,6 +17,12 @@ ;; ;; ;;================================================================================================;; ;; ;; +;; 2009-03-08 (mike.dld) ;; +;; bug-fixes: ;; +;; - moved buffer bound check in libini._.low.read_value up (reported by Insolor) ;; +;; new features: ;; +;; - comments support (char is ini.COMMENT_CHAR, defaults to ';') ;; +;; inline comments are not supported ;; ;; 2008-12-29 (mike.dld) ;; ;; bug-fixes: ;; ;; - unnecessary 'stosb' in ini.get_str was causing problems ;; @@ -117,8 +123,6 @@ endl stdcall libini._.get_char, [f_addr] stdcall libini._.skip_spaces, [f_addr] -; inc esi -; dec [f.cnt] mov edi, [sec_buf] @@: stdcall libini._.get_char, [f_addr] cmp al, ']' @@ -385,7 +389,6 @@ endl .modify_key.ex: invoke file.tell, [f.fh] sub eax, [f.cnt] -; dec eax invoke file.seek, [f.fh], eax, SEEK_SET invoke file.write, [f.fh], [_buffer], [_buf_len] @@ -399,8 +402,6 @@ endl push edi .create_key.ex: -; mov word[edi], 0x0A0D -; add edi,2 mov esi, [_key_name] call libini._.string_copy mov byte[edi], '=' @@ -427,13 +428,9 @@ endl push edi mov esi, [_sec_name] -; mov dword[edi], 0x0A0D + ('[' shl 16) -; add edi, 3 mov byte[edi], '[' inc edi call libini._.string_copy -; mov byte[edi], ']' -; inc edi mov dword[edi], ']' + (0x0A0D shl 8) add edi, 3 @@ -485,7 +482,7 @@ endl or eax, eax jnz .exit_error - stdcall libini._.skip_nonblanks, [f_addr] + stdcall libini._.skip_spaces, [f_addr] xor eax, eax xor ebx, ebx xor edx, edx @@ -702,7 +699,7 @@ align 16 export \ libini._.init , 'lib_init' , \ - 0x00040006 , 'version' , \ + 0x00040007 , 'version' , \ ini.enum_sections , 'ini.enum_sections' , \ ini.enum_keys , 'ini.enum_keys' , \ ini.get_str , 'ini.get_str' , \ diff --git a/programs/develop/libraries/libs-dev/libini/libini_p.asm b/programs/develop/libraries/libs-dev/libini/libini_p.asm index 8c0dd5f962..659160c943 100644 --- a/programs/develop/libraries/libs-dev/libini/libini_p.asm +++ b/programs/develop/libraries/libs-dev/libini/libini_p.asm @@ -60,12 +60,6 @@ proc libini._.unget_char _f ;/////////////////////////////////////////////////// ;;------------------------------------------------------------------------------------------------;; ;< --- TBD --- ;; ;;================================================================================================;; - ;push ecx - ;mov ecx,[f] - ;inc [ecx+INIFILE.cnt] - ;dec esi - ;pop ecx - ;ret push eax ecx mov ecx, [_f] inc [ecx + IniFile.cnt] @@ -74,8 +68,7 @@ proc libini._.unget_char _f ;/////////////////////////////////////////////////// cmp [ecx + IniFile.cnt], eax jle @f stdcall libini._.unload_block, [_f] - @@: ;mov al,[esi-1] - pop ecx eax + @@: pop ecx eax ret endp @@ -116,8 +109,11 @@ proc libini._.skip_nonblanks _f ;/////////////////////////////////////////////// je @b cmp al, 9 je @b + cmp al, ini.COMMENT_CHAR + jne @f + stdcall libini._.skip_line, [_f] + jmp @b @@: stdcall libini._.unget_char, [_f] - ;inc [ecx+INIFILE.cnt] ret endp @@ -137,7 +133,6 @@ proc libini._.skip_spaces _f ;////////////////////////////////////////////////// cmp al, 9 je @b @@: stdcall libini._.unget_char, [_f] - ;inc [ecx+INIFILE.cnt] ret endp @@ -159,7 +154,6 @@ proc libini._.skip_line _f ;//////////////////////////////////////////////////// cmp al, 10 jne @b @@: stdcall libini._.unget_char, [_f] - ;inc [ecx+INIFILE.cnt] ret endp @@ -178,7 +172,7 @@ proc libini._.unload_block _f ;///////////////////////////////////////////////// add eax, -ini.BLOCK_SIZE invoke file.seek, [ebx + IniFile.fh], eax, SEEK_SET stdcall libini._.preload_block, ebx - add esi, eax ; ini.BLOCK_SIZE + add esi, eax mov [ebx + IniFile.cnt], 0 pop ecx ebx eax ret @@ -208,8 +202,7 @@ proc libini._.preload_block _f ;//////////////////////////////////////////////// mov esi,[ebx + IniFile.buf] cmp eax,ini.BLOCK_SIZE jl @f - ;dec eax - @@: mov [ebx + IniFile.cnt], eax;ini.BLOCK_SIZE-1 + @@: mov [ebx + IniFile.cnt], eax mov [ebx + IniFile.bsize], eax pop ecx ebx eax ret @@ -273,9 +266,7 @@ endl mov ecx, [ebx + IniFile.cnt] mov ebx, [ebx + IniFile.fh] invoke file.tell, ebx -; push eax sub eax, ecx -; dec eax invoke file.seek, ebx, eax, SEEK_SET @@: invoke file.seek, ebx, [_delta], SEEK_CUR invoke file.eof?, ebx @@ -285,17 +276,15 @@ endl mov ecx, eax mov eax, [_delta] neg eax - sub eax, ecx;ini.BLOCK_SIZE + sub eax, ecx invoke file.seek, ebx, eax, SEEK_CUR - invoke file.write, ebx, [buf], ecx;ini.BLOCK_SIZE + invoke file.write, ebx, [buf], ecx jmp @b .done: mov eax, [_delta] neg eax invoke file.seek, ebx, eax, SEEK_CUR invoke file.seteof, ebx -; pop eax -; invoke file.seek, ebx, SEEK_SET;, eax stdcall libini._.reload_block, [_f] invoke mem.free, [buf] pop ecx ebx @@ -313,7 +302,6 @@ endl mov ecx, [ebx + IniFile.cnt] mov ebx, [ebx + IniFile.fh] invoke file.tell, ebx -; push eax sub eax, ecx lea edx, [eax - 1] push edx @@ -339,11 +327,6 @@ endl @@: .skip.2: add esp, 4 -; mov eax,[delta] -; neg eax -; invoke file.seek,ebx,SEEK_CUR,eax -; pop eax -; invoke file.seek,ebx,SEEK_SET;,eax stdcall libini._.reload_block, [_f] invoke mem.free, [buf] pop ecx ebx @@ -451,8 +434,6 @@ proc libini._.find_section _f, _sec_name ;////////////////////////////////////// jnz .exit_error stdcall libini._.get_char, [_f] -; inc esi -; dec [ecx + IniFile.cnt] stdcall libini._.skip_spaces, [_f] mov edi, [_sec_name] @@: stdcall libini._.get_char, [_f] @@ -564,12 +545,13 @@ proc libini._.low.read_value _f_addr, _buffer, _buf_len ;/////////////////////// @@: stdcall libini._.unget_char, [_f_addr] mov byte[edi], 0 dec edi - @@: cmp byte[edi], 32 + @@: cmp edi, [_buffer] + jb @f + cmp byte[edi], 32 ja @f mov byte[edi], 0 dec edi - cmp edi, [_buffer] - jae @b + jmp @b @@: pop eax edi ret endp diff --git a/programs/develop/libraries/libs-dev/libini/libini_p.inc b/programs/develop/libraries/libs-dev/libini/libini_p.inc index 7c48d1f9ae..73311b4c71 100644 --- a/programs/develop/libraries/libs-dev/libini/libini_p.inc +++ b/programs/develop/libraries/libs-dev/libini/libini_p.inc @@ -23,6 +23,8 @@ ini.MAX_VALUE_LEN = 4096 ini.MEM_SIZE = 4096 ini.BLOCK_SIZE = ini.MEM_SIZE / 2 +ini.COMMENT_CHAR = ';' + struct IniFile fh dd ? buf dd ?