Last modified: 2008-09-14 00:19:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T17349, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 15349 - #expr doesn't correctly handle minus or endash as minus sign
#expr doesn't correctly handle minus or endash as minus sign
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: easy
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-28 17:05 UTC by Doug Strain
Modified: 2008-09-14 00:19 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Doug Strain 2008-08-28 17:05:06 UTC
Hi!  You guys are doing a great job!

The MOS states that the unicode minus (and variously or not(!?), the en dash) are to be used to negate numbers and to represent subtraction.  Sometimes these representations are used for display and calculation in the same template call.

Minus and en dash are not evaluated correctly by the #expr parser function (see http://en.wikipedia.org/wiki/User:Saintrain/A/NegTest).

If we can't use the hyphen (as the Lords of FORTRAN intended) then the parser functions should handle the typographic characters.
Comment 1 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-09-12 16:06:11 UTC
I don't think en dash should be handled as a minus sign.  That's just wrong.  The minus sign should, though, for all us typography Nazis.
Comment 2 Doug Strain 2008-09-12 19:52:49 UTC
en dash is no longer in the MOS as a couple weeks ago.  (So Aryeh, that's a vote "for", yes? :-)

Looks like a simple "str_replace" in Expr.php. 

Comment 3 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-09-12 20:18:35 UTC
If somebody were willing to write a patch, I'd be willing to test and commit it.  Brion has expressed reservations about the necessity of typographic exactitude in MediaWiki numerical formatting before, though, over at bug 8327 comment 2.  :)  So I can't promise it will stick, but I don't see why not.
Comment 4 X! 2008-09-12 20:20:35 UTC
I am a little concerned about this, but I don't know why. I can't see any other sensible way to do this, though. (template, str_replace, they won't work on the wiki).
Comment 5 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-09-12 20:21:54 UTC
(In reply to comment #4)
> (template, str_replace, they won't work on the wiki).
Comment 6 Doug Strain 2008-09-12 21:01:14 UTC
(In reply to comment #3)
> Brion has expressed reservations about the necessity of typographic
> exactitude ...
And I agree with him; hyphen, minus, I don't care but Expr.php does.  I just want to calculate with old numbers without getting reverted by people who do care about the typo-crap.
Comment 7 Doug Strain 2008-09-12 21:31:25 UTC
(In reply to comment #3)
> If somebody were willing to write a patch, 
Sorry, I don't have no steenking patches, but changing

  # Unescape inequality operators
  $expr = strtr( $expr, array( '&lt;' => '<', '&gt;' => '>' ) );

to

  # Unescape inequality operators.  Change minuses to hyphens
  $expr = strtr( $expr, array( '&lt;' => '<', '&gt;' => '>', '&minus;' => '-' ) );

at about line# 169 of Expr.php (near the top of doExpression()) should do it.  (Looks like this issue has come up before, typographical-to-calculationical. :-)

Thanks.

Comment 8 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-09-12 22:09:10 UTC
Committed in r40762, and allowed to tolerate U+2212 "−" as well.
Comment 9 Doug Strain 2008-09-12 23:19:06 UTC
(In reply to comment #8)
> Committed in r40762, and allowed to tolerate U+2212 "−" as well.

Many thanks. 
Doug

P.s.  Very roughly, round numbers, how long to get to en?  That is, what's the usual time for such things?
Comment 10 Aryeh Gregor (not reading bugmail, please e-mail directly) 2008-09-14 00:19:34 UTC
Typically on the order of a week.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links