Where has "strpos" gone?

Bug reports (if you don't/won't have a Github account)
Post Reply
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Where has "strpos" gone?

Post by siggi »

According to WIKI it is contained in "string.h". But that is no more given in current z88dk
When I compile my old sendmail program at ZX81, result is:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\sendmail>zcc +zx81 -startup=2 -create-app -vn -O3 -o smai
l.bin mini_sendmail-V2.3.c -llibsocket -llibhttp
Error at file 'mini_sendmail-V2.3.c' line 477: symbol '_strpos' not defined
Error at file 'mini_sendmail-V2.3.c' line 559: symbol '_strpos' not defined
Error at file 'mini_sendmail-V2.3.c' line 1099: symbol '_strpos' not defined
3 errors occurred during assembly
Errors in source file c:\z88dk\lib\config\\..\..\\lib\target\zx81\classic\zx81_c
rt0.asm:
Error at file 'mini_sendmail-V2.3.c' line 477: symbol '_strpos' not defined
                   ^ ----     if ( status != 250  && status != 251 )
Error at file 'mini_sendmail-V2.3.c' line 559: symbol '_strpos' not defined
                   ^ ----     while ((rc >= 0)  && (poll_fd(sockfd1) == 4))
Error at file 'mini_sendmail-V2.3.c' line 1099: symbol '_strpos' not defined
                   ^ ---- (null)D:\PRIVAT\ZX81\DEV\LAN\sendmail>
Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

BTW: The line nummers given in the error messages do not really help. This are the real line numbers, where the C-file calls strpos:

Code: Select all

Suche "strpos" im aktiven Dokument

D:\PRIVAT\ZX81\DEV\LAN\sendmail\mini_sendmail-V2.3.c
   186: status = strpos(username, '?');
   209: status = strpos(reply_to, '?');
   362: i = strpos(buf, '?');
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I don't have information about its removal, but I understand it is not in the posix standard. The equivalent function should be strstr().
The wrong line numbers being reported is for another known bug.
Please confirm it is a valid workaround and let me know what link in the wiki is reporting the wrong information. ;)
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:... and let me know what link in the wiki is reporting the wrong information. ;)
[url]https://www.z88dk.org/wiki/doku.php?id=library:string&s[]=strpos#int_strpos_char_s_uchar_c[/url]
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

stefano wrote:Please confirm it is a valid workaround
Yes, I used it and now I can compile sendmail (which can be started and also crashes when using some (not all!) ZeddyNet functions).

Siggi
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

classic is now using the newlib string functions which doesn't have strpos (it's not posix and is a non-posix equivalent to strstr as mentioned). Classic retained a couple of other string functions not in newlib but missed / deliberately omitted strpos.
Post Reply