Commit Graph

20 Commits

Author SHA1 Message Date
sin 804b62f7a2 Fix broken sbase-box due to multiple definitions of usage 2015-02-28 18:33:33 +00:00
FRIGN e7c33c4af3 Audit basename(1)
1) be stricter which number of arguments is accepted (1 or 2)
2) basename already returns a pointer to "." is argv[0] is ""
3) No need to check for *p != '/', because basename() only returns
   a string beginning with '/' which has length 1, so if strlen(p)
   == 1, the only way for suffix to be "evaluated" is for off to
   be > 0, being equal to suffix being "", but "" != "/".
4) don't calculate strlen twice for each string. Store it in a
   ssize_t and check if it's > 0.
2015-02-28 14:48:44 +01:00
FRIGN 31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
Hiltjo Posthuma a986e4bbd5 basename: make usage line the same as the man page 2015-02-01 19:26:49 +01:00
sin 1059782af8 Fix comparison >= 0 is always true in basename(1) 2014-12-08 12:14:39 +00:00
Brandon Mulcahy 757cf0651a Fix basename suffix treatment
Explicitly use "." instead of the result of basename(3) when argv[0] is
an empty string in order to avoid a segfault.

Skip suffix treatment if the result of basename(3) is "/", per POSIX.

Fix the suffix check, which was previously checking for a match at any
location in the string.
2014-12-04 08:00:03 +00:00
FRIGN eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
sin a7ad11ed5e Fix overflow in basename(1) 2014-11-13 14:56:25 +00:00
sin 0c5b7b9155 Stop using EXIT_{SUCCESS,FAILURE} 2014-10-02 23:46:59 +01:00
Hiltjo Posthuma 953ebf3573 code style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:30 +01:00
sin b5a511dacf Exit with EXIT_SUCCESS/EXIT_FAILURE instead of 0 and 1
Fixed for consistency purposes.
2013-10-07 16:44:22 +01:00
Christoph Lohmann 52d39e35c2 The style inquisition on basename. 2013-03-05 21:35:55 +01:00
Connor Lane Smith fcb8821246 revert to per-cmd usage() 2012-05-15 13:32:56 +01:00
Connor Lane Smith 146cca114e new ARGBEGIN & usage() function 2012-05-14 21:28:41 +01:00
Christoph Lohmann 3863ccdf98 Testing before rage. Suffix is fixed in basename. 2012-04-23 16:34:34 +02:00
Christoph Lohmann 3817f78f87 Moving back to the stone age. 2012-04-23 16:32:41 +02:00
Christoph Lohmann f75d7a47ff Adding ARGBEGIN for basename. 2012-04-23 15:50:47 +02:00
Connor Lane Smith c367d4d05f add dirname 2011-05-24 21:39:20 +01:00
Connor Lane Smith 026e63c005 simplify basename 2011-05-24 12:56:38 +01:00
Connor Lane Smith 8e26716a5a initial commit 2011-05-23 02:36:34 +01:00