koreader / koreader-base

Base framework offering a Lua scriptable environment for creating document readers
http://koreader.rocks/
GNU Affero General Public License v3.0
130 stars 105 forks source link

ffi/util: Deal with stupid GNU basename quirks #1825

Closed NiLuJe closed 2 months ago

NiLuJe commented 2 months ago

basename("/foo/") yielding "" is very much not what we signed up for...


This change is Reviewable

NiLuJe commented 2 months ago

There is thankfully no such madness happening with dirname, so we once again have a guarantee that joining the output of dirname with the output of basename yields something sensible.

NiLuJe commented 2 months ago

See https://github.com/koreader/koreader/pull/12038#issuecomment-2171805576 for more details, because I had completely forgotten we'd switched to (attempt to) prefer the GNU imp, because (ironically) Android...

mergen3107 commented 2 months ago

Ah, OK xD You beat me to it, lol

NiLuJe commented 2 months ago

because (ironically) Android...

Specifically, the only guarantee we have on bionic is that the public symbol will be named basename. This happens to match the name of the GNU implementation on glibc, where the POSIX one is instead exported as __xpg_basename....

Whether the Android implementation leans more towards a POSIX or GNU behavior is irrelevant (for the record, it leans towards a sane, POSIX behavior, while also not modifying its input ;p).