df-xmldecode-patch #1
Reference in New Issue
Block a user
Delete Branch "df/tvdb:df-xmldecode-patch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
theTVDB.com started sending single quotes in XML encoded as
'rather than"as observed in this thread.One fix was to
webif/lib/xml.class; however this program replicates the decoding process in the Jim class (which is a lot slower) and needs to be fixed as well.The patch uses
sscanf()to detect and decode numerically coded XML character entities within the original framework of theunescape()function.Modified compilation options:
-std=c99for thehhformat size prefix-D_XOPEN_SOURCE=700for correct declaration ofstrdup()in the on-box build environment.WIP: df-xmldecode-patchto df-xmldecode-patchApparently does the job but the build needs to be tested in the usual environment.
@@ -61,0 +58,4 @@/* sscanf -> 1: the code was read; ll>0: ';' came next */if ((1 == sscanf( p, "&#%hhu;%n", &icode, &ll) ||1 == sscanf( p, "&#%*[xX]%hhx;%n", &icode, &ll)) &&ll > 0) {sscanf()will return 2 if two input items were converted, won't it?You'd think so, but free30 and I have both run the version built from that code, so apparently not, and I am more confident of that based on the following.
POSIX (admittedly a racily anachronistic 2017 version says):
"Upon successful completion, these functions shall return the number of
successfully matched and assigned input items;"
Arguably, as
%ndoesn't involve any matching, it doesn't count towards the result.Also, as
%*[xX]doesn't involve any assigning, it also doesn't count.In the library source I see this (
libc/stdio/_scanf.cl.1331ff):So MJN3 decided that %n didn't cause
zero_conversionsto be cleared, which is done for formats like %s, %d.Also, the 0/1 flag (
unsigned char store) member that is cleared/set according to whether the format contains*to suppress assignment is used to increment the return count.