Bug Tracker
ID: | 99 🔗 |
---|---|
Status: | Closed (Fixed) |
Category: | datatool |
Version: | 2.23 |
Submitted by: | Patrice Mégret |
Date: | 2015-11-12 03:49:52 |
Summary: | strange behavior of \dtlcompare |
Report
I used the example from the doc-code and I cannot explain the result of\dtlcompare{\mycount}{\noopsort{z}foo}{bar}\number\mycount{}
that should be 1 and not -1 as {z}foo
is greater than bar
.
\documentclass[12pt,a4paper,final]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[verbose]{datatool} \begin{document} \newcount\mycount \newcommand*{\noopsort}[1]{} \verb+\newcommand*{\noopsort}[1]{}+ then \verb+\noopsort{a}foo+ produces the text: foo, however the following \verb+\dtlcompare{\mycount}{\noopsort{a}foo}{bar}\number\mycount+ produces: -1, since the command \verb+\noopsort+ is disregarded when the comparison is made, so \verb+\dtlcompare+ just compares \{a\}foo with bar, and since a is less than b, the first string is considered to be less than the second string. A. result with \verb+\noopsort{a}foo}+ \dtlcompare{\mycount}{\noopsort{a}foo}{bar}\number\mycount{} as expected B. result with \verb+\noopsort{z}foo}+ \dtlcompare{\mycount}{\noopsort{z}foo}{bar}\number\mycount{}. Should it not be 1? \end{document}
MWE
\documentclass[12pt,a4paper,final]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \listfiles \usepackage[verbose]{datatool} \begin{document} \newcount\mycount \newcommand*{\noopsort}[1]{} \verb+\newcommand*{\noopsort}[1]{}+ then \verb+\noopsort{a}foo+ produces the text: foo, however the following \verb+\dtlcompare{\mycount}{\noopsort{a}foo}{bar}\number\mycount+ produces: -1, since the command \verb+\noopsort+ is disregarded when the comparison is made, so \verb+\dtlcompare+ just compares \{a\}foo with bar, and since a is less than b, the first string is considered to be less than the second string. A. result with \verb+\noopsort{a}foo}+ \dtlcompare{\mycount}{\noopsort{a}foo}{bar}\number\mycount{} as expected B. result with \verb+\noopsort{z}foo}+ \dtlcompare{\mycount}{\noopsort{z}foo}{bar}\number\mycount{}. Should it not be 1? \end{document}
Evaluation
I'm sorry, it turns out the documentation was wrong. What actually happens is that commands are treated as though they have a character code of 0. Since this may cause a problem for backward-compatibility for documents that rely on the actual behaviour (rather than the intended behaviour) I've added a switch \ifdtlcompareskipcs
to version 2.32. This is false by default to maintain current behaviour but if you switch it to true (\dtlcompareskipcstrue
) before making the comparison you should get the intended behaviour.
Add comment or return to search results.
Watch This Report
If you would like to be notified whenever updates are made to this report, please fill in your email address in the box below and click on "Notify Me of Changes" button. (Please ensure the address is valid.) Your details won't be passed on to third parties in line with this site's Privacy Policy.
If you supply your name, it will be used in the email greeting, which provides a more personal message, otherwise you'll just get a generic greeting. If you have previously supplied your name when signing up for notifications, you don't need to resupply it unless you want to change it.
If you have previously subscribed to notifications for this report, you can unsubscribe by clicking on the "Stop Notification" button.
The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).
To unsubscribe from all notifications use the notifications page.
Comment
You can append a comment to the report using the form below. Comments are checked first before being added. Any spam or offensive content will be removed first according to this site's Terms of Website Use. Please bear in mind that I develop and maintain free software in my spare time. If you want commerical level support then you can hire a TeX consultant.
The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).