Compare commits

..

112 Commits

Author SHA1 Message Date
axel
ff2d354ef8 Bump version number
darcs-hash:20060904002509-ac50b-098c9c879257d689a975abd102f9b4d9fc00f592.gz
2006-09-04 10:25:09 +10:00
axel
3bef568955 Fix nagging warning message
darcs-hash:20060903234751-ac50b-c5d7f026323b5cab450e1770be572dcdf3ecc904.gz
2006-09-04 09:47:51 +10:00
axel
9a7be6db08 New status message for fish_pager
darcs-hash:20060903231209-ac50b-b8bad71cb9194a905918534fafec619118d61e21.gz
2006-09-04 09:12:09 +10:00
axel
40e2025327 Minor polish
darcs-hash:20060903230006-ac50b-c55a9272bb1cdb10312b8580c4c2a85654329e30.gz
2006-09-04 09:00:06 +10:00
axel
a819c863eb Skip bug causing autoloader to sometimes use the wrong version of a function. Thanks to Martin Bähr and Mystilleef for the bug reports.
darcs-hash:20060903225839-ac50b-5b1f3d5f0b8c54b999836c3384c22c2a31c31bd0.gz
2006-09-04 08:58:39 +10:00
axel
827c88e4a1 Fix bug where using the return builtin inside an if-block could cause the else-block to get executed
darcs-hash:20060831205320-ac50b-64ecbaa3ed5e32c1a815ba384a6831a8fd5e1b47.gz
2006-09-01 06:53:20 +10:00
axel
e2b7a078f4 Make "$foo\[1]" not be an array slicing. Notice the extra backslash
darcs-hash:20060831155932-ac50b-746462d2147f349f9a799cb4786a0abacd1d3d4a.gz
2006-09-01 01:59:32 +10:00
axel
6de0c4103b Add support for \cx backslash escapes for control sequences, syntax is borrowed from bash
darcs-hash:20060831155813-ac50b-cc93412afc87c1c391c3dbc5e7b8c9175efe01d8.gz
2006-09-01 01:58:13 +10:00
axel
b6e8171f01 Fix minor null pointer bug in the set builtin, fix bug causing the -n switch to be ignored, add missing completions for the -n switch to functions and set builtins, and touch up the documentation for said builtin a bit
darcs-hash:20060831154400-ac50b-dddbee79481e0e0a8da9fc025e8a15c466460a2f.gz
2006-09-01 01:44:00 +10:00
axel
b1439075c6 Updated definiton of move_word, more intuitive behaviour when a token consists only of non-alphanumerics
darcs-hash:20060831004525-ac50b-aa6675809f0f17fa266982374700a8a4ce6b2f5a.gz
2006-08-31 10:45:25 +10:00
axel
7df536023b Fix concurrency bug in autoloader causing memory leak
darcs-hash:20060828162734-ac50b-76c88ba8cc164646dcff16cb899633f1e10392e2.gz
2006-08-29 02:27:34 +10:00
axel
f5f15f9de2 Use dynamically sized buffer for reporting error messages in the parser
darcs-hash:20060828151913-ac50b-02453c13d107f88023b2331bf40daf6d329ac597.gz
2006-08-29 01:19:13 +10:00
axel
0e0a61119f Update english transliteration
darcs-hash:20060828130147-ac50b-2b07adaa3fd63cf0cd2b0122fef45b9aee365e37.gz
2006-08-28 23:01:47 +10:00
axel
6f058c687d Add fallback if SIGWINCH is unavailable
darcs-hash:20060828122515-ac50b-f2b8f1519bbbd62908a6648255bfb20bdce83212.gz
2006-08-28 22:25:15 +10:00
axel
53ea5d60b7 Minor code tweaks, mostly things like indentation, but also a ferw code reorderings
darcs-hash:20060828120244-ac50b-ad4be149ff245b6f799452f9eeff7bcc60af1526.gz
2006-08-28 22:02:44 +10:00
axel
9525f429c6 Dont let fallback implementation of killpg kill group 1
darcs-hash:20060828120122-ac50b-c5e3eb7392654feb378cdfcf11ab102418aa1386.gz
2006-08-28 22:01:22 +10:00
axel
548e379d6a Provide fallback version of getopt_long instead of checking for it's presense every time it is used
darcs-hash:20060828114305-ac50b-f4aad19e936fa42bbe84e51e72aa32445a469527.gz
2006-08-28 21:43:05 +10:00
axel
202d29de88 Restructure the autoloader. This fixes a very weird and rare Heissenbug, probably caused by a compiler bug, but also makes the structure of the code a bit more logical.
darcs-hash:20060828110019-ac50b-7be19eda18eb358163a9a5b7180c6c7d028e546d.gz
2006-08-28 21:00:19 +10:00
axel
23152ae8a6 Remove checks for gettext presense in mimedb.c and set_color.c. If gettext is unavailable, a fallback is provided.
darcs-hash:20060828105806-ac50b-47f092813ed70a03477d66c377edbe24f2aedf40.gz
2006-08-28 20:58:06 +10:00
axel
7310596dab Much more reliable getopt_long test. Idea from Netocrat.
darcs-hash:20060828102949-ac50b-bb55face2f3127018b6c79a72ee71e38f075232a.gz
2006-08-28 20:29:49 +10:00
axel
4afe49d7c6 Redo the -POSIX_C_SOURCE test to only add macros if they are found to fix things. Also add -stdÉ9 to CPPFLAGS if it is added to CFLAGS. Also add more comments, redo indentation and general file cleanup. Written cooperatively by Liljencrantz and Netocrat.
darcs-hash:20060828100334-ac50b-73eed298fdf5a853243413f0f12c235ffa9e787a.gz
2006-08-28 20:03:34 +10:00
axel
d7c3d2acbf Use OK as return value for del_curterm fallback
darcs-hash:20060828100046-ac50b-e52e7181ffb6fa5b1b3162ac3ae0aacc9bf7f5a3.gz
2006-08-28 20:00:46 +10:00
axel
f771fce892 Add a $version variable. Suggested by Martin Bähr
darcs-hash:20060828095840-ac50b-db561647eee1d06785448a4bfc6826eef5aec2b7.gz
2006-08-28 19:58:40 +10:00
axel
6522000bf0 Don't turn of file completion in svn completions if given an unknown subcommand
darcs-hash:20060827144853-ac50b-d09576fd6984eb18b06e0e7b1d8a88aa7b9d1df4.gz
2006-08-28 00:48:53 +10:00
axel
285abcc9bc Do not use the non-standard -i switch for sed
darcs-hash:20060827131554-ac50b-b969c2a56607ff46d028f5c44faabf2842814f0e.gz
2006-08-27 23:15:54 +10:00
axel
b15e8123ca If no completions have been found, use file completion even if command specific completions have disabled file completions. Suggested by MArtin Bähr.
darcs-hash:20060827005740-ac50b-41c3bf2bb91bcfc0122c317bcc2aca2061cd019e.gz
2006-08-27 10:57:40 +10:00
axel
1c86395ed8 Fix bug reportad by Martin Bähr that causes fish fail when using blocks in pipelines in interactive mode.
darcs-hash:20060827005252-ac50b-09c98537b9de72f0d4a2e5a28490b2e38fe321c8.gz
2006-08-27 10:52:52 +10:00
axel
3c8d2a1126 Don't use carriage return on initial painting of the prompt
darcs-hash:20060826022416-ac50b-16746f45142589e7fa83e95b6ee6a2fad98432c4.gz
2006-08-26 12:24:16 +10:00
axel
ed8cd08984 Fix minor memory leak in completion code
darcs-hash:20060826021948-ac50b-6fecba2056e47cb7c4e8499f2a51e1c0c23d0757.gz
2006-08-26 12:19:48 +10:00
axel
69537430ea Fix bug in completion code reported by Martin Bähr, as well as other bug evident in his bug report.
darcs-hash:20060826013722-ac50b-08de084a40af8ba5d708a7cd162087b7afbb7648.gz
2006-08-26 11:37:22 +10:00
axel
0a603a56c6 Minor bugfix for the completions for the complete builtin
darcs-hash:20060825154545-ac50b-eaa8b210ddc6fb6a089deb5c2b19723bd92228f3.gz
2006-08-26 01:45:45 +10:00
axel
046dd82995 Add minor new completion for make command
darcs-hash:20060825154516-ac50b-80284df4f7dd6cd332f2b21f5c9bdc359cc00eca.gz
2006-08-26 01:45:16 +10:00
axel
97c3e231f4 Allow slicing of command substitution output
darcs-hash:20060824133904-ac50b-fbc43cf30d8eb15e50343b786af77f85fb0b8d4e.gz
2006-08-24 23:39:04 +10:00
axel
76b782d576 Do not mix wide and narrow printf calls on stderr in set_color.c
darcs-hash:20060824133828-ac50b-399d9c8d4f6cd7c36ceb2991011d9dae23851d6f.gz
2006-08-24 23:38:28 +10:00
axel
ed5c1db392 Bump version number
darcs-hash:20060824105129-ac50b-999429675a936c246665940ee9154a524eae4be2.gz
2006-08-24 20:51:29 +10:00
axel
37f5db2bf9 Use terminfo to look up tab width instead of assuming 8 character tabs when calculating prompt width
darcs-hash:20060824104354-ac50b-bfb6428411a9c3f6e7a8df980b1005fdd1842a10.gz
2006-08-24 20:43:54 +10:00
axel
8a97bffd02 Spelling correction in documentation
darcs-hash:20060824103055-ac50b-8a81c73571b76dd2800787ca6e5bd29787eb9501.gz
2006-08-24 20:30:55 +10:00
axel
2fd48bce11 Fix use og uncasted 0 as null pointer in vararg function. Potential crash bug on 64 bit systems.
darcs-hash:20060824103014-ac50b-3fb830f548d383b8cef7a37b737c90f3ad30c4bd.gz
2006-08-24 20:30:14 +10:00
axel
d1a3e6abf5 Complete --do-complete argument should be optional
darcs-hash:20060824005315-ac50b-fa4fb8177bc11cf20f2f95fff43cd674a439bae0.gz
2006-08-24 10:53:15 +10:00
axel
1a29979bbd Ignore return code of exec_subshell when doing command substitution
darcs-hash:20060824005217-ac50b-9de976e1fe2d396b08b59619e46669bad6598ec2.gz
2006-08-24 10:52:17 +10:00
axel
69814e5066 Add documentation about new backslash escapes, and correct a broken link in the docs
darcs-hash:20060824005117-ac50b-39a1f56891c92e6a9b64b20fdd4bfd7d60090949.gz
2006-08-24 10:51:17 +10:00
axel
4dbac8f941 Add support for \a \f \v escape sequences, and make supåport for \e standards compliant
darcs-hash:20060824002609-ac50b-a1a9150d096647d9ab4c39d3245b528d7e75cd57.gz
2006-08-24 10:26:09 +10:00
axel
303473f20c Fix incorrect usage of the term subshell when command substitution was meant
darcs-hash:20060822143831-ac50b-cb5267a6434adcbd5bafb452d688bee06c23d4d6.gz
2006-08-23 00:38:31 +10:00
axel
480a29594e Minor tweaks to previous fish_pager patch to fix two bugs
darcs-hash:20060822135815-ac50b-35d9f643385ec29f9d8f93ca83d01e060de93cc7.gz
2006-08-22 23:58:15 +10:00
stew
dfe3dc1429 fish_pager_via_stdin
darcs-hash:20060822012451-2edb7-d8939fab708d8c605d2c7d0683c71f11db659bc9.gz
2006-08-22 11:24:51 +10:00
axel
2ea00ce444 help --help should be same as help help
darcs-hash:20060822005230-ac50b-b82c0665cae7427c09992f51e128e33cea44b41e.gz
2006-08-22 10:52:30 +10:00
axel
ac13bdeaa7 Work around Doxygen bug in man-file generation
darcs-hash:20060822004853-ac50b-3c5036484961825304059567670eea0ccb3cd643.gz
2006-08-22 10:48:53 +10:00
axel
22cb7dd2d7 Add horizontal ruler between documentation for builtins and commands
darcs-hash:20060822004810-ac50b-aa75e233685ce4e0c22cde27411550a13efbeff6.gz
2006-08-22 10:48:10 +10:00
axel
20698cc813 Remove duplicate include
darcs-hash:20060817155050-ac50b-bbbd5130688d1f3f5f4e4d48c4319faf4413995a.gz
2006-08-18 01:50:50 +10:00
axel
1ebf571da5 Update french translation, thanks to Xavier Douville
darcs-hash:20060814181448-ac50b-08e5a5e8eff3316411469730d03d756170e4b01a.gz
2006-08-15 04:14:48 +10:00
axel
7c822cbf30 Add a message to stdout in the help function describing where the help went if help opens an external browser window
darcs-hash:20060814181135-ac50b-6d9b05b714bc9576c260e87b5706e7d94dd73e39.gz
2006-08-15 04:11:35 +10:00
axel
90302d9232 Documentation correction
darcs-hash:20060814120540-ac50b-25daddbd1130d1b57837affa6c58542fd91ff59e.gz
2006-08-14 22:05:40 +10:00
axel
bee6805ff9 Check return value of del_curterm
darcs-hash:20060813230502-ac50b-2b7e30d3560097725789bf6aa659835e30c7a81b.gz
2006-08-14 09:05:02 +10:00
netocrat
65035c4dc7 Change null function to #define for del_curterm() - solves build problem on some BSDs.
darcs-hash:20060813030853-344c5-7aa2cc3c70044214d90263999f2312f8f10296a4.gz
2006-08-13 13:08:53 +10:00
netocrat
2b0d64184a Switch back to using -D for _POSIX_C_SOURCE and _XOPEN_SOURCE - solves build problem on Solaris 10
darcs-hash:20060813030806-344c5-ad0eec62d3ce93d98adcad4b93318b06538eef95.gz
2006-08-13 13:08:06 +10:00
axel
51d7159ba7 Update fish_pager interface, first try - this is the second patch to redo the fish_pager interface. Both this one and the previous one breaks the display of completions
darcs-hash:20060813014602-ac50b-3d30e3486021b1ffddf3f1a69e86ee51a6aac611.gz
2006-08-13 11:46:02 +10:00
axel
0a4819be27 Add support for buffering of input to a command, the first step to piping data to fish_pager instead of using the argument list
darcs-hash:20060813013803-ac50b-f8000d4c96162023411f84643f47221860b350b2.gz
2006-08-13 11:38:03 +10:00
axel
72ad4e0d3b Make fish pager use non-universal variables as well for getting it's colors
darcs-hash:20060811145528-ac50b-26be05f363f353d87ebceccf73385cd1af1c88f2.gz
2006-08-12 00:55:28 +10:00
axel
21de293a44 Fix missing quote in configure.ac
darcs-hash:20060811142930-ac50b-52d1bb6faf07b6a0ddac754cee16e899dd196679.gz
2006-08-12 00:29:30 +10:00
axel
8b395d05ef Switch to using AC_DEFINE instead of using -D switces in CFLAGS for a few macros that don't need to be passed through the Makefile
darcs-hash:20060811134859-ac50b-6efc59b9214909aa6804bed9c5919ed0e29ddf81.gz
2006-08-11 23:48:59 +10:00
axel
8392902cec Remove unneded include in Autoconf test. Thanks to Netocrat.
darcs-hash:20060811101005-ac50b-275a1240e7802f70eb763be42683b4d1f816a9b0.gz
2006-08-11 20:10:05 +10:00
axel
a5abdd2792 Always redefine del_curterm to be a no-op under bsd, seeme the double free bug can surface under ncurses as well. Thanks to Netocrat.
darcs-hash:20060811100756-ac50b-1b1010b696fdd9acf45ef85ab19e75f574e5198b.gz
2006-08-11 20:07:56 +10:00
axel
e784683b8a Comment away currently unused function to avoid warning. Thanks to Netocrat.
darcs-hash:20060811093051-ac50b-d025c406234bb31e36c0b0b7951b54c6fc62ed07.gz
2006-08-11 19:30:51 +10:00
axel
7fadf6c083 Do not call closedir on directories that failed to open. Avoids crash bug. Thanks to Netocrat.
darcs-hash:20060811092639-ac50b-6615f51aad8c2a81917db08e2dc8f4da3d7db2ef.gz
2006-08-11 19:26:39 +10:00
axel
7ff76476ed Remove non-unicode character in documentation file. Thanks to Netocrat.
darcs-hash:20060811092603-ac50b-59a68550fa3279662113ec080b18e7930bb02fe2.gz
2006-08-11 19:26:03 +10:00
axel
cd9102214b Rearrange includes so that config.h is always the first file to be included
darcs-hash:20060811011835-ac50b-847fc790288e3bb3f3a0ee7734ff278d2dc65bef.gz
2006-08-11 11:18:35 +10:00
axel
8da54a1955 Add two BSD-specific preprocessor macros to get additional prototypes. Thanks to Netocrat.
darcs-hash:20060810203756-ac50b-21259e610fc738c6ad990d88b0af74d56d6a38f8.gz
2006-08-11 06:37:56 +10:00
axel
6899e4e734 Do not use ! to negate shellscript results, this is unsupported on Solaris. Thanks to Netocrat.
darcs-hash:20060810194951-ac50b-7baee5f1ab962fac6fbb37f13e0a8ba134e910e2.gz
2006-08-11 05:49:51 +10:00
axel
486e0dbe84 Remove Solaris circular dependency in init file. Thanks to Netocrat.
darcs-hash:20060810193338-ac50b-2f1f68170610e1669fc20298fcce50a920c3f38f.gz
2006-08-11 05:33:38 +10:00
axel
441c109afb Remove unneded includes in autoconf tesst and add possibly needed one. Thanks to Netocrat.
darcs-hash:20060810192359-ac50b-8e38e24ada59928cf6f37e7ed625fe40a34fd5d7.gz
2006-08-11 05:23:59 +10:00
axel
4b0810d7e9 Added missing include in input_common.c, needed under FreeBSD. Thanks to Netocrat.
darcs-hash:20060810190246-ac50b-190b0b2e1fbcab0bd742f5b98f7e1e173b793800.gz
2006-08-11 05:02:46 +10:00
axel
51d58a6a7c Added missing line continuation. Thanks to Netocrat.
darcs-hash:20060810185244-ac50b-944f18d3bed557061e0625b805e51a6a743835ae.gz
2006-08-11 04:52:44 +10:00
axel
7a884e11a6 Avoid circular dependency in ls autoload. Second try.
darcs-hash:20060809231155-ac50b-52b1b1609307fb05d3d8f32c972b0a22476a1da8.gz
2006-08-10 09:11:55 +10:00
axel
c4acfdd87c Add missing files to make uninstall
darcs-hash:20060809230749-ac50b-2948357bb000b47b49b6310dabd84410fde3b461.gz
2006-08-10 09:07:49 +10:00
axel
41f8007a03 More header/autoconf fixes, improve winsize checking
darcs-hash:20060809225338-ac50b-7162a690e44e2272f4760723f5bf8cc135dc5952.gz
2006-08-10 08:53:38 +10:00
axel
8207030b21 Fix typo in seq.in
darcs-hash:20060809225230-ac50b-8371f5fd1a22526325d46f5a0565e3a38d51bb78.gz
2006-08-10 08:52:30 +10:00
axel
a2c70f495e Use string.h not strings.h in all cases
darcs-hash:20060809223452-ac50b-67c4b5af37ebd17ff6d7c1403ff3231272f35465.gz
2006-08-10 08:34:52 +10:00
axel
b11f366bb0 Add SIGUSR1 as fallback if SIGIO doesn't exist
darcs-hash:20060809222656-ac50b-9a1f5a202f012c836570041acb6064849e7b0de5.gz
2006-08-10 08:26:56 +10:00
axel
0e1a3c7c4a Add missing sys/select.h header needed on FreeBSD
darcs-hash:20060809222605-ac50b-7914c1eb0509a01bfb6d07a04e29e126218f89dc.gz
2006-08-10 08:26:05 +10:00
axel
d3a75a354a A new faq question and some minor documentation edits
darcs-hash:20060809114048-ac50b-0fe667bfe9cdcade6480137f2cf5982cc743288c.gz
2006-08-09 21:40:48 +10:00
axel
afc49dded2 Minor edits to the spec file
darcs-hash:20060809113614-ac50b-ab6ca380a48586ef95256ab8acb77da42854829b.gz
2006-08-09 21:36:14 +10:00
axel
49b232df84 Add a few missing dependencies for the spec file
darcs-hash:20060809113554-ac50b-cbc408698f102c3e3170a119acfafe7569c56592.gz
2006-08-09 21:35:54 +10:00
axel
248d11c462 Only write out titlebar message if it is of non-zero length
darcs-hash:20060809113424-ac50b-59988efa4dd788d6623023b642fd96989c4c9ada.gz
2006-08-09 21:34:24 +10:00
axel
6b1570b745 Tweak spec file as per suggestions from Michael Schwendt
darcs-hash:20060801135709-ac50b-07c6191b7464ba90dd64c78ae18df8b59e8e18ad.gz
2006-08-01 23:57:09 +10:00
axel
dc3634dc94 Add posix macros in configure.ac, not in Makefile, so that they will be honored by the configure tests
darcs-hash:20060801013123-ac50b-0c561ad5afd6e71230e29a25d467ed63c47b9f17.gz
2006-08-01 11:31:23 +10:00
axel
696b4df1c6 Add __EXTENSIONS__ macro when under Solaris
darcs-hash:20060801013018-ac50b-08925f5e5239e48ca3024717d5fec2e82138ca5a.gz
2006-08-01 11:30:18 +10:00
axel
65f4d6e866 The xpg4-path was mistyped. Fix it.
darcs-hash:20060801005736-ac50b-ef8389777e012f9f0b6edcb3df3d638158f87373.gz
2006-08-01 10:57:36 +10:00
axel
8833e8f4ea Fix minor nit in comment
darcs-hash:20060801005246-ac50b-56cb6d2245ce81d16807028749495b8e5a86cc3c.gz
2006-08-01 10:52:46 +10:00
axel
f29026b767 Fix another typo in common.c
darcs-hash:20060801004648-ac50b-4177620e4ee37ab1ad6f942faa3023cedeee9055.gz
2006-08-01 10:46:48 +10:00
axel
7ecf7c1fac Fix typo in common.c
darcs-hash:20060801003556-ac50b-fb20d6405d2d8fc8d343d040afbf3863bac07b2f.gz
2006-08-01 10:35:56 +10:00
axel
4a2fa5ea34 Fix typo in signal.c
darcs-hash:20060801002550-ac50b-3412377a694aac72d04e6eae3173ac0980724e60.gz
2006-08-01 10:25:50 +10:00
axel
03f6656af6 Use S_IS* macros instead of S_IF*, which are non-posix
darcs-hash:20060801002411-ac50b-e5afcbfe4adfc54333c982b43309091c1cbcc1c9.gz
2006-08-01 10:24:11 +10:00
axel
8e6dbe245c Changes to the fish spec file, written by Paul Howarth. Fixes spelling and broken dependencies.
darcs-hash:20060731212954-ac50b-630beb87b4563118c132dbf1c525d492b30df3eb.gz
2006-08-01 07:29:54 +10:00
axel
daf171aa86 Make grep call in seq fallback implementation Posix compliant
darcs-hash:20060731165626-ac50b-5560aebc877f49f4942b2c730273d8c2424bec24.gz
2006-08-01 02:56:26 +10:00
axel
d1bbb89389 Move over a few more objects to the new array_list functions
darcs-hash:20060731165511-ac50b-7858829e6a612e0c737d82d3d71d6833dc97f078.gz
2006-08-01 02:55:11 +10:00
axel
bd0c1573df Fix bug when using same array index more than once in a single array expansion, e.g. $PATH[1 1 1]
darcs-hash:20060731164816-ac50b-d3fc56b425035a4cbcf93a91435f9df9ca5997ac.gz
2006-08-01 02:48:16 +10:00
axel
2700a9b697 Use the new array_list functions in exec.c
darcs-hash:20060731163548-ac50b-3b503e0457b33c6bb2eda0040a9fa7f15e6afe32.gz
2006-08-01 02:35:48 +10:00
axel
474f6e90ff Use maxi not max in test suite when comaparing ints
darcs-hash:20060731163119-ac50b-94134f758d9cd7e87746fb93f187aa100c1b820d.gz
2006-08-01 02:31:19 +10:00
axel
7cbc11f1c3 Minor documentation additions
darcs-hash:20060731163027-ac50b-8532ecadc755400fc1be1f029fcec49412764da2.gz
2006-08-01 02:30:27 +10:00
axel
09f9d43be3 Drup minf/maxf from util.h, they are unused
darcs-hash:20060731162550-ac50b-6b4d29d73ef7d672c3c0f9070b528b96b9ec0c16.gz
2006-08-01 02:25:50 +10:00
axel
109e7455a8 Use the new array_list functions in builtin.c
darcs-hash:20060731162339-ac50b-e8a6bd2c327b8fa5527b739fba544994e1a809e3.gz
2006-08-01 02:23:39 +10:00
axel
9b95332aa9 Use the new array_list functions in builtin_set.c
darcs-hash:20060731161719-ac50b-28a669e7a83f966dba3527a148ff0fa0813fbd6b.gz
2006-08-01 02:17:19 +10:00
axel
cccd13db92 Add long and function pointer versions of all array_list_t calls
darcs-hash:20060731161641-ac50b-1850b9c2464ce1aa7ff2f1aa74140b526a6825f2.gz
2006-08-01 02:16:41 +10:00
axel
2c8a2c9f61 Add _POSIX_C_SOURCE macro, to enable Posix mode of various headers. Should help under Solaris. Thanks to Netocrat for the suggestion.
darcs-hash:20060731153213-ac50b-14f8402a743dd67f34e3699e993cef329fdd9427.gz
2006-08-01 01:32:13 +10:00
axel
f05e1f6e48 Always check strings sent to tparm
darcs-hash:20060731004804-ac50b-ddede984cbc114b5e79745aef768f85a587d3dc6.gz
2006-07-31 10:48:04 +10:00
axel
f439c4a484 Make calls to grep Posix compliant
darcs-hash:20060731003354-ac50b-5916d6d862fe8b4f31b64840296d24615b52d175.gz
2006-07-31 10:33:54 +10:00
axel
2fba53b113 Make PATH validation only run for interactive shells to avoid infinite loop
darcs-hash:20060731003311-ac50b-da0b49830e5a9042fbe7952a63ced2c86b8978fe.gz
2006-07-31 10:33:11 +10:00
axel
8a2846ed44 Add Solaris xpg4 PATH test
darcs-hash:20060731003111-ac50b-d8945adca50bbe9e86041835ed52a88e09f65701.gz
2006-07-31 10:31:11 +10:00
axel
91b63e4989 Make sure install-sh is executable in the Makefile
darcs-hash:20060730210506-ac50b-9869e637a768aefd6ec7db33cec5f2defb29eb36.gz
2006-07-31 07:05:06 +10:00
axel
89d876d0f7 Provide fallback of killpg function
darcs-hash:20060730205941-ac50b-ddcec32cc5ab74770b743fed3d131460ee576191.gz
2006-07-31 06:59:41 +10:00
axel
e79fdcb194 Provide fallback is struct winsize is not defined
darcs-hash:20060730205544-ac50b-26f34eb04b56924baa34f560fd274cf38413b5f5.gz
2006-07-31 06:55:44 +10:00
axel
60f0533821 Include siginfo.h in all signal-using files to make Solaris happy. Thanks to Netocrat for the report and a description of the solution.
darcs-hash:20060730202659-ac50b-1840aff40ec2467242bd107676c7426cdb14f643.gz
2006-07-31 06:26:59 +10:00
70 changed files with 12474 additions and 1690 deletions

View File

@@ -49,7 +49,7 @@ prefix = @prefix@
optbindirs = @optbindirs@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
MACROS=-DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
MACROS=-DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
CFLAGS=@CFLAGS@ $(MACROS)
CPPFLAGS=@CPPFLAGS@
LDFLAGS= @LIBS@ @LDFLAGS@
@@ -196,6 +196,9 @@ configure: configure.ac
Makefile: Makefile.in configure
./config.status
fish.spec: fish.spec.in
./config.status
debug:
make fish CFLAGS="@CFLAGS@ $(MACROS) -O0 -Wno-unused -Werror -g"
.PHONY: debug
@@ -235,11 +238,17 @@ xsel-0.9.6/xsel: xsel-0.9.6
doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
cat doc_src/doc.hdr >doc.h;
echo "/** \page builtins Builtin commands" >>doc.h;
cat `printf "%s\n" $(BUILTIN_DOC_SRC)|sort` >>doc.h;
for i in `printf "%s\n" $(BUILTIN_DOC_SRC)|sort`; do \
echo "<hr>" >>doc.h; \
cat $$i >>doc.h; \
done
echo "*/" >>doc.h
echo "/** \page commands External commands" >>doc.h;
echo "\c fish is shipped with commands which do not use any internal parts of the shell, and are therefore not written as builtins, but separate commands." >>doc.h
cat `printf "%s\n" $(CMD_DOC_SRC)|sort` >>doc.h;
for i in `printf "%s\n" $(CMD_DOC_SRC)|sort`; do \
echo "<hr>" >>doc.h; \
cat $$i >>doc.h; \
done
echo "*/" >>doc.h
# This rule creates complete doxygen headers from each of the various
@@ -275,7 +284,7 @@ doc.h:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC) doc_src/doc.hdr
messages.pot: *.c *.h etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq
if test $(HAVE_GETTEXT) = 1;then \
xgettext -k_ -kN_ *.c *.h -o messages.pot; \
if ! xgettext -j -k_ -kN_ -LShell etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq -o messages.pot; then \
if xgettext -j -k_ -kN_ -LShell etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \
echo "Your xgettext version is too old to build the messages.pot file"\
rm messages.pot\
false;\
@@ -326,12 +335,16 @@ doc_src/builtin_doc: $(BUILTIN_DOC_SRC) doc_src/count.txt builtin_help.hdr $(CMD
echo "*/" >>$$FILE; \
done
cd doc_src; doxygen; cd ..;
for i in doc_src/builtin_doc/man/man1/*.1; do \
sed -e "s/\(.\)\\.SH/\1/" <$$i >$$i.tmp; \
mv $$i.tmp $$i; \
done
touch doc_src/builtin_doc
builtin_help.c: doc_src/builtin_doc gen_hdr.sh
$(MAKE) gen_hdr2 # Don't depend on gen_hdr2, because then we would need to rebuild the docs whenever we use a fresh tarball
cp builtin_help.hdr builtin_help.c;
if ! test -x gen_hdr.sh; then chmod 755 gen_hdr.sh; fi
if test -x gen_hdr.sh; then true; else chmod 755 gen_hdr.sh; fi
for i in $(BUILTIN_DOC_HDR) doc_src/count.doxygen ; do \
echo ' hash_put( &tbl, L"'`basename $$i .doxygen`'",' >>$@; \
./gen_hdr.sh $$i >>$@; \
@@ -380,8 +393,12 @@ check-uninstall:
fi;
.PHONY: check-uninstall
install-sh:
if test -x install-sh; then true; else chmod 755 install-sh; fi
.PHONY: install-sh
# Try to install after checking for incompatible installed versions
install: all check-uninstall install-force
install: all install-sh check-uninstall install-force
.PHONY: install
# Force installation, even in presense of incompatible previous
@@ -437,14 +454,17 @@ uninstall: uninstall-translations
rm -f $(DESTDIR)$(bindir)/xsel
rm -f $(DESTDIR)$(sysconfdir)/fish
rm -f $(DESTDIR)$(sysconfdir)/fish_inputrc
if test -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish; then \
rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish; \
fi
if test -d $(DESTDIR)$(datadir)/fish; then \
rm -r $(DESTDIR)$(datadir)/fish; \
fi
if test -d $(DESTDIR)$(docdir); then \
rm -r $(DESTDIR)$(docdir);\
fi
for i in fish.1 @XSEL_MAN@ mimedb.1 fishd.1 set_color.1 count.1; do \
rm -f $(DESTDIR)$(mandir)/man1/$$i*; \
for i in $(MANUALS); do \
rm -f $(DESTDIR)$(mandir)/man1/`basename $$i`*; \
done;
.PHONY: uninstall
@@ -574,8 +594,8 @@ dist: fish-@PACKAGE_VERSION@.tar.bz2
# Create .rpm file for the current systems architecture and an
# .src.rpm file.
rpm: fish-@PACKAGE_VERSION@.tar.bz2
@if ! which rpmbuild; then \
rpm: fish-@PACKAGE_VERSION@.tar.bz2 fish.spec
@if which rpmbuild; then true; else \
echo Could not find the rpmbuild command, needed to build an rpm; \
echo You may be able to install it using the following command:; \
echo \'yum install rpm-build\'; \

View File

@@ -21,6 +21,8 @@
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -37,8 +39,6 @@
#include <sys/time.h>
#include <time.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -2743,11 +2743,11 @@ static int builtin_return( wchar_t **argv )
b = current_block;
while( ( b->type != FUNCTION_CALL))
{
b->type = FAKE;
b->skip=1;
b = b->outer;
}
b->skip=1;
// proc_set_last_status( status );
return status;
}
@@ -2778,7 +2778,7 @@ static int builtin_switch( wchar_t **argv )
current_block->skip=1;
current_block->param2.switch_taken=0;
}
return res;
}
@@ -2790,7 +2790,7 @@ static int builtin_case( wchar_t **argv )
int argc = builtin_count_args( argv );
int i;
wchar_t *unescaped=0;
if( current_block->type != SWITCH )
{
sb_printf( sb_err,
@@ -2799,30 +2799,30 @@ static int builtin_case( wchar_t **argv )
builtin_print_help( argv[0], sb_err );
return 1;
}
current_block->skip = 1;
if( current_block->param2.switch_taken )
{
return 0;
}
for( i=1; i<argc; i++ )
{
free( unescaped );
int match;
unescaped = parse_util_unescape_wildcards( argv[i] );
match = wildcard_match( current_block->param1.switch_value, unescaped );
free( unescaped );
if( wildcard_match( current_block->param1.switch_value, unescaped ) )
if( match )
{
current_block->skip = 0;
current_block->param2.switch_taken = 1;
break;
}
}
free( unescaped );
return 0;
}
@@ -3126,7 +3126,7 @@ void builtin_push_io( int in )
{
if( builtin_stdin != -1 )
{
al_push( &io_stack, (void *)(long)builtin_stdin );
al_push_long( &io_stack, (long)builtin_stdin );
al_push( &io_stack, sb_out );
al_push( &io_stack, sb_err );
}
@@ -3149,7 +3149,7 @@ void builtin_pop_io()
{
sb_err = (string_buffer_t *)al_pop( &io_stack );
sb_out = (string_buffer_t *)al_pop( &io_stack );
builtin_stdin = (int)(long)al_pop( &io_stack );
builtin_stdin = (int)al_pop_long( &io_stack );
}
else
{

View File

@@ -3,6 +3,8 @@
Functions used for implementing the commandline builtin.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -11,8 +13,6 @@ Functions used for implementing the commandline builtin.
#include <termios.h>
#include <signal.h>
#include "config.h"
#include "fallback.h"
#include "util.h"

View File

@@ -3,6 +3,8 @@
Functions used for implementing the complete builtin.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -11,8 +13,6 @@ Functions used for implementing the complete builtin.
#include <termios.h>
#include <signal.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -364,7 +364,7 @@ static int builtin_complete( wchar_t **argv )
}
,
{
L"do-complete", required_argument, 0, 'C'
L"do-complete", optional_argument, 0, 'C'
}
,
{

View File

@@ -5,13 +5,14 @@
various help files in the doc_src directory.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <string.h>
#include <wchar.h>
#include <sys/types.h>
#include "config.h"
#include "util.h"
#include "common.h"
#include "halloc_util.h"

View File

@@ -1,6 +1,7 @@
/** \file builtin_jobs.c
Functions for executing the jobs builtin.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
@@ -13,8 +14,6 @@
#include <string.h>
#include <wctype.h>
#include "config.h"
#include "fallback.h"
#include "util.h"

View File

@@ -3,6 +3,8 @@
Functions used for implementing the set builtin.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -11,8 +13,6 @@ Functions used for implementing the set builtin.
#include <termios.h>
#include <signal.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -81,7 +81,7 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
show_perror = 1;
}
if( !( S_IFDIR & buff.st_mode ) )
if( !( S_ISDIR(buff.st_mode) ) )
{
error = 1;
@@ -233,7 +233,6 @@ static int parse_index( array_list_t *indexes,
{
wchar_t *end;
long l_ind = wcstol(src, &end, 10);
int *ind;
if (end == src)
{
@@ -246,9 +245,7 @@ static int parse_index( array_list_t *indexes,
l_ind = var_count+l_ind+1;
}
ind = (int *) calloc(1, sizeof(int));
*ind = (int) l_ind;
al_push(indexes, ind);
al_push_long(indexes, l_ind);
src = end;
count++;
while (iswspace(*src)) src++;
@@ -275,7 +272,11 @@ static int update_values( array_list_t *list,
/* Replace values where needed */
for( i = 0; i < al_get_count(indexes); i++ )
{
int ind = *(int *) al_get(indexes, i) - 1;
/*
The '- 1' below is because the indices in fish are
one-based, but the array_lsit_t uses zero-based indices
*/
long ind = al_get_long(indexes, i) - 1;
void *new = (void *) al_get(values, i);
if( ind <= 0 )
{
@@ -291,18 +292,18 @@ static int update_values( array_list_t *list,
/**
Return 1 if an array list of int* pointers contains the specified
Return 1 if an array list of longs contains the specified
value, 0 otherwise
*/
static int al_contains_int( array_list_t *list,
int val)
static int al_contains_long( array_list_t *list,
long val)
{
int i;
for (i = 0; i < al_get_count(list); i++)
{
int *current = (int *) al_get(list, i);
if( current != 0 && *current == val )
long current = al_get_long(list, i);
if( current != 0 && current == val )
{
return 1;
}
@@ -324,7 +325,7 @@ static void erase_values(array_list_t *list, array_list_t *indexes)
for (i = 0; i < al_get_count(list); i++)
{
if (!al_contains_int(indexes, i + 1))
if (!al_contains_long(indexes, (long)i + 1))
{
al_push(&result, al_get(list, i));
}
@@ -365,9 +366,12 @@ static void print_variables(int include_values, int esc, int scope)
{
wchar_t *value = env_get(key);
wchar_t *e_value;
e_value = esc ? expand_escape_variable(value) : wcsdup(value);
sb_append2(sb_out, L" ", e_value, (void *)0);
free(e_value);
if( value )
{
e_value = esc ? expand_escape_variable(value) : wcsdup(value);
sb_append2(sb_out, L" ", e_value, (void *)0);
free(e_value);
}
}
sb_append(sb_out, L"\n");
@@ -454,6 +458,8 @@ static int builtin_set( wchar_t **argv )
int slice=0;
int i;
wchar_t *bad_char;
/* Parse options to obtain the requested operation and the modifiers */
woptind = 0;
@@ -598,6 +604,13 @@ static int builtin_set( wchar_t **argv )
return retcode;
}
if( list )
{
/* Maybe we should issue an error if there are any other arguments? */
print_variables(0, 0, scope);
return 0;
}
if( woptind == argc )
{
/*
@@ -622,13 +635,6 @@ static int builtin_set( wchar_t **argv )
return retcode;
}
if( list )
{
/* Maybe we should issue an error if there are any other arguments? */
print_variables(0, 0, scope);
return 0;
}
if( !(dest = wcsdup(argv[woptind])))
{
DIE_MEM();
@@ -647,7 +653,15 @@ static int builtin_set( wchar_t **argv )
builtin_print_help( argv[0], sb_err );
return 1;
}
if( (bad_char = wcsvarname( dest ) ) )
{
sb_printf( sb_err, BUILTIN_ERR_VARCHAR, argv[0], *bad_char );
builtin_print_help( argv[0], sb_err );
free( dest );
return 1;
}
if( slice && erase && (scope != ENV_USER) )
{
free( dest );
@@ -675,9 +689,9 @@ static int builtin_set( wchar_t **argv )
al_init(&values);
al_init(&indexes);
al_init(&result);
tokenize_variable_array( env_get(dest), &result );
for( ; woptind<argc; woptind++ )
{
if( !parse_index( &indexes, argv[woptind], dest, al_get_count( &result ) ) )
@@ -749,7 +763,6 @@ static int builtin_set( wchar_t **argv )
al_foreach( &result, &free );
al_destroy( &result );
al_foreach( &indexes, &free );
al_destroy(&indexes);
al_destroy(&values);

173
common.c
View File

@@ -9,10 +9,14 @@ parts of fish.
#include <unistd.h>
#ifdef HAVE_STROPTS
#ifdef HAVE_STROPTS_H
#include <stropts.h>
#endif
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
#include <stdlib.h>
#include <termios.h>
#include <wchar.h>
@@ -20,7 +24,15 @@ parts of fish.
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <sys/stat.h>
#include <unistd.h>
#include <wctype.h>
@@ -284,7 +296,10 @@ char *wcs2str_internal( const wchar_t *in, char *out )
while( in[in_pos] )
{
if( ( in[in_pos] >= ENCODE_DIRECT_BASE) &&
if( in[in_pos] == INTERNAL_SEPARATOR )
{
}
else if( ( in[in_pos] >= ENCODE_DIRECT_BASE) &&
( in[in_pos] < ENCODE_DIRECT_BASE+256) )
{
out[out_pos++] = in[in_pos]- ENCODE_DIRECT_BASE;
@@ -295,7 +310,7 @@ char *wcs2str_internal( const wchar_t *in, char *out )
if( res == (size_t)(-1) )
{
debug( 1, L"Wide character has no narrow representation" );
debug( 1, L"Wide character %d has no narrow representation", in[in_pos] );
memset( &state, 0, sizeof(state) );
}
else
@@ -801,46 +816,22 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
{
switch( in[++in_pos] )
{
/*
A null character after a backslash is an
error, return null
*/
case L'\0':
{
free(in);
return 0;
}
case L'n':
{
in[out_pos]=L'\n';
break;
}
/*
Numeric escape sequences. No prefix means
octal escape, otherwise hexadecimal.
*/
case L'r':
{
in[out_pos]=L'\r';
break;
}
case L't':
{
in[out_pos]=L'\t';
break;
}
case L'b':
{
in[out_pos]=L'\b';
break;
}
case L'e':
{
in[out_pos]=L'\e';
break;
}
case L'u':
case L'U':
case L'x':
case L'X':
case L'0':
case L'1':
case L'2':
@@ -849,6 +840,10 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
case L'5':
case L'6':
case L'7':
case L'u':
case L'U':
case L'x':
case L'X':
{
int i;
long long res=0;
@@ -921,8 +916,106 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
break;
}
/*
\a means bell (alert)
*/
case L'a':
{
in[out_pos]=L'\a';
break;
}
/*
\b means backspace
*/
case L'b':
{
in[out_pos]=L'\b';
break;
}
/*
\cX means control sequence X
*/
case L'c':
{
in_pos++;
if( in[in_pos] >= L'a' &&
in[in_pos] <= (L'a'+32) )
{
in[out_pos]=in[in_pos]-L'a'+1;
}
else if( in[in_pos] >= L'A' &&
in[in_pos] <= (L'A'+32) )
{
in[out_pos]=in[in_pos]-L'A'+1;
}
else
{
free(in);
return 0;
}
break;
}
/*
\e means escape
*/
case L'e':
{
in[out_pos]=L'\x1b';
break;
}
/*
\f means form feed
*/
case L'f':
{
in[out_pos]=L'\f';
break;
}
/*
\n means newline
*/
case L'n':
{
in[out_pos]=L'\n';
break;
}
/*
\r means carriage return
*/
case L'r':
{
in[out_pos]=L'\r';
break;
}
/*
\t means tab
*/
case L't':
{
in[out_pos]=L'\t';
break;
}
/*
\v means vetrical tab
*/
case L'v':
{
in[out_pos]=L'\v';
break;
}
default:
{
in[out_pos++] = INTERNAL_SEPARATOR;
in[out_pos]=in[in_pos];
break;
}
@@ -930,7 +1023,8 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
}
else
{
switch( in[in_pos]){
switch( in[in_pos])
{
case L'~':
{
if( unescape_special && (in_pos == 0) )
@@ -1408,10 +1502,15 @@ int acquire_lock_file( const char *lockfile, const int timeout, int force )
void common_handle_winch( int signal )
{
#ifdef HAVE_WINSIZE
if (ioctl(1,TIOCGWINSZ,&termsize)!=0)
{
return;
}
#else
termsize.ws_col = 80;
termsize.ws_row = 24;
#endif
}
int common_get_width()

View File

@@ -3,6 +3,8 @@
These functions are used for storing and retrieving tab-completion data, as well as for performing tab-completion.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
@@ -20,7 +22,6 @@
#include <signal.h>
#include <wchar.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -587,7 +588,7 @@ static void parse_cmd_string( void *context,
Use the empty string as the 'path' for commands that can
not be found.
*/
path = wcsdup(L"");
path = halloc_wcsdup( context, L"");
}
/* Make sure the path is not included in the command */
@@ -1080,7 +1081,7 @@ static void copy_strings_with_prefix( array_list_t *comp_out,
wchar_t *wc, *tmp;
tmp = expand_one( 0,
wcsdup(wc_escaped), EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_WILDCARDS);
wcsdup(wc_escaped), EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_WILDCARDS);
if(!tmp)
return;
@@ -1785,14 +1786,14 @@ static void complete_param_expand( wchar_t *str,
}
/*
debug( 3,
L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | %ls );",
L"expand_string( \"%ls\", comp_out, EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | %ls );",
comp_str,
do_file?L"0":L"EXPAND_SKIP_WILDCARDS" );
*/
expand_string( 0,
wcsdup(comp_str),
comp_out,
EXPAND_SKIP_SUBSHELL | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
EXPAND_SKIP_CMDSUBST | ACCEPT_INCOMPLETE | (do_file?0:EXPAND_SKIP_WILDCARDS) );
}
/**
@@ -1819,20 +1820,27 @@ static int complete_variable( const wchar_t *var,
if( wcsncmp( var, name, varlen) == 0 )
{
wchar_t *value = expand_escape_variable( env_get( name ));
wchar_t *value_unescaped, *value;
wchar_t *blarg;
/*
Variable description is 'Variable: VALUE
*/
blarg = wcsdupcat2( &name[varlen], COMPLETE_SEP_STR, COMPLETE_VAR_DESC_VAL, value, 0 );
if( blarg )
value_unescaped = env_get( name );
if( value_unescaped )
{
res =1;
al_push( comp, blarg );
value = expand_escape_variable( value_unescaped );
/*
Variable description is 'Variable: VALUE
*/
blarg = wcsdupcat2( &name[varlen], COMPLETE_SEP_STR, COMPLETE_VAR_DESC_VAL, value, 0 );
if( blarg )
{
res =1;
al_push( comp, blarg );
}
free( value );
}
free( value );
}
}
@@ -2129,6 +2137,14 @@ void complete( const wchar_t *cmd,
int do_file;
do_file = complete_param( current_command, prev_token, current_token, comp );
/*
If we have found no command specific completions at
all, fall back to using file completions.
*/
if( !al_get_count( comp ) )
do_file = 1;
complete_param_expand( current_token, comp, do_file );
}
}

View File

@@ -66,6 +66,10 @@
*/
#define PROG_COMPLETE_SEP L'\t'
/**
Terminator for completions sent to the fish_pager
*/
#define COMPLETE_TERMINATOR L'\006'
/**

View File

@@ -1,5 +1,15 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(fish,1.21.10,fish-users@lists.sf.net)
#
# This file is the main build configuration file for fish. It is used
# to determine your systems capabilities, and tried to adapt fish to
# take maximum advantage of the services your system offers.
#
# Process this file using the 'autoconf' to produce a working
# configure script, which should in turn be executed in order to
# configure the build process.
#
AC_INIT(fish,1.21.12,fish-users@lists.sf.net)
# If needed, run autoconf to regenerate the configure file
AC_MSG_CHECKING([if autoconf needs to be run])
@@ -11,12 +21,15 @@ if test configure -ot configure.ac; then
AC_MSG_NOTICE([running autoconf])
if autoconf; then
./configure "$@"
exit
fi
exit
exit 1
else
AC_MSG_ERROR( [cannot find the autoconf program in your path.
AC_MSG_ERROR(
[cannot find the autoconf program in your path.
This program needs to be run whenever the configure.ac file is modified.
Please install it and try again.])
Please install it and try again.]
)
fi
else
AC_MSG_RESULT([no])
@@ -29,11 +42,13 @@ if test ! -f ./config.h.in -o config.h.in -ot configure.ac; then
AC_MSG_RESULT([yes])
if which autoheader >/dev/null; then
AC_MSG_NOTICE([running autoheader])
autoheader
autoheader || exit 1
else
AC_MSG_ERROR( [cannot find the autoheader program in your path.
AC_MSG_ERROR(
[cannot find the autoheader program in your path.
This program needs to be run whenever the configure.ac file is modified.
Please install it and try again.])
Please install it and try again.]
)
fi
else
AC_MSG_RESULT([no])
@@ -87,11 +102,15 @@ AC_PROG_INSTALL
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
# Optionally drop xsel command
AC_ARG_WITH( xsel,
AC_HELP_STRING([--without-xsel],
[do not build the xsel program needed for X clipboard integration]),
[xsel=$withval],
[xsel=with_xsel] )
AC_ARG_WITH(
xsel,
AC_HELP_STRING(
[--without-xsel],
[do not build the xsel program needed for X clipboard integration]
),
[xsel=$withval],
[xsel=with_xsel]
)
if [[ "$xsel" = "with_xsel" ]]; then
AC_SUBST( XSEL,[xsel-0.9.6/xsel])
@@ -103,31 +122,44 @@ else
AC_SUBST( XSEL_MAN_PATH,[ ])
fi
# These help out with getting better prototypes on some platforms
#
# Test if the compiler accepts the -std=c99 flag. If so, using it
# increases the odds of correct compilation, since we want to use the
# *wprintf functions, which where defined in C99.
#
# *wprintf functions, which where defined in C99.
XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
XCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)
AC_CACHE_VAL(local_cv_has__std_c99,[
AC_TRY_RUN([
#include <stdlib.h>
#include <stdio.h>
AC_CACHE_VAL(
local_cv_has__std_c99,
[
AC_TRY_RUN(
[
#include <stdlib.h>
#include <stdio.h>
int main() {
return 0;
}],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)])
int main()
{
return 0;
}
],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)
]
)
AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno) CFLAGS="$XCFLAGS" ;;
xno)
CFLAGS="$XCFLAGS"
CPPFLAGS="$XCPPFLAGS" ;;
esac
#
# If we are using gcc, set some flags that increase the odds of the
# compiler producing a working binary...
@@ -137,7 +169,7 @@ if test "$CC" = gcc; then
#
# -fno-optimize-sibling-calls seems to work around a bug where
# sending a SIGWINCH to fish on NetBSD causes fish to exit when
# sending a SIGWINCH to fish on NetBSD 3.0 causes fish to exit when
# compiled with GCC 3.3.3. This is probably either a compiler bug
# or a libc bug, but adding this flag seems to fix things for
# now. Long term, the real problem should be tracked down and
@@ -164,16 +196,24 @@ fi
AC_MSG_CHECKING([if we are compiling against glibc])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
#include <stdlib.h>
#ifdef __GLIBC__
#define STATUS 0
#else
#define STATUS 1
#endif],
[return STATUS;])],
[
AC_LANG_PROGRAM(
[
#include <stdlib.h>
#ifdef __GLIBC__
#define STATUS 0
#else
#define STATUS 1
#endif
],
[
return STATUS;
]
)
],
[glibc=yes],
[glibc=no] )
[glibc=no]
)
if test "$glibc" = yes; then
AC_MSG_RESULT(yes)
@@ -185,8 +225,8 @@ if test "$glibc" = yes; then
# fallback.h, in order to keep fish working on non-gnu platforms.
#
CFLAGS="$CFLAGS -D _GNU_SOURCE -D _ISOC99_SOURCE"
AC_DEFINE( _GNU_SOURCE, 1, [Macro to enable additional prototypes under Glibc])
AC_DEFINE( _ISOC99_SOURCE, 1, [Macro to enable additional prototypes under Glibc])
else
AC_MSG_RESULT(no)
fi
@@ -206,6 +246,33 @@ if test $target_cpu = powerpc; then
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
fi
# Solaris-specific flags go here
AC_MSG_CHECKING([if we are under Solaris])
case $target_os in
solaris*)
AC_DEFINE( __EXTENSIONS__, 1, [Macro to enable additional prototypes under Solaris])
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac
# BSD-specific flags go here
AC_MSG_CHECKING([if we are under BSD])
case $target_os in
*bsd*)
AC_DEFINE( __BSD_VISIBLE, 1, [Macro to enable additional prototypes under BSD])
AC_DEFINE( _NETBSD_SOURCE, 1, [Macro to enable additional prototypes under BSD])
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac
# Set up PREFIX and related preprocessor symbols. Fish needs to know
# where it will be installed. One of the reasons for this is so that
@@ -240,8 +307,11 @@ AC_CHECK_FILES([/proc/self/stat])
# This is ued to tell the wgetopt library to translate strings. This
# way wgetopt can be dropped into any project without requiring i18n.
AC_DEFINE([HAVE_TRANSLATE_H], [1],
[Define to 1 if the wgettext function should be used for translating strings.])
AC_DEFINE(
[HAVE_TRANSLATE_H],
[1],
[Define to 1 if the wgettext function should be used for translating strings.]
)
# Check for presense of various libraries
AC_SEARCH_LIBS( gettext, intl,,)
@@ -250,16 +320,142 @@ AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, need
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
# Check for presense of various header files
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h])
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h])
AC_CHECK_HEADER([regex.h],
[AC_DEFINE([HAVE_REGEX_H], [1], [Define to 1 if you have the <regex.h> header file.])],
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])])
AC_CHECK_HEADER(
[regex.h],
[
AC_DEFINE(
[HAVE_REGEX_H],
[1],
[Define to 1 if you have the <regex.h> header file.]
)],
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])
]
)
#
# On some platforms (Solaris 10) adding -std=c99 in turn requires that
# _POSIX_C_SOURCE be defined to 200112L otherwise several
# POSIX-specific, non-ISO-C99 types/prototypes are made unavailable
# e.g. siginfo_t. Defining _XOPEN_SOURCE to 600 is compatible with
# the _POSIX_C_SOURCE value and provides a little assurance that
# extension functions' prototypes are available, e.g. killpg().
#
# Some other platforms (OS X), will remove types/prototypes/macros
# e.g. SIGWINCH if either _POSIX_C_SOURCE or _XOPEN_SOURCE is defined.
#
# This test adds these macros only if they enable a program that uses
# both Posix and non-standard features to compile, and that program
# does not compile without these macros.
#
# We try to make everyone happy.
#
# The ordering of the various autoconf tests is very critical as well:
#
# * This test needs to be run _after_ header detection tests, so that
# the proper headers are included.
#
# * This test needs to be run _before_ testing for the presense of any
# prototypes or other language functinality.
#
# * This test should be (but does not need to be) run after the
# conditional definition of __EXTENSIONS__, to avoid redundant tests.
XCFLAGS="$CFLAGS"
echo Checking how to use -D_XOPEN_SOURCE=600 and -D_POSIX_C_SOURCE=200112L...
local_found_posix_switch=no
for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"; do
AC_MSG_CHECKING( if switches \"$i\" works)
CFLAGS="$XCFLAGS $i"
#
# Try to run this program, which should test various extensions
# and Posix functionality. If this program works, then everything
# should work. Hopefully.
#
AC_TRY_LINK(
[
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
/* POSIX, C89 and C99: POSIX extends this header.
* For: kill(), killpg(), siginfo_t, sigset_t,
* struct sigaction, sigemptyset(), sigaction(),
* SIGIO and SIGWINCH. */
#include <signal.h>
#ifdef HAVE_SIGINFO_H
/* Neither POSIX, C89 nor C99: Solaris-specific (others?).
* For: siginfo_t (also defined by signal.h when in
* POSIX/extensions mode). */
#include <siginfo.h>
#endif
#ifdef HAVE_SYS_TERMIOS_H
/* Neither POSIX, C89 nor C99: a common extension.
* For: TIOCGWINSZ and struct winsize (under at least
* Solaris, NetBSD and (dual-listed) FreeBSD). */
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
/* As above (under at least Linux and FreeBSD). */
#include <sys/ioctl.h>
#endif
],
[
/* Avert high-level optimisation, by making the program's
* return value depend on all tested identifiers. */
int ret = 0;
/* POSIX only: might be unhidden by _POSIX_C_SOURCE. */
struct sigaction sa;
sigset_t ss;
siginfo_t info;
ret += (int)(void *)&info + kill( 0, 0 ) +
sigaction( 0, &sa, 0 ) + sigemptyset( &ss );
/* Extended-POSIX: might be unhidden by _XOPEN_SOURCE. */
ret += killpg( 0, 0 );
/* Non-standard: might be hidden by the macros. */
{
struct winsize termsize;
ret += (int)(void *)&termsize;
ret += SIGWINCH + TIOCGWINSZ + SIGIO;
}
return ret;
],
local_cv_use__posix_c_source=yes,
local_cv_use__posix_c_source=no,
)
if test x$local_cv_use__posix_c_source = xyes; then
AC_MSG_RESULT( yes )
local_found_posix_switch=yes
break;
else
AC_MSG_RESULT( no )
fi
done
# We didn't find any combination of switches that worked - revert to
# no switches and hope that the fallbacks work. A warning will be
# printed at the end of the configure script.
if test ! x$local_found_posix_switch = xyes; then
CFLAGS="$XCFLAGS"
fi
# Check for presense of various functions
AC_CHECK_FUNCS( gettext wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
AC_CHECK_FUNCS( futimes wcwidth wcswidth getopt_long wcstok fputwc fgetwc )
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r)
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r killpg)
# The Makefile also needs to know if we have gettext, so it knows if the translations should be installed.
AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 ) )
@@ -270,72 +466,174 @@ AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 )
# Check if realpath accepts null for its second argument
AC_MSG_CHECKING([if realpath accepts null for its second argument])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
#include <limits.h>
#include <errno.h>
#include <stdlib.h>],
[int status; char *res; res = realpath( "somefile", 0 ); status = !(res != 0 || errno == ENOENT); exit( status );])],
[
AC_LANG_PROGRAM(
[
#include <limits.h>
#include <errno.h>
#include <stdlib.h>
],
[
int status;
char *res;
res = realpath( "somefile", 0 );
status = !(res != 0 || errno == ENOENT);
exit( status );
]
)
],
[have_realpath_null=yes],
[have_realpath_null=no] )
[have_realpath_null=no]
)
if test "$have_realpath_null" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_REALPATH_NULL], [1],
[Define to 1 if realpath accepts null for its second argument.])
AC_DEFINE(
[HAVE_REALPATH_NULL],
[1],
[Define to 1 if realpath accepts null for its second argument.]
)
else
AC_MSG_RESULT(no)
fi
# Check if struct winsize exists
AC_MSG_CHECKING([if struct winsize and TIOCGWINSZ exist])
AC_LINK_IFELSE(
[
AC_LANG_PROGRAM(
[
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
],
[
struct winsize termsize = {0};
TIOCGWINSZ;
]
)
],
[
AC_MSG_RESULT(yes);
AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])
],
[
AC_MSG_RESULT(no)
]
)
# If we have a fwprintf in libc, test that it actually works. As of
# March 2006, it is broken under Dragonfly BSD.
if test "$ac_cv_func_fwprintf" = yes; then
AC_MSG_CHECKING([if fwprintf is broken])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
],
[
setlocale( LC_ALL, "" );
fwprintf( stderr, L"%ls%ls", L"", L"fish:" );
])],
[
AC_LANG_PROGRAM(
[
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
],
[
setlocale( LC_ALL, "" );
fwprintf( stderr, L"%ls%ls", L"", L"fish:" );
]
)
],
[
AC_MSG_RESULT(no)
],
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_BROKEN_FWPRINTF], [1], [Define to 1 one if the implemented fwprintf is broken])
] )
]
)
fi
# Check for _nl_msg_cat_cntr symbol
AC_MSG_CHECKING([for _nl_msg_cat_cntr symbol])
AC_TRY_LINK([#if HAVE_LIBINTL_H]
[#include <libintl.h>]
[#endif],
[extern int _nl_msg_cat_cntr;]
[int tmp = _nl_msg_cat_cntr; exit(tmp);], have__nl_msg_cat_cntr=yes, have__nl_msg_cat_cntr=no)
AC_TRY_LINK(
[
#if HAVE_LIBINTL_H
#include <libintl.h>
#endif
],
[
extern int _nl_msg_cat_cntr;
int tmp = _nl_msg_cat_cntr;
exit(tmp);
],
have__nl_msg_cat_cntr=yes,
have__nl_msg_cat_cntr=no
)
if test "$have__nl_msg_cat_cntr" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE__NL_MSG_CAT_CNTR], [1],
[Define to 1 if the _nl_msg_cat_cntr symbol is exported.])
AC_DEFINE(
[HAVE__NL_MSG_CAT_CNTR],
[1],
[Define to 1 if the _nl_msg_cat_cntr symbol is exported.]
)
else
AC_MSG_RESULT(no)
fi
# Check if we are using basic BSD curses - in that case we redefine
# Check if getopt_long exists and works
AC_MSG_CHECKING([if getopt_long exists and works])
AC_TRY_LINK(
[
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
],
[
static struct option
long_options[] =
{
0, 0, 0, 0
}
;
int opt = getopt_long( 0,
0,
0,
long_options,
0 );
],
have_working_getopt_long=yes,
have_working_getopt_long=no
)
if test "$have_working_getopt_long" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE_WORKING_GETOPT_LONG],
[1],
[Define to 1 if getopt_long exists and works.]
)
else
AC_MSG_RESULT(no)
fi
# Check if del_curterm is broken - in that case we redefine
# del_curterm as a no-op, to avoid a double-free
AC_MSG_CHECKING([If we are using BSD curses])
AC_MSG_CHECKING([If del_curterm is broken])
case $target_os in
*bsd*)
AC_MSG_RESULT(yes)
AC_CHECK_LIB( ncurses, del_curterm, true, [AC_DEFINE([HAVE_BROKEN_DEL_CURTERM],[1],[We are using basic BSD curses, redefine del_curterm to a no-op to avoid a double-free bug])])
AC_DEFINE(
[HAVE_BROKEN_DEL_CURTERM],
[1],
[del_curterm is broken, redefine it to a no-op to avoid a double-free bug]
)
;;
*)
AC_MSG_RESULT(no)
@@ -346,5 +644,11 @@ esac
AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile seq])
AC_OUTPUT
if test ! x$local_found_posix_switch = xyes; then
echo "Can't find a combination of switches to enable common extensions like detecting window size."
echo "Some fish features may be disabled."
fi
echo "fish is now configured."
echo "Use 'make' and 'make install' to build and install fish."

View File

@@ -2,6 +2,8 @@
The length command, used for determining the number of items in an
environment variable array.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>

View File

@@ -105,11 +105,14 @@ would remove the two files 'cumbersome' and 'filename.txt'.
Some characters can not be written directly on the command line. For
these characters, so called escape sequences are provided. These are:
- <code>'\\n'</code>, escapes a newline character
- <code>'\\t'</code>, escapes the tab character
- <code>'\\a'</code>, escapes the alert character
- <code>'\\b'</code>, escapes the backspace character
- <code>'\\r'</code>, escapes the carriage return character
- <code>'\\e'</code>, escapes the escape character
- <code>'\\f'</code>, escapes the form feed character
- <code>'\\n'</code>, escapes a newline character
- <code>'\\r'</code>, escapes the carriage return character
- <code>'\\t'</code>, escapes the tab character
- <code>'\\v'</code>, escapes the vertical tab character
- <code>'\\ '</code>, escapes the space character
- <code>'\\$'</code>, escapes the dollar character
- <code>'\\\\'</code>, escapes the backslash character
@@ -259,7 +262,7 @@ $argv</code> should be called when ll is invoked. $argv is an array
variable, which always contains all arguments sent to the function. In
the example above, these are simply passed on to the ls command. For
more information on functions, see the documentation for the <a
href='builtin.html#function'>function</a> builtin.
href='builtins.html#function'>function</a> builtin.
\subsubsection Autoloading functions
@@ -493,7 +496,7 @@ shells allow you to specify a variable name using '$VARNAME' or
'${VARNAME}'. Fish supports the former, and has no support whatsoever
for the latter or anything like it. So what is '{$VARNAME}' then?
Well, '{WHATEVER}' is <a href='#brace'>brace expansion</a>, identical
to that supported by Posix shells, i.e. 'a{b,c}d' -> 'abd acd' works
to that supported by e.g. bash. 'a{b,c}d' -> 'abd acd' works
both in bash and on fish. So '{$VARNAME}' is a bracket-expansion with
only a single element, i.e. it becomes expanded to '$VARNAME', which
will be variable expanded to the value of the variable 'VARNAME'. So
@@ -1156,9 +1159,9 @@ When defining a new function in fish, it is possible to make it into an
event handler, i.e. a function that is automatically run when a
specific event takes place. Events that can trigger a handler currently are:
* When a signal is delivered
* When a process or job exits
* When the value of a variable is updated
- When a signal is delivered
- When a process or job exits
- When the value of a variable is updated
Example:
@@ -2454,6 +2457,7 @@ DAMAGES.
- <a href='#faq-cd-implicit'>I accidentally entered a directory path and fish changed directory. What happened?</a>
- <a href='#faq-open'>The open command doesn't work.</a>
- <a href='#faq-default'>How do I make fish my default shell?</a>
- <a href='#faq-titlebar'>I'm seeing weird output before each prompt when using screen. What's wrong?</a>
<hr>
@@ -2525,6 +2529,34 @@ package manager), you first need to add fish to the list of shells by
executing the following command (assuming you installed fish in
/usr/local) as root:
\section faq-titlebar I'm seeing weird output before each prompt when using screen. What's wrong?
Quick answer:
Add
<pre>
function fish_title;end
</pre>
To your ~/.fish file. Problem solved.
The long answer:
Fish is trying to set the titlebar message of your terminal. While
screen itself supports this feature, your terminal does
not. Unfortuntaly, when the underlying terminal doesn't support
setting the titlebar, screen simply passes through the escape codes
and text to the underlying terminal instead of ignoring them. It is
impossible detect and resolve this problem from inside fish since fish
has no way of knowing what the underlying terminal type is. For now,
the only way to fix this is to unset the titlebar message, as
suggested above.
Note that fish has a default titlebar message, so simply unsetting the
fish_title function will not work.
<code>echo /usr/local/bin/fish >>/etc/shells</code>
If you installed a prepackaged version of fish, the package manager

View File

@@ -11,7 +11,7 @@ This builtin command is used to print or erase functions.
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function
- <code>-e</code> or <code>--erase</code> causes the specified functions to be erased.
- <code>-h</code> or <code>--help</code> display a help message and exit
- <code>-n</code> or <code>--names</code> list only the names of all defined functions
- <code>-n</code> or <code>--names</code> list only the names of all defined functions, not their definition
- <code>-q</code> or <code>--query</code> test if the specified functions exist. Does not output anything, but the builtins exit status is the number of functions specified that were not defined.
The default behavior of \c functions when called with no arguments,

View File

@@ -15,7 +15,7 @@ The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_N
- <code>-l</code> or <code>--local</code> forces the specified environment variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
- <code>-g</code> or <code>--global</code> causes the specified environment variable to be given a global scope. Non-global variables disappear when the block they belong to ends
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
- <code>-n</code> or <code>--names</code> List only the names of all defined variables
- <code>-n</code> or <code>--names</code> List only the names of all defined variables, not their value
- <code>-q</code> or <code>--query</code> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes

View File

@@ -7,8 +7,8 @@
\subsection trap-description Description
Trap is a shellscript wrapper around the fish event delivery
framework. IT is defined for backwards compatibility reasons. For
other uses, it is recommended to define a <a
framework. It exists for backwards compatibility with Posix
shells. For other uses, it is recommended to define a <a
href='index.html#event'>event handler</a>.
- ARG is the command to be executed on signal delivery

View File

@@ -22,7 +22,7 @@ value. Other options are interpreted as follows:
- <code>-a</code> or <code>--all</code> Set or get all current limits
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created
- <code>-d</code> or <code>--data-size</code> The maximum size of a process’s data segment
- <code>-d</code> or <code>--data-size</code> The maximum size of a process's data segment
- <code>-f</code> or <code>--file-size</code> The maximum size of files created by the shell
- <code>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory
- <code>-m</code> or <code>--resident-set-size</code> The maximum resident set size

10
env.c
View File

@@ -457,6 +457,8 @@ void env_init()
char **p;
struct passwd *pw;
wchar_t *uname;
wchar_t *version;
sb_init( &dyn_var );
b_init( &export_buffer );
@@ -468,6 +470,7 @@ void env_init()
hash_put( &env_read_only, L"status", L"" );
hash_put( &env_read_only, L"history", L"" );
hash_put( &env_read_only, L"version", L"" );
hash_put( &env_read_only, L"_", L"" );
hash_put( &env_read_only, L"LINES", L"" );
hash_put( &env_read_only, L"COLUMNS", L"" );
@@ -555,6 +558,13 @@ void env_init()
env_set( L"USER", uname, ENV_GLOBAL | ENV_EXPORT );
free( uname );
}
/*
Set up the version variable
*/
version = str2wcs( PACKAGE_VERSION );
env_set( L"version", version, ENV_GLOBAL );
free( version );
env_universal_init( env_get( L"FISHD_SOCKET_DIR"),
env_get( L"USER" ),

1
env.h
View File

@@ -129,7 +129,6 @@ char **env_export_arr( int recalc );
/**
Insert all variable names into l. These are not copies of the strings and should not be freed after use.
*/
void env_get_names( array_list_t *l, int flags );

View File

@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -25,6 +25,10 @@
#include <ncurses/term.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <signal.h>
#include "fallback.h"

View File

@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <strings.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -28,6 +28,10 @@
#include <signal.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include "fallback.h"
#include "util.h"

View File

@@ -3,6 +3,8 @@
Functions for handling event triggers
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -11,8 +13,6 @@
#include <signal.h>
#include <string.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -540,7 +540,7 @@ static void event_fire_delayed()
free( blocked );
blocked = new_blocked;
}
while( sig_list[active_list].count > 0 )
{
signal_list_t *lst;

191
exec.c
View File

@@ -5,6 +5,8 @@
manual, though I the changes performed have been massive.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
@@ -21,7 +23,9 @@
#include <assert.h>
#include <dirent.h>
#include "config.h"
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
#include "fallback.h"
#include "util.h"
@@ -75,7 +79,6 @@ static array_list_t *open_fds=0;
static int set_child_group( job_t *j, process_t *p, int print_errors );
void exec_close( int fd )
{
int i;
@@ -94,13 +97,12 @@ void exec_close( int fd )
{
for( i=0; i<al_get_count( open_fds ); i++ )
{
int n = (int)(long)al_get( open_fds, i );
int n = (int)al_get_long( open_fds, i );
if( n == fd )
{
al_set( open_fds,
i,
al_get( open_fds,
al_get_count( open_fds ) -1 ) );
al_set_long( open_fds,
i,
al_get_long( open_fds, al_get_count( open_fds ) -1 ) );
al_truncate( open_fds,
al_get_count( open_fds ) -1 );
break;
@@ -130,8 +132,8 @@ int exec_pipe( int fd[2])
open_fds = al_halloc( global_context );
}
al_push( open_fds, (void *)(long)fd[0] );
al_push( open_fds, (void *)(long)fd[1] );
al_push_long( open_fds, (long)fd[0] );
al_push_long( open_fds, (long)fd[1] );
return res;
}
@@ -176,7 +178,7 @@ static void close_unused_internal_pipes( io_data_t *io )
{
for( ;i<al_get_count( open_fds ); i++ )
{
int n = (int)(long)al_get( open_fds, i );
int n = (long)al_get_long( open_fds, i );
if( !use_fd_in_pipe( n, io) )
{
debug( 4, L"Close fd %d, used in other context", n );
@@ -439,7 +441,9 @@ static void launch_process( process_t *p )
{
// debug( 1, L"exec '%ls'", p->argv[0] );
execve (wcs2str(p->actual_cmd), wcsv2strv( (const wchar_t **) p->argv), env_export_arr( 0 ) );
execve ( wcs2str(p->actual_cmd),
wcsv2strv( (const wchar_t **) p->argv),
env_export_arr( 0 ) );
debug( 0,
_( L"Failed to execute process '%ls'" ),
p->actual_cmd );
@@ -607,21 +611,21 @@ static int set_child_group( job_t *j, process_t *p, int print_errors )
if( j->job_control )
{
int new_pgid=0;
if (!j->pgid)
{
new_pgid=1;
j->pgid = p->pid;
}
if( setpgid (p->pid, j->pgid) )
{
{
if( getpgid( p->pid) != j->pgid && print_errors )
{
debug( 1,
_( L"Could not send process %d from group %d to group %d" ),
p->pid,
_( L"Could not send process %d, '%ls' in job %d, '%ls' from group %d to group %d" ),
p->pid,
p->argv[0],
j->job_id,
j->command,
getpgid( p->pid),
j->pgid );
wperror( L"setpgid" );
@@ -669,16 +673,48 @@ void exec( job_t *j )
*/
int exec_error=0;
int needs_keepalive = 0;
process_t keepalive;
CHECK( j, );
if( no_exec )
return;
sigemptyset( &chldset );
sigaddset( &chldset, SIGCHLD );
debug( 4, L"Exec job '%ls' with id %d", j->command, j->job_id );
if( block_io )
{
if( j->io )
j->io = io_add( io_duplicate( j, block_io), j->io );
else
j->io=io_duplicate( j, block_io);
}
io_data_t *input_redirect = io_get( j->io, 0 );
if( input_redirect &&
(input_redirect->io_mode == IO_BUFFER) &&
input_redirect->param3.is_input )
{
/*
Input redirection - create a new gobetween process to take
care of buffering
*/
process_t *fake = halloc( j, sizeof(process_t) );
fake->type = INTERNAL_BUFFER;
fake->pipe_fd = 1;
fake->next = j->first_process;
j->first_process = fake;
}
if( j->first_process->type==INTERNAL_EXEC )
{
/*
@@ -703,7 +739,7 @@ void exec( job_t *j )
j->first_process->completed=1;
return;
}
}
pipe_read.fd=0;
@@ -716,20 +752,61 @@ void exec( job_t *j )
pipe_write.next=0;
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=-1;
//fwprintf( stderr, L"Run command %ls\n", j->command );
if( block_io )
{
if( j->io )
j->io = io_add( io_duplicate( j, block_io), j->io );
else
j->io=io_duplicate( j, block_io);
}
//fwprintf( stderr, L"Run command %ls\n", j->command );
j->io = io_add( j->io, &pipe_write );
signal_block();
/*
See if we need to create a group keepalive process. This is a
process that we create to make sure that the process group
doesn't die accidentally, and is needed when a block/function is
inside a pipeline.
*/
if( j->job_control )
{
for( p=j->first_process; p; p = p->next )
{
if( (p->type == INTERNAL_BLOCK ) ||
(p->type == INTERNAL_FUNCTION ) )
{
if( p->next )
{
needs_keepalive = 1;
break;
}
}
}
}
if( needs_keepalive )
{
keepalive.pid = fork();
if( keepalive.pid == 0 )
{
keepalive.pid = getpid();
set_child_group( j, &keepalive, 1 );
pause();
exit(0);
}
else if( keepalive.pid < 0 )
{
/* The fork failed. */
debug( 0, FORK_ERROR );
wperror (L"fork");
exit (1);
}
else
{
set_child_group( j, &keepalive, 0 );
}
}
/*
This loop loops over every process_t in the job, starting it as
appropriate. This turns out to be rather complex, since a
@@ -742,7 +819,7 @@ void exec( job_t *j )
{
mypipe[1]=-1;
skip_fork=0;
pipe_write.fd = p->pipe_fd;
/*
@@ -811,7 +888,7 @@ void exec( job_t *j )
if( p->next )
{
io_buffer = io_buffer_create();
io_buffer = io_buffer_create( 0 );
j->io = io_add( j->io, io_buffer );
}
@@ -827,7 +904,7 @@ void exec( job_t *j )
{
if( p->next )
{
io_buffer = io_buffer_create();
io_buffer = io_buffer_create( 0 );
j->io = io_add( j->io, io_buffer );
}
@@ -835,7 +912,7 @@ void exec( job_t *j )
break;
}
case INTERNAL_BUILTIN:
{
int builtin_stdin=0;
@@ -945,6 +1022,7 @@ void exec( job_t *j )
switch( p->type )
{
case INTERNAL_BLOCK:
case INTERNAL_FUNCTION:
{
@@ -1025,6 +1103,46 @@ void exec( job_t *j )
break;
}
case INTERNAL_BUFFER:
{
pid = fork();
if( pid == 0 )
{
/*
This is the child process. Write out the contents of the pipeline.
*/
p->pid = getpid();
setup_child_process( j, p );
write( 1,
input_redirect->param2.out_buffer->buff,
input_redirect->param2.out_buffer->used );
exit( 0 );
}
else if( pid < 0 )
{
/* The fork failed. */
debug( 0, FORK_ERROR );
wperror (L"fork");
exit (1);
}
else
{
/*
This is the parent process. Store away
information on the child, and possibly give
it control over the terminal.
*/
p->pid = pid;
set_child_group( j, p, 0 );
}
break;
}
case INTERNAL_BUILTIN:
{
@@ -1125,7 +1243,7 @@ void exec( job_t *j )
p->pid = getpid();
setup_child_process( j, p );
launch_process( p );
/*
launch_process _never_ returns...
*/
@@ -1181,6 +1299,15 @@ void exec( job_t *j )
}
}
/*
The keepalive process is no longer needed, so we terminate it
with extreme prejudice
*/
if( needs_keepalive )
{
kill( keepalive.pid, SIGKILL );
}
signal_unblock();
debug( 3, L"Job is constructed" );
@@ -1222,7 +1349,7 @@ int exec_subshell( const wchar_t *cmd,
}
is_subshell=1;
io_buffer= io_buffer_create();
io_buffer= io_buffer_create( 0 );
prev_status = proc_get_last_status();

227
expand.c
View File

@@ -5,6 +5,8 @@ parameter expansion.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -26,8 +28,6 @@ parameter expansion.
#include <procfs.h>
#endif
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -44,6 +44,7 @@ parameter expansion.
#include "complete.h"
#include "parse_util.h"
#include "halloc.h"
#include "halloc_util.h"
/**
@@ -743,6 +744,55 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
}
static int parse_slice( wchar_t *in, wchar_t **end_ptr, array_list_t *idx )
{
wchar_t *end;
int pos = 1;
// debug( 0, L"parse_slice on '%ls'", in );
while( 1 )
{
long tmp;
while( iswspace(in[pos]) || (in[pos]==INTERNAL_SEPARATOR))
pos++;
if( in[pos] == L']' )
{
pos++;
break;
}
errno=0;
tmp = wcstol( &in[pos], &end, 10 );
if( ( errno ) || ( end == &in[pos] ) )
{
return 1;
}
// debug( 0, L"Push idx %d", tmp );
al_push_long( idx, tmp );
pos = end-in;
}
if( end_ptr )
{
// debug( 0, L"Remainder is '%ls', slice def was %d characters long", in+pos, pos );
*end_ptr = in+pos;
}
// debug( 0, L"ok, done" );
return 0;
}
/**
Expand all environment variables in the string *ptr.
@@ -841,44 +891,22 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
int all_vars=1;
array_list_t var_item_list;
al_init( &var_item_list );
if( in[stop_pos] == L'[' )
{
wchar_t *end;
all_vars = 0;
stop_pos++;
while( 1 )
wchar_t *slice_end;
all_vars=0;
if( parse_slice( &in[stop_pos], &slice_end, var_idx_list ) )
{
long tmp;
while( iswspace(in[stop_pos]) || (in[stop_pos]==INTERNAL_SEPARATOR))
stop_pos++;
if( in[stop_pos] == L']' )
{
stop_pos++;
break;
}
errno=0;
tmp = wcstol( &in[stop_pos], &end, 10 );
if( ( errno ) || ( end == &in[stop_pos] ) )
{
error( SYNTAX_ERROR,
-1,
L"Expected integer or \']\'" );
is_ok = 0;
break;
}
al_push( var_idx_list, (void *)tmp );
stop_pos = end-in;
}
}
error( SYNTAX_ERROR,
-1,
L"Invalid index value" );
is_ok = 0;
}
stop_pos = (slice_end-in);
}
if( is_ok )
{
tokenize_variable_array( var_val, &var_item_list );
@@ -887,12 +915,17 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
int j;
for( j=0; j<al_get_count( var_idx_list ); j++)
{
long tmp = (long)al_get( var_idx_list, j );
long tmp = al_get_long( var_idx_list, j );
if( tmp < 0 )
{
tmp = al_get_count( &var_item_list)+tmp+1;
}
/*
Check that we are within array
bounds. If not, truncate the list to
exit.
*/
if( tmp < 1 || tmp > al_get_count( &var_item_list ) )
{
error( SYNTAX_ERROR,
@@ -904,12 +937,11 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
}
else
{
/* Move string from list l to list idx */
al_set( var_idx_list, j, al_get( &var_item_list, tmp-1 ) );
al_set( &var_item_list, tmp-1, 0 );
/* Replace each index in var_idx_list inplace with the string value at the specified index */
al_set( var_idx_list, j, wcsdup(al_get( &var_item_list, tmp-1 ) ) );
}
}
/* Free remaining strings in list l and truncate it */
/* Free strings in list var_item_list and truncate it */
al_foreach( &var_item_list, &free );
al_truncate( &var_item_list, 0 );
/* Add items from list idx back to list l */
@@ -1180,21 +1212,25 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
}
/**
Perform subshell expansion
Perform cmdsubst expansion
*/
static int expand_subshell( wchar_t *in, array_list_t *out )
static int expand_cmdsubst( wchar_t *in, array_list_t *out )
{
wchar_t *paran_begin=0, *paran_end=0;
int len1, len2;
int len1;
wchar_t prev=0;
wchar_t *subcmd;
array_list_t sub_res, tail_expand;
array_list_t *sub_res, *tail_expand;
int i, j;
const wchar_t *item_begin;
wchar_t *tail_begin = 0;
void *context;
CHECK( in, 0 );
CHECK( out, 0 );
switch( parse_util_locate_cmdsubst(in,
&paran_begin,
&paran_end,
@@ -1213,44 +1249,93 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
break;
}
context = halloc( 0, 0 );
len1 = (paran_begin-in);
len2 = wcslen(paran_end)-1;
prev=0;
item_begin = paran_begin+1;
al_init( &sub_res );
if( !(subcmd = malloc( sizeof(wchar_t)*(paran_end-paran_begin) )))
sub_res = al_halloc( context );
if( !(subcmd = halloc( context, sizeof(wchar_t)*(paran_end-paran_begin) )))
{
al_destroy( &sub_res );
halloc_free( context );
return 0;
}
wcslcpy( subcmd, paran_begin+1, paran_end-paran_begin );
subcmd[ paran_end-paran_begin-1]=0;
if( exec_subshell( subcmd, &sub_res)==-1 )
exec_subshell( subcmd, sub_res);
tail_begin = paran_end + 1;
if( *tail_begin == L'[' )
{
al_foreach( &sub_res, &free );
al_destroy( &sub_res );
free( subcmd );
return 0;
array_list_t *slice_idx = al_halloc( context );
wchar_t *slice_end;
if( parse_slice( tail_begin, &slice_end, slice_idx ) )
{
halloc_free( context );
error( SYNTAX_ERROR, -1, L"Invalid index value" );
return 0;
}
else
{
array_list_t *sub_res2 = al_halloc( context );
tail_begin = slice_end;
for( i=0; i<al_get_count( slice_idx ); i++ )
{
long idx = al_get_long( slice_idx, i );
if( idx < 0 )
{
idx = al_get_count( sub_res ) + idx + 1;
}
if( idx < 1 || idx > al_get_count( sub_res ) )
{
halloc_free( context );
error( SYNTAX_ERROR, -1, L"Invalid index value" );
return 0;
}
idx = idx-1;
al_push( sub_res2, al_get( sub_res, idx ) );
// debug( 0, L"Pushing item '%ls' with index %d onto sliced result", al_get( sub_res, idx ), idx );
al_set( sub_res, idx, 0 );
}
al_foreach( sub_res, &free );
sub_res = sub_res2;
}
}
al_init( &tail_expand );
expand_subshell( wcsdup(paran_end+1), &tail_expand );
tail_expand = al_halloc( context );
for( i=0; i<al_get_count( &sub_res ); i++ )
/*
Recursively call ourselves to expand any remaining command
substitutions. The result of this recusrive call usiung the tail
of the string is inserted into the tail_expand array list
*/
expand_cmdsubst( wcsdup(tail_begin), tail_expand );
/*
Combine the result of the current command substitution with the
result of the recusrive tail expansion
*/
for( i=0; i<al_get_count( sub_res ); i++ )
{
wchar_t *sub_item, *sub_item2;
sub_item = (wchar_t *)al_get( &sub_res, i );
sub_item = (wchar_t *)al_get( sub_res, i );
sub_item2 = escape( sub_item, 1 );
free(sub_item);
int item_len = wcslen( sub_item2 );
for( j=0; j<al_get_count( &tail_expand ); j++ )
for( j=0; j<al_get_count( tail_expand ); j++ )
{
string_buffer_t whole_item;
wchar_t *tail_item = (wchar_t *)al_get( &tail_expand, j );
wchar_t *tail_item = (wchar_t *)al_get( tail_expand, j );
sb_init( &whole_item );
@@ -1267,12 +1352,8 @@ static int expand_subshell( wchar_t *in, array_list_t *out )
}
free(in);
al_destroy( &sub_res );
al_foreach( &tail_expand, &free );
al_destroy( &tail_expand );
free( subcmd );
al_foreach( tail_expand, &free );
halloc_free( context );
return 1;
}
@@ -1430,7 +1511,7 @@ int expand_string( void *context,
array_list_t *in, *out;
int i;
int subshell_ok = 1;
int cmdsubst_ok = 1;
int res = EXPAND_OK;
int start_count = al_get_count( end_out );
@@ -1447,7 +1528,7 @@ int expand_string( void *context,
al_init( &list1 );
al_init( &list2 );
if( EXPAND_SKIP_SUBSHELL & flags )
if( EXPAND_SKIP_CMDSUBST & flags )
{
wchar_t *begin, *end;
@@ -1456,7 +1537,7 @@ int expand_string( void *context,
&end,
1 ) != 0 )
{
error( SUBSHELL_ERROR, -1, L"Subshells not allowed" );
error( CMDSUBST_ERROR, -1, L"Command substitutions not allowed" );
free( str );
al_destroy( &list1 );
al_destroy( &list2 );
@@ -1466,10 +1547,10 @@ int expand_string( void *context,
}
else
{
subshell_ok = expand_subshell( str, &list1 );
cmdsubst_ok = expand_cmdsubst( str, &list1 );
}
if( !subshell_ok )
if( !cmdsubst_ok )
{
al_destroy( &list1 );
return EXPAND_ERROR;

View File

@@ -20,9 +20,9 @@
#include "util.h"
/**
Flag specifying that subshell expansion should be skipped
Flag specifying that cmdsubst expansion should be skipped
*/
#define EXPAND_SKIP_SUBSHELL 1
#define EXPAND_SKIP_CMDSUBST 1
/**
Flag specifying that variable expansion should be skipped
@@ -122,7 +122,7 @@ enum
Perform various forms of expansion on in, such as tilde expansion
(\~USER becomes the users home directory), variable expansion
(\$VAR_NAME becomes the value of the environment variable VAR_NAME),
subshell expansion and wildcard expansion. The results are inserted
cmdsubst expansion and wildcard expansion. The results are inserted
into the list out.
If the parameter does not need expansion, it is copied into the list
@@ -135,7 +135,7 @@ enum
\param context the halloc context to use for automatic deallocation
\param in The parameter to expand
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\param out The list to which the result will be appended.
\return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH. EXPAND_WILDCARD_NO_MATCH and EXPAND_WILDCARD_MATCH are normal exit conditions used only on strings containing wildcards to tell if the wildcard produced any matches.
*/
@@ -151,7 +151,7 @@ int expand_string( void *context, wchar_t *in, array_list_t *out, int flag );
\param context the halloc context to use for automatic deallocation
\param in The parameter to expand
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\return The expanded parameter, or 0 on failiure
*/
wchar_t *expand_one( void *context, wchar_t *in, int flag );

View File

@@ -25,6 +25,7 @@
#include <dirent.h>
#include <stdarg.h>
#include <limits.h>
#include <assert.h>
#if HAVE_NCURSES_H
#include <ncurses.h>
@@ -1005,14 +1006,6 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
#endif
#ifdef HAVE_BROKEN_DEL_CURTERM
int del_curterm(TERMINAL *oterm)
{
}
#endif
#ifndef HAVE_LRAND48_R
int lrand48_r(struct drand48_data *buffer, long int *result)
@@ -1076,3 +1069,25 @@ int _nl_msg_cat_cntr=0;
#endif
#ifndef HAVE_KILLPG
int killpg( int pgr, int sig )
{
assert( pgr > 1 );
return kill( -pgr, sig );
}
#endif
#ifndef HAVE_WORKING_GETOPT_LONG
int getopt_long( int argc,
char * const argv[],
const char *optstring,
const struct option *longopts,
int *longindex )
{
return getopt( argc, argv, optstring );
}
#endif

View File

@@ -9,6 +9,8 @@
#include <wchar.h>
#include <limits.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
#ifndef WCHAR_MAX
/**
@@ -43,6 +45,24 @@ typedef int tputs_arg_t;
typedef char tputs_arg_t;
#endif
#ifndef SIGIO
#define SIGIO SIGUSR1
#endif
#ifndef SIGWINCH
#define SIGIO SIGUSR2
#endif
#ifndef HAVE_WINSIZE
struct winsize
{
unsigned short ws_row;
unsigned short ws_col;
}
;
#endif
#ifdef TPUTS_KLUDGE
/**
@@ -290,7 +310,7 @@ size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
/**
BSD del_curterm seems to do a double-free. We redefine it as a no-op
*/
int del_curterm(TERMINAL *oterm);
#define del_curterm(oterm) OK
#endif
#ifndef HAVE_LRAND48_R
@@ -366,5 +386,42 @@ extern int _nl_msg_cat_cntr;
#endif
#ifndef HAVE_KILLPG
int killpg( int pgr, int sig );
#endif
#ifndef HAVE_WORKING_GETOPT_LONG
struct option
{
const char *name;
int has_arg;
int *flag;
int val;
}
;
#ifndef no_argument
#define no_argument 0
#endif
#ifndef required_argument
#define required_argument 1
#endif
#ifndef optional_argument
#define optional_argument 2
#endif
int getopt_long(int argc,
char * const argv[],
const char *optstring,
const struct option *longopts,
int *longindex);
#endif
#endif

View File

@@ -1,5 +1,3 @@
%define xinclude %( if test -d /usr/X11R6/include; then echo /usr/X11R6/include; else echo /usr/include; fi )
Summary: A friendly interactive shell
Name: @PACKAGE_NAME@
@@ -13,20 +11,52 @@ URL: http://roo.no-ip.org/fish/
Source0: http://roo.no-ip.org/%{name}/files/%{version}/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ncurses-devel
BuildRequires: %{xinclude}/X11/StringDefs.h, %{xinclude}/X11/Xlib.h
BuildRequires: %{xinclude}/X11/Intrinsic.h, %{xinclude}/X11/Xatom.h
BuildRequires: ncurses-devel gettext groff
# Locate correct build time-dependencies for providing X headers
%if "%fedora" >= "5"
# Modern Fedora version, has modular X.org
BuildRequires: xorg-x11-proto-devel libX11-devel libXt-devel libXext-devel
%endif
%if "%fedora" < "5"
%if "%fedora" >= "3"
# Semi-old Fedora version, has non-modular X.org
BuildRequires: xorg-x11-devel
%endif
%endif
%if 0%{?fedora}
%if "%fedora" < "3"
# Ancient Fedora version, has XFree86
BuildRequires: XFree86-devel
%endif
%else
# The %fedora variable has not been correctly defined, or this is is
# not a Fedora system, try guessing BuildRequires by looking at the
# directory structure
%define xinclude /usr%(if [ -d /usr/X11R6/include ]; then echo /X11R6; fi)/include
BuildRequires: %{xinclude}/X11/StringDefs.h, %{xinclude}/X11/Xlib.h
BuildRequires: %{xinclude}/X11/Intrinsic.h, %{xinclude}/X11/Xatom.h
%endif
%description
fish is a shell geared towards interactive use. It's features are
focused on user friendlieness and discoverability. The language syntax
fish is a shell geared towards interactive use. Its features are
focused on user friendliness and discoverability. The language syntax
is simple but incompatible with other shell languages.
%prep
%setup -q
@@ -34,6 +64,9 @@ is simple but incompatible with other shell languages.
%build
# The docdir argument is to make the name of the cosumantation
# directory 'fish-VERSION', instead of the default, which is simply
# 'fish'.
%configure docdir=%_datadir/doc/%{name}-%{version}
make %{?_smp_mflags}
@@ -44,6 +77,8 @@ make %{?_smp_mflags}
rm -rf $RPM_BUILD_ROOT
make install DESTDIR="$RPM_BUILD_ROOT"
# Find translation files
%find_lang %{name}.\*
@@ -54,6 +89,7 @@ rm -rf $RPM_BUILD_ROOT
%post
# Add fish to the list of allowed shells in /etc/shells
if ! grep %_bindir/fish %_sysconfdir/shells >/dev/null; then
echo %_bindir/fish >>%_sysconfdir/shells
fi
@@ -62,6 +98,7 @@ fi
%postun
# Remove fish from the list of allowed shells in /etc/shells
if [ "$1" = 0 ]; then
grep -v %_bindir/fish %_sysconfdir/shells >%_sysconfdir/fish.tmp
mv %_sysconfdir/fish.tmp %_sysconfdir/shells
@@ -70,11 +107,14 @@ fi
%files
%files -f %{name}.\*.lang
%defattr(-,root,root,-)
# The documentation directory
%doc %_datadir/doc/%{name}-%{version}
# man files
%_mandir/man1/fish.1*
%_mandir/man1/xsel.1x*
%_mandir/man1/mimedb.1*
@@ -83,6 +123,7 @@ fi
%_mandir/man1/fishd.1*
%_mandir/man1/fish_pager.1*
# The program binaries
%attr(0755,root,root) %_bindir/fish
%attr(0755,root,root) %_bindir/fishd
%attr(0755,root,root) %_bindir/fish_pager
@@ -91,26 +132,41 @@ fi
%attr(0755,root,root) %_bindir/mimedb
%attr(0755,root,root) %_bindir/count
# Configuration files
%config %_sysconfdir/fish
%config %_sysconfdir/fish_inputrc
%dir %_sysconfdir/fish.d
%config %_sysconfdir/fish.d/fish_*.fish
# Non-configuration initialization files
%dir %_datadir/fish
%_datadir/fish/fish
# Program specific tab-completions
%dir %_datadir/fish/completions
%_datadir/fish/completions/*.fish
# Dynamically loaded shellscript functions
%dir %_datadir/fish/functions
%_datadir/fish/functions/*.fish
%_datadir/locale/*/LC_MESSAGES/fish.mo
%changelog
* Fri Aug 4 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-4
- Add better translation finding code from fedora spec to main spec. Thank you to Michael Schwendt.
- Add missing dependency libXext-devel.
- Remove one nesting level from dependency checking code.
* Tue Aug 1 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-1
- Improved the dependency check for X headers. Thank you to Michael Schwendt for pointers on how to do this
* Mon Jul 31 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.21.10-1
- Fixed spelling and punctuation as a per patch from Paul Howarth
- Fixed dependencies as per patch from Paul Howarth
* Tue Nov 29 2005 Axel Liljencrantz <axel@liljencrantz.se> 1.17.0-0
- 1.17.0

View File

@@ -9,7 +9,14 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <sys/time.h>
#include <sys/wait.h>
#include <dirent.h>
@@ -131,14 +138,21 @@ typedef struct
static int get_color( int highlight )
{
wchar_t *val;
if( highlight < 0 )
return FISH_COLOR_NORMAL;
if( highlight >= (4) )
return FISH_COLOR_NORMAL;
wchar_t *val = env_universal_get( hightlight_var[highlight]);
val = wgetenv( hightlight_var[highlight]);
if( !val )
{
val = env_universal_get( hightlight_var[highlight]);
}
if( val == 0 )
if( !val )
{
return FISH_COLOR_NORMAL;
}
@@ -569,14 +583,13 @@ static int completion_try_print( int cols,
*/
while(do_loop)
{
wchar_t msg[10];
int percent = 100*pos/(rows-termsize.ws_row+1);
wchar_t msg[30];
int percent = 100*(pos+rows)/(2*rows-termsize.ws_row+1);
set_color( FISH_COLOR_BLACK,
get_color(HIGHLIGHT_PAGER_PROGRESS) );
swprintf( msg, 12,
L" %ls(%d%%) \r",
percent==100?L"":(percent >=10?L" ": L" "),
percent );
swprintf( msg, 30,
L" %d to %d of %d \r",
pos, pos+termsize.ws_row-1, rows );
writestr(msg);
set_color( FISH_COLOR_NORMAL, FISH_COLOR_NORMAL );
pager_flush();
@@ -881,15 +894,29 @@ static void init()
the resulting output back to the caller
*/
int out = dup( 1 );
int in = dup( 0 );
close(1);
if( open( ttyname(0), O_WRONLY ) != 1 )
close(0);
if( (in = open( ttyname(2), O_RDWR )) != -1 )
{
if( dup2( 2, 1 ) == -1 )
{
debug( 0, L"Could not set up file descriptors for pager" );
debug( 0, L"Could not set up output file descriptors for pager" );
exit( 1 );
}
if( dup2( in, 0 ) == -1 )
{
debug( 0, L"Could not set up input file descriptors for pager %d", in );
exit( 1 );
}
}
else
{
debug( 0, L"Could not open tty for pager" );
exit( 1 );
}
out_file = fdopen( out, "w" );
/**
@@ -903,7 +930,7 @@ static void init()
output_set_writer( &pager_buffered_writer );
pager_buffer = halloc( global_context, sizeof( buffer_t ) );
halloc_register_function( global_context, (void (*)(void *))&b_destroy, pager_buffer );
sigemptyset( & act.sa_mask );
act.sa_flags=0;
act.sa_handler=SIG_DFL;
@@ -916,7 +943,7 @@ static void init()
}
handle_winch( 0 ); /* Set handler for window change events */
tcgetattr(0,&pager_modes); /* get the current terminal modes */
memcpy( &saved_modes,
&pager_modes,
@@ -949,11 +976,54 @@ void destroy()
env_universal_destroy();
input_common_destroy();
halloc_util_destroy();
del_curterm( cur_term );
if( del_curterm( cur_term ) == ERR )
{
debug( 0, _(L"Error while closing terminfo") );
}
sb_destroy( &out_buff );
fclose( out_file );
}
#define BUFSIZE 1024
void read_array( FILE* file, array_list_t *comp )
{
char buffer[BUFSIZE];
int c;
int i;
wchar_t *wcs, *unescaped;
while( !feof( file ) )
{
i = 0;
while( i < BUFSIZE-1 )
{
c = getc( file );
if( c == EOF )
{
return;
}
if( c == '\n' )
{
break;
}
buffer[ i++ ] = c;
}
buffer[ i ] = '\0';
wcs = str2wcs( buffer );
if( wcs )
{
unescaped = unescape( wcs, 0 );
al_push( comp, unescaped );
free( wcs );
}
}
}
int main( int argc, char **argv )
{
int i;
@@ -961,8 +1031,6 @@ int main( int argc, char **argv )
array_list_t *comp;
wchar_t *prefix;
init();
if( argc < 3 )
{
debug( 0, L"Insufficient arguments" );
@@ -976,19 +1044,29 @@ int main( int argc, char **argv )
debug( 3, L"prefix is '%ls'", prefix );
for( i=3; i<argc; i++ )
if( argc > 3 )
{
wchar_t *wcs = str2wcs( argv[i] );
if( wcs )
for( i=3; i<argc; i++ )
{
al_push( comp, wcs );
wchar_t *wcs = str2wcs( argv[i] );
if( wcs )
{
al_push( comp, wcs );
}
}
}
mangle_descriptions( comp );
if( wcscmp( prefix, L"-" ) == 0 )
join_completions( comp );
mangle_completions( comp, prefix );
else
{
read_array( stdin, comp );
}
init();
mangle_descriptions( comp );
if( wcscmp( prefix, L"-" ) == 0 )
join_completions( comp );
mangle_completions( comp, prefix );
for( i = 6; i>0; i-- )
{

View File

@@ -152,7 +152,7 @@ static void pq_test( int elements )
*/
static int stack_test( int elements )
{
int i;
long i;
int res=1;
@@ -162,12 +162,12 @@ static int stack_test( int elements )
for( i=0; i<elements; i++ )
{
int foo;
long foo;
al_push( &s, (void*)i);
al_push( &s, (void*)i);
al_push_long( &s, i);
al_push_long( &s, i);
if( (foo=(int)al_pop( &s )) != i )
if( (foo=al_pop_long( &s )) != i )
{
err( L"Unexpected data" );
res = 0;
@@ -177,16 +177,14 @@ static int stack_test( int elements )
for( i=0; i<elements; i++ )
{
int foo;
long foo;
if( (foo=(int)al_pop( &s )) != (elements-i-1) )
if( (foo=al_pop_long( &s )) != (elements-i-1) )
{
err( L"Unexpected data" );
res = 0;
break;
}
}
}
@@ -297,22 +295,22 @@ static int hash_test( int elements )
*/
static void al_test( int sz)
{
int i;
long i;
array_list_t l;
al_init( &l );
al_set( &l, 1, (void *)7 );
al_set( &l, sz, (void *)7 );
al_set_long( &l, 1, 7L );
al_set_long( &l, sz, 7L );
if( al_get_count( &l ) != maxf( sz+1, 2 ) )
if( al_get_count( &l ) != maxi( sz+1, 2 ) )
err( L"Wrong number of elements in array list" );
for( i=0; i<al_get_count( &l ); i++ )
{
int val = (int)((long) al_get( &l, i ));
long val = al_get_long( &l, i );
if( (i == 1) || (i==sz))
{
if( val != 7 )

View File

@@ -494,7 +494,6 @@ int main( int argc, char ** argv )
*/
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{
@@ -520,11 +519,6 @@ int main( int argc, char ** argv )
long_options,
&opt_index );
#else
int opt = getopt( argc,
argv,
GETOPT_STRING );
#endif
if( opt == -1 )
break;

View File

@@ -1,6 +1,9 @@
/** \file function.c
Functions for storing and retrieving function information.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -8,8 +11,6 @@
#include <termios.h>
#include <signal.h>
#include "config.h"
#include "wutil.h"
#include "fallback.h"
#include "util.h"

View File

@@ -74,7 +74,7 @@ typedef struct halloc
size_t scratch_free;
#if __STDC_VERSION__ < 199901L
/**
The actual data. MAde to be of type long long to make sure memory alignment is in order.
The actual data. Made to be of type long long to make sure memory alignment is in order.
*/
long long data[1]; // Waste one byte on non-C99 compilers... :-(
#else

View File

@@ -1,6 +1,8 @@
/** \file highlight.c
Functions for syntax highlighting
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
@@ -11,8 +13,6 @@
#include <termios.h>
#include <signal.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -136,7 +136,10 @@ static int is_potential_path( const wchar_t *path )
{
dir = wopendir( unescaped );
res = !!dir;
closedir( dir );
if( dir )
{
closedir( dir );
}
}
else
{
@@ -583,7 +586,7 @@ void highlight_shell( wchar_t * buff,
{
wchar_t *dir = expand_one( context,
wcsdup(tok_last( &tok )),
EXPAND_SKIP_SUBSHELL );
EXPAND_SKIP_CMDSUBST );
if( dir )
{
if( !parser_cdpath_get( context, dir ) )
@@ -609,7 +612,7 @@ void highlight_shell( wchar_t * buff,
*/
cmd = expand_one( context,
wcsdup(tok_last( &tok )),
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
if( cmd == 0 )
{
@@ -726,9 +729,9 @@ void highlight_shell( wchar_t * buff,
{
case TOK_STRING:
{
target = expand_one( context, wcsdup( tok_last( &tok ) ), EXPAND_SKIP_SUBSHELL);
target = expand_one( context, wcsdup( tok_last( &tok ) ), EXPAND_SKIP_CMDSUBST);
/*
Redirect filename may contain a subshell.
Redirect filename may contain a cmdsubst.
If so, it will be ignored/not flagged.
*/
}
@@ -829,7 +832,7 @@ void highlight_shell( wchar_t * buff,
tok_destroy( &tok );
/*
Locate and syntax highlight subshells recursively
Locate and syntax highlight cmdsubsts recursively
*/
wchar_t *buffcpy = halloc_wcsdup( context, buff );
@@ -960,7 +963,7 @@ static void highlight_universal_internal( wchar_t * buff,
if( level == 0 )
{
level++;
al_push( &l, (void *)(str-buff) );
al_push_long( &l, (long)(str-buff) );
prev_q = *str;
}
else
@@ -970,7 +973,7 @@ static void highlight_universal_internal( wchar_t * buff,
long pos1, pos2;
level--;
pos1 = (long)al_pop( &l );
pos1 = al_pop_long( &l );
pos2 = str-buff;
if( pos1==pos || pos2==pos )
{
@@ -984,7 +987,7 @@ static void highlight_universal_internal( wchar_t * buff,
else
{
level++;
al_push( &l, (void *)(str-buff) );
al_push_long( &l, (long)(str-buff) );
prev_q = *str;
}
}

View File

@@ -1,6 +1,8 @@
/** \file history.c
History functions, part of the user interface.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -11,8 +13,6 @@
#include <unistd.h>
#include "config.h"
#include "fallback.h"
#include "util.h"

18
input.c
View File

@@ -17,7 +17,15 @@ implementation in fish is as of yet incomplete.
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <unistd.h>
#include <wchar.h>
@@ -271,7 +279,7 @@ wchar_t input_get_code( const wchar_t *name )
/**
Returns the function name for the given function code.
*/
/*
static const wchar_t *input_get_name( wchar_t c )
{
@@ -285,7 +293,7 @@ static const wchar_t *input_get_name( wchar_t c )
}
return 0;
}
*/
/**
Returns the function description for the given function code.
*/
@@ -1481,7 +1489,11 @@ void input_destroy()
hash_foreach( &all_mappings, &destroy_mapping );
hash_destroy( &all_mappings );
del_curterm( cur_term );
if( del_curterm( cur_term ) == ERR )
{
debug( 0, _(L"Error while closing terminfo") );
}
}
/**

View File

@@ -14,7 +14,9 @@ Implementation file for the low level input library
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include "fallback.h"
#include "util.h"
@@ -34,7 +36,7 @@ Implementation file for the low level input library
/**
Characters that have been read and returned by the sequence matching code
*/
static wint_t lookahead_arr[32];
static wint_t lookahead_arr[1024];
/**
Number of entries in lookahead_arr

18
io.c
View File

@@ -12,7 +12,15 @@ Utilities for io redirection.
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <unistd.h>
#include <fcntl.h>
@@ -93,16 +101,17 @@ void io_buffer_read( io_data_t *d )
}
io_data_t *io_buffer_create()
io_data_t *io_buffer_create( int is_input )
{
io_data_t *buffer_redirect = malloc( sizeof( io_data_t ));
buffer_redirect->io_mode=IO_BUFFER;
buffer_redirect->next=0;
buffer_redirect->param2.out_buffer= malloc( sizeof(buffer_t));
buffer_redirect->param3.is_input = is_input;
b_init( buffer_redirect->param2.out_buffer );
buffer_redirect->fd=1;
buffer_redirect->fd=is_input?0:1;
if( exec_pipe( buffer_redirect->param1.pipe_fd ) == -1 )
{
debug( 1, PIPE_ERROR );
@@ -221,8 +230,7 @@ void io_print( io_data_t *io )
return;
}
debug( 1, L"IO fd %d, type ",
io->fd );
debug( 1, L"IO fd %d, type ", io->fd );
switch( io->io_mode )
{
case IO_PIPE:

20
io.h
View File

@@ -44,6 +44,17 @@ typedef struct io_data
} param2
;
union
{
/**
This will be non-zero if this is a buffer of input, not
output
*/
int is_input;
}
param3;
/** Pointer to the next IO redirection */
struct io_data *next;
@@ -80,9 +91,14 @@ void io_buffer_destroy( io_data_t *io_buffer );
/**
Create a IO_BUFFER type io redirection, complete with a pipe and a
buffer_t for output.
buffer_t for output. The default file descriptor used is 1 for
output buffering and 0 for input buffering.
\param is_input set this parameter to zero if the buffer should be
used to buffer the output of a command, or non-zero to buffer the
input to a command.
*/
io_data_t *io_buffer_create();
io_data_t *io_buffer_create( int is_input );
/**
Close output pipe, and read from input pipe until eof.

4
kill.c
View File

@@ -6,6 +6,8 @@
with the X clipboard.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -17,8 +19,6 @@
#include <dirent.h>
#include "config.h"
#include "fallback.h"
#include "util.h"

6
main.c
View File

@@ -123,7 +123,6 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{
@@ -173,11 +172,6 @@ int main( int argc, char **argv )
long_options,
&opt_index );
#else
int opt = getopt( argc,
argv,
GETOPT_STRING );
#endif
if( opt == -1 )
break;

View File

@@ -135,14 +135,10 @@ static int launch_len=0;
*/
static int launch_pos=0;
#if HAVE_GETTEXT
/**
gettext alias
*/
#define _(string) gettext(string)
#else
#define _(string) (string)
#endif
/**
Dynamically generated function, made from the documentation in doc_src.
@@ -1145,10 +1141,8 @@ static void clear_entry( void *key, void *val )
static void locale_init()
{
setlocale( LC_ALL, "" );
#if HAVE_GETTEXT
bindtextdomain( PACKAGE_NAME, LOCALEDIR );
textdomain( PACKAGE_NAME );
#endif
}
@@ -1174,7 +1168,6 @@ int main (int argc, char *argv[])
*/
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{
@@ -1228,11 +1221,6 @@ int main (int argc, char *argv[])
long_options,
&opt_index );
#else
int opt = getopt( argc,
argv,
GETOPT_STRING );
#endif
if( opt == -1 )
break;

View File

@@ -11,7 +11,15 @@
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <sys/time.h>
#include <unistd.h>
#include <wctype.h>
@@ -279,8 +287,12 @@ void set_color( int c, int c2 )
writembs( exit_attribute_mode );
if( ( last_color != FISH_COLOR_NORMAL ) && fg )
{
writembs( tparm( fg, last_color ) );
if( fg )
{
writembs( tparm( fg, last_color ) );
}
}
was_bold=0;
was_underline=0;
@@ -303,7 +315,10 @@ void set_color( int c, int c2 )
{
if( is_bold && !was_bold )
{
writembs( tparm( enter_bold_mode ) );
if( enter_bold_mode )
{
writembs( tparm( enter_bold_mode ) );
}
}
was_bold = is_bold;
}

View File

@@ -580,34 +580,46 @@ int parse_util_unload( const wchar_t *cmd,
return !!val;
}
static int path_util_load_internal( const wchar_t *cmd,
void (*on_load)(const wchar_t *cmd),
int reload,
autoload_t *loaded,
array_list_t *path_list );
int parse_util_load( const wchar_t *cmd,
const wchar_t *path_var_name,
void (*on_load)(const wchar_t *cmd),
int reload )
{
static array_list_t *path_list=0;
static string_buffer_t *path=0;
array_list_t *path_list=0;
int i;
time_t *tm;
int reloaded = 0;
autoload_t *loaded;
wchar_t *path_var;
int res;
int c, c2;
CHECK( path_var_name, 0 );
CHECK( cmd, 0 );
// debug( 0, L"Autoload %ls in %ls", cmd, path_var_name );
path_var = env_get( path_var_name );
/*
Do we know where to look
Do we know where to look?
*/
if( !path_var )
{
// debug( 0, L"Path null" );
return 0;
}
/**
Init if this is the first time we try to autoload anything
*/
if( !all_loaded )
{
all_loaded = malloc( sizeof( hash_table_t ) );
@@ -623,9 +635,14 @@ int parse_util_load( const wchar_t *cmd,
if( loaded )
{
/**
Warn and fail on infinite recursion
*/
if( hash_get( &loaded->is_loading, cmd ) )
{
debug( 0, _(L"Could not autoload item %ls, it is already being autoloaded. This is a circular dependency in the autoloading scripts, please remove it."), cmd );
debug( 0,
_(L"Could not autoload item '%ls', it is already being autoloaded. This is a circular dependency in the autoloading scripts, please remove it."),
cmd );
return 1;
}
@@ -637,35 +654,86 @@ int parse_util_load( const wchar_t *cmd,
{
parse_util_load_reset( path_var_name, on_load);
reload = parse_util_load( cmd, path_var_name, on_load, reload );
// debug( 0, L"Reload" );
return reload;
}
}
else
{
/*
We have never tried to autoload using this name before, set up initial data
We have never tried to autoload using this path name before,
set up initial data
*/
loaded = malloc( sizeof( autoload_t ) );
loaded = malloc( sizeof( autoload_t ) );
if( !loaded )
{
DIE_MEM();
}
hash_init( &loaded->load_time, &hash_wcs_func, &hash_wcs_cmp );
hash_put( all_loaded, wcsdup(path_var_name), loaded );
hash_init( &loaded->is_loading, &hash_wcs_func, &hash_wcs_cmp );
loaded->old_path = wcsdup( path_var );
}
hash_put( &loaded->is_loading, cmd, cmd );
path_list = al_new( global_context);
tokenize_variable_array( path_var, path_list );
c = al_get_count( path_list );
hash_put( &loaded->is_loading, cmd, cmd );
/*
Do the actual work in the internal helper function
*/
res = path_util_load_internal( cmd, on_load, reload, loaded, path_list );
/**
Cleanup
*/
hash_remove( &loaded->is_loading, cmd, 0, 0 );
c2 = al_get_count( path_list );
al_foreach( path_list, &free );
al_destroy( path_list );
free( path_list );
/**
Make sure we didn't 'drop' something
*/
assert( c == c2 );
return res;
}
/**
This internal helper function does all the real work. By using two
functions, the internal function can return on various places in
the code, and the caller can take care of various cleanup work.
*/
static int path_util_load_internal( const wchar_t *cmd,
void (*on_load)(const wchar_t *cmd),
int reload,
autoload_t *loaded,
array_list_t *path_list )
{
static string_buffer_t *path=0;
time_t *tm;
int i;
int reloaded = 0;
/*
Get modification time of file
*/
tm = (time_t *)hash_get( &loaded->load_time, cmd );
/*
Did we just check this?
*/
@@ -673,7 +741,7 @@ int parse_util_load( const wchar_t *cmd,
{
if(time(0)-tm[1]<=1)
{
hash_remove( &loaded->is_loading, cmd, 0, 0 );
// debug( 0, L"Cached" );
return 0;
}
}
@@ -683,20 +751,16 @@ int parse_util_load( const wchar_t *cmd,
*/
if( !reload && tm )
{
hash_remove( &loaded->is_loading, cmd, 0, 0 );
// debug( 0, L"Weak check" );
return 0;
}
if( !path_list )
path_list = al_halloc( global_context);
if( !path )
path = sb_halloc( global_context );
else
sb_clear( path );
tokenize_variable_array( path_var, path_list );
/*
Iterate over path searching for suitable completion files
*/
@@ -706,6 +770,7 @@ int parse_util_load( const wchar_t *cmd,
wchar_t *next = (wchar_t *)al_get( path_list, i );
sb_clear( path );
sb_append2( path, next, L"/", cmd, L".fish", (void *)0 );
if( (wstat( (wchar_t *)path->buff, &buf )== 0) &&
(waccess( (wchar_t *)path->buff, R_OK ) == 0) )
{
@@ -713,6 +778,7 @@ int parse_util_load( const wchar_t *cmd,
{
wchar_t *esc = escape( (wchar_t *)path->buff, 1 );
wchar_t *src_cmd = wcsdupcat( L". ", esc );
free( esc );
if( !tm )
{
@@ -727,7 +793,6 @@ int parse_util_load( const wchar_t *cmd,
intern( cmd ),
tm );
free( esc );
if( on_load )
on_load(cmd );
@@ -738,8 +803,8 @@ int parse_util_load( const wchar_t *cmd,
exec_subshell( src_cmd, 0 );
free(src_cmd);
reloaded = 1;
break;
}
break;
}
}
@@ -759,10 +824,8 @@ int parse_util_load( const wchar_t *cmd,
hash_put( &loaded->load_time, intern( cmd ), tm );
}
al_foreach( path_list, &free );
al_truncate( path_list, 0 );
hash_remove( &loaded->is_loading, cmd, 0, 0 );
// debug( 0, L"Regular return" );
return reloaded;
}

View File

@@ -4,6 +4,8 @@ The fish parser. Contains functions for parsing code.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
@@ -17,8 +19,6 @@ The fish parser. Contains functions for parsing code.
#include <dirent.h>
#include <signal.h>
#include "config.h"
#include "fallback.h"
#include "util.h"
@@ -251,11 +251,6 @@ The fish parser. Contains functions for parsing code.
#define UNKNOWN_BLOCK N_( L"unknown/invalid block" )
/**
Size of the error string buffer
*/
#define ERR_STR_SZ 1024
/**
Datastructure to describe a block type, like while blocks, command substitution blocks, etc.
*/
@@ -350,7 +345,7 @@ io_data_t *block_io;
static int err_pos;
/** Description of last error */
static wchar_t err_str[ERR_STR_SZ];
static string_buffer_t *err_buff=0;
/** Pointer to the current tokenizer */
static tokenizer *current_tokenizer;
@@ -756,11 +751,17 @@ void error( int ec, int p, const wchar_t *str, ... )
{
va_list va;
if( !err_buff )
err_buff = sb_halloc( global_context );
error_code = ec;
err_pos = p;
va_start( va, str );
vswprintf( err_str, ERR_STR_SZ, str, va );
sb_vprintf( err_buff, str, va );
va_end( va );
}
@@ -1007,11 +1008,11 @@ void parser_destroy()
*/
static void print_errors( string_buffer_t *target, const wchar_t *prefix )
{
if( error_code )
if( error_code && err_buff )
{
int tmp;
sb_printf( target, L"%ls: %ls\n", prefix, err_str );
sb_printf( target, L"%ls: %ls\n", prefix, (wchar_t *)err_buff->buff );
tmp = current_tokenizer_pos;
current_tokenizer_pos = err_pos;
@@ -1027,9 +1028,9 @@ static void print_errors( string_buffer_t *target, const wchar_t *prefix )
*/
static void print_errors_stderr()
{
if( error_code )
if( error_code && err_buff )
{
debug( 0, L"%ls", err_str );
debug( 0, L"%ls", (wchar_t *)err_buff->buff );
int tmp;
tmp = current_tokenizer_pos;
@@ -1863,7 +1864,7 @@ static int parse_job( process_t *p,
{
nxt = expand_one( j,
wcsdup(tok_last( tok )),
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES);
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
if( nxt == 0 )
{
@@ -2747,7 +2748,7 @@ static int parser_get_block_type( const wchar_t *cmd )
}
/**
\return the block type created by the specified builtin, or -1 on error.
\return the block command that createa the specified block type, or null on error.
*/
static const wchar_t *parser_get_block_command( int type )
{
@@ -2800,7 +2801,7 @@ static int parser_test_argument( const wchar_t *arg, string_buffer_t *out, const
}
free( arg_cpy );
return 1;
case 0:
do_loop = 0;
break;
@@ -3034,7 +3035,7 @@ int parser_test( const wchar_t * buff,
if( !(cmd = expand_one( context,
wcsdup( tok_last( &tok ) ),
EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES ) ) )
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES ) ) )
{
err=1;
if( out )

View File

@@ -179,9 +179,9 @@ enum parser_error
*/
EVAL_ERROR,
/**
Error while evaluating subshell
Error while evaluating cmdsubst
*/
SUBSHELL_ERROR,
CMDSUBST_ERROR,
}
;
@@ -217,7 +217,7 @@ wchar_t *parser_get_filename( void *context, const wchar_t *cmd );
int eval( const wchar_t *cmd, io_data_t *io, int block_type );
/**
Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and subshell execution on the tokens.
Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and cmdsubst execution on the tokens.
The output is inserted into output, and should be freed by the caller.
\param line Line to evaluate

1471
po/en.po

File diff suppressed because it is too large Load Diff

9989
po/fr.po

File diff suppressed because it is too large Load Diff

21
proc.c
View File

@@ -20,7 +20,15 @@ Some of the code in this file is based on code from the Glibc manual.
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <unistd.h>
#include <signal.h>
#include <dirent.h>
@@ -42,6 +50,13 @@ Some of the code in this file is based on code from the Glibc manual.
#include <ncurses/term.h>
#endif
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include "fallback.h"
#include "util.h"
@@ -439,7 +454,7 @@ void job_handle_signal ( int signal, siginfo_t *info, void *con )
handle_child_status( pid, status );
break;
}
}
}
kill( 0, SIGIO );
errno=errno_old;
}
@@ -1089,7 +1104,7 @@ void proc_sanity_check()
void proc_push_interactive( int value )
{
int old = is_interactive;
al_push( interactive_stack, (void *)(long)is_interactive );
al_push_long( interactive_stack, (long)is_interactive );
is_interactive = value;
if( old != value )
signal_set_handlers();
@@ -1098,7 +1113,7 @@ void proc_push_interactive( int value )
void proc_pop_interactive()
{
int old = is_interactive;
is_interactive= (int)(long)al_pop(interactive_stack);
is_interactive= (int)al_pop_long(interactive_stack);
if( is_interactive != old )
signal_set_handlers();
}

17
proc.h
View File

@@ -45,6 +45,11 @@ enum
The exec builtin
*/
INTERNAL_EXEC,
/**
A buffer
*/
INTERNAL_BUFFER,
}
;
@@ -66,7 +71,7 @@ enum
be the result of an exec command. The role of this process_t is
determined by the type field, which can be one of EXTERNAL,
INTERNAL_BUILTIN, INTERNAL_FUNCTION, INTERNAL_BLOCK and
INTERNAL_EXEC.
INTERNAL_EXEC, INTERNAL_BUFFER
The process_t contains information on how the process should be
started, such as command name and arguments, as well as runtime
@@ -79,13 +84,13 @@ enum
argument array and actual_cmd is the absolute path of the command
to execute.
If the process is of type ITERNAL_BUILTIN, argv is the argument
If the process is of type INTERNAL_BUILTIN, argv is the argument
vector, and argv[0] is the name of the builtin command.
If the process is of type ITERNAL_FUNCTION, argv is the argument
If the process is of type INTERNAL_FUNCTION, argv is the argument
vector, and argv[0] is the name of the shellscript function.
If the process is of type ITERNAL_BLOCK, argv has exactly one
If the process is of type INTERNAL_BLOCK, argv has exactly one
element, which is the block of commands to execute.
*/
@@ -93,8 +98,8 @@ typedef struct process
{
/**
Type of process. Can be one of \c EXTERNAL, \c
INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK or
INTERNAL_EXEC
INTERNAL_BUILTIN, \c INTERNAL_FUNCTION, \c INTERNAL_BLOCK,
INTERNAL_EXEC, or INTERNAL_BUFFER
*/
int type;
/** argv parameter for for execv, builtin_run, etc. */

202
reader.c
View File

@@ -28,7 +28,15 @@ commence.
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TERMIOS_H
#include <sys/termios.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/poll.h>
@@ -51,6 +59,14 @@ commence.
#include <ncurses/term.h>
#endif
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <signal.h>
#include <fcntl.h>
#include <dirent.h>
@@ -633,7 +649,7 @@ void reader_write_title()
as that of a virtual terminal, we assume it supports setting the
title. Otherwise we check the ttyname.
*/
if( !term || !contains_str( term, L"xterm", L"screen", L"nxterm", L"rxvt", 0 ) )
if( !term || !contains_str( term, L"xterm", L"screen", L"nxterm", L"rxvt", (wchar_t *)0 ) )
{
char *n = ttyname( STDIN_FILENO );
if( strstr( n, "tty" ) || strstr( n, "/vc/") )
@@ -651,12 +667,15 @@ void reader_write_title()
if( exec_subshell( title, &l ) != -1 )
{
int i;
writestr( L"\e]2;" );
for( i=0; i<al_get_count( &l ); i++ )
if( al_get_count( &l ) > 0 )
{
writestr( (wchar_t *)al_get( &l, i ) );
writestr( L"\e]2;" );
for( i=0; i<al_get_count( &l ); i++ )
{
writestr( (wchar_t *)al_get( &l, i ) );
}
writestr( L"\7" );
}
writestr( L"\7" );
}
proc_pop_interactive();
@@ -791,7 +810,13 @@ static int calc_prompt_width( array_list_t *arr )
}
else if( next[j] == L'\t' )
{
res=(res+8)&~7;
/*
Assume tab stops every 8 characters if undefined
*/
if( init_tabs <= 0 )
init_tabs = 8;
res=( (res/init_tabs)+1 )*init_tabs;
}
else
{
@@ -875,6 +900,7 @@ static void write_cmdline()
void reader_init()
{
tcgetattr(0,&shell_modes); /* get the current terminal modes */
memcpy( &saved_modes,
&shell_modes,
@@ -913,13 +939,14 @@ void reader_exit( int do_exit, int forced )
}
void repaint()
void repaint( int skip_return )
{
int steps;
calc_output();
set_color( FISH_COLOR_RESET, FISH_COLOR_RESET );
writech('\r');
if( !skip_return )
writech('\r');
writembs(clr_eol);
write_prompt();
write_cmdline();
@@ -949,7 +976,7 @@ static void check_colors()
{
memcpy( data->color, data->new_color, sizeof(int)*data->buff_len );
repaint();
repaint( 0 );
}
}
@@ -1021,7 +1048,7 @@ static void reader_check_status()
if( changed )
{
repaint();
repaint( 0 );
set_color( FISH_COLOR_RESET, FISH_COLOR_RESET );
}
}
@@ -1082,7 +1109,7 @@ static void remove_backward()
data->new_color,
sizeof(int) * data->buff_len );
repaint();
repaint( 0 );
}
}
@@ -1172,7 +1199,7 @@ static int insert_char( int c )
/* Nope, colors are off, so we repaint the entire command line */
memcpy( data->color, data->new_color, sizeof(int) * data->buff_len );
repaint();
repaint( 0 );
}
// wcscpy(data->search_buff,data->buff);
return 1;
@@ -1219,7 +1246,7 @@ static int insert_str(wchar_t *str)
/* repaint */
repaint();
repaint( 0 );
}
return 1;
@@ -1443,7 +1470,9 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
{
int i;
string_buffer_t cmd;
string_buffer_t msg;
wchar_t * prefix_esc;
char *foo;
if( !prefix || (wcslen(prefix)==0))
prefix_esc = wcsdup(L"\"\"");
@@ -1451,6 +1480,7 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
prefix_esc = escape( prefix,1);
sb_init( &cmd );
sb_init( &msg );
sb_printf( &cmd,
L"fish_pager %d %ls",
// L"valgrind --track-fds=yes --log-file=pager.txt --leak-check=full ./fish_pager %d %ls",
@@ -1459,24 +1489,33 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
free( prefix_esc );
io_data_t *in= io_buffer_create( 1 );
for( i=0; i<al_get_count( comp); i++ )
{
wchar_t *el = escape( (wchar_t*)al_get( comp, i ),1);
sb_printf( &cmd, L" %ls", el );
free(el);
wchar_t *el = escape((wchar_t*)al_get( comp, i ), 0);
sb_printf( &msg, L"%ls\n", el );
free( el );
}
foo = wcs2str( (wchar_t *)msg.buff );
b_append( in->param2.out_buffer, foo, strlen(foo) );
free( foo );
term_donate();
io_data_t *out = io_buffer_create();
io_data_t *out = io_buffer_create( 0 );
out->next = in;
out->fd = 1;
eval( (wchar_t *)cmd.buff, out, TOP);
term_steal();
io_buffer_read( out );
sb_destroy( &cmd );
sb_destroy( &msg );
int nil=0;
b_append( out->param2.out_buffer, &nil, 1 );
@@ -1493,7 +1532,9 @@ static void run_pager( wchar_t *prefix, int is_quoted, array_list_t *comp )
free( str );
}
io_buffer_destroy( out);
io_buffer_destroy( in);
}
@@ -1614,7 +1655,7 @@ static int handle_completions( array_list_t *comp )
}
free( prefix );
repaint();
repaint( 0 );
}
@@ -1760,7 +1801,7 @@ static void handle_history( const wchar_t *new_str )
data->buff_pos=wcslen(data->buff);
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 0 );
}
/**
@@ -1845,7 +1886,7 @@ static void handle_token_history( int forward, int reset )
reader_replace_current_token( str );
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 0 );
}
else
{
@@ -1918,7 +1959,7 @@ static void handle_token_history( int forward, int reset )
{
reader_replace_current_token( str );
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 0 );
al_push( &data->search_prev, str );
data->search_pos = al_get_count( &data->search_prev )-1;
}
@@ -1943,11 +1984,25 @@ static void handle_token_history( int forward, int reset )
static void move_word( int dir, int erase )
{
int end_buff_pos=data->buff_pos;
int mode=0;
int step = dir?1:-1;
while( mode < 2 )
/*
If we are beyond the last character and moving left, start by
moving one step, since otehrwise we'll start on the \0, which
should be ignored.
*/
if( !dir && (end_buff_pos == data->buff_len) )
{
if( !end_buff_pos )
return;
end_buff_pos--;
}
while( 1 )
{
wchar_t c;
if( !dir )
{
if( end_buff_pos == 0 )
@@ -1958,41 +2013,46 @@ static void move_word( int dir, int erase )
if( end_buff_pos == data->buff_len )
break;
}
end_buff_pos+=step;
if( end_buff_pos < data->buff_len )
c = data->buff[end_buff_pos];
if( !iswspace( c ) )
{
switch( mode )
{
case 0:
if( iswalnum(data->buff[end_buff_pos] ) )
mode++;
break;
case 1:
if( !iswalnum(data->buff[end_buff_pos] ) )
{
if( !dir )
end_buff_pos -= step;
mode++;
}
break;
/*
case 2:
if( !iswspace(data->buff[end_buff_pos] ) )
{
mode++;
if( !dir )
end_buff_pos-=step;
}
break;
*/
}
break;
}
end_buff_pos+=step;
}
while( 1 )
{
wchar_t c;
if( !dir )
{
if( end_buff_pos == 0 )
break;
}
else
{
if( end_buff_pos == data->buff_len )
break;
}
if( mode==2)
break;
c = data->buff[end_buff_pos];
if( !iswalnum( c ) )
{
/*
Don't gobble the boundary character if it was a
whitespace, but do for all other non-alphabetic
characters
*/
if( iswspace( c ) )
end_buff_pos -= step;
break;
}
end_buff_pos+=step;
}
if( erase )
@@ -2011,7 +2071,7 @@ static void move_word( int dir, int erase )
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 0 );
}
else
{
@@ -2036,7 +2096,7 @@ static void move_word( int dir, int erase )
}
}
repaint();
repaint( 0 );
// check_colors();
}
}
@@ -2390,7 +2450,7 @@ wchar_t *reader_readline()
data->exec_prompt=1;
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 1 );
tcgetattr(0,&old_modes); /* get the current terminal modes */
if( tcsetattr(0,TCSANOW,&shell_modes)) /* set the new modes */
@@ -2475,7 +2535,7 @@ wchar_t *reader_readline()
{
data->buff_pos = 0;
repaint();
repaint( 0 );
break;
}
@@ -2484,14 +2544,14 @@ wchar_t *reader_readline()
{
data->buff_pos = data->buff_len;
repaint();
repaint( 0 );
break;
}
case R_NULL:
{
data->exec_prompt=1;
repaint();
repaint( 0 );
break;
}
@@ -2560,7 +2620,7 @@ wchar_t *reader_readline()
data->buff[data->buff_len]=L'\0';
repaint();
repaint( 0 );
break;
}
@@ -2579,7 +2639,7 @@ wchar_t *reader_readline()
data->buff_pos=0;
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 0 );
break;
}
@@ -2590,7 +2650,7 @@ wchar_t *reader_readline()
data->buff[data->buff_len]=L'\0';
reader_super_highlight_me_plenty( data->buff, data->color, data->buff_pos, 0 );
repaint();
repaint( 0 );
break;
}
@@ -2688,7 +2748,7 @@ wchar_t *reader_readline()
writech('\r');
writembs(clr_eol);
writech('\n');
repaint();
repaint( 0 );
}
break;
@@ -2772,7 +2832,7 @@ wchar_t *reader_readline()
}
else
{
repaint();
repaint( 0 );
}
}
break;
@@ -2793,7 +2853,7 @@ wchar_t *reader_readline()
{
data->buff_pos++;
repaint();
repaint( 0 );
}
}
break;
@@ -2804,7 +2864,7 @@ wchar_t *reader_readline()
data->buff[0]=0;
data->buff_len=0;
data->buff_pos=0;
repaint();
repaint( 0 );
break;
}
@@ -2840,7 +2900,7 @@ wchar_t *reader_readline()
{
if( clear_screen )
writembs( clear_screen );
repaint();
repaint( 0 );
break;
}

View File

@@ -1,6 +1,8 @@
/** \file sanity.c
Functions for performing sanity checks on the program state
*/
#include "config.h"
#include <stdlib.h>
#include <wchar.h>
#include <stdio.h>
@@ -13,8 +15,6 @@
#include <dirent.h>
#include "config.h"
#include "fallback.h"
#include "util.h"

2
seq.in
View File

@@ -39,7 +39,7 @@ switch (count $argv)
end
for i in $from $step $to
if not echo $i | grep '^-\?[0-9]*\(\|.[0-9]\+\)$' >/dev/null
if not echo $i | grep -E '^-?[0-9]*([0-9]*|\.[0-9]+)$' >/dev/null
printf (_ "%s: '%s' is not a number\n") seq $i
exit 1
end

View File

@@ -56,11 +56,7 @@
*/
#define GETOPT_STRING "b:hvocu"
#if HAVE_GETTEXT
#define _(string) gettext(string)
#else
#define _(string) (string)
#endif
char *col[]=
{
@@ -141,10 +137,8 @@ static void check_locale_init()
is_init = 1;
setlocale( LC_ALL, "" );
#if HAVE_GETTEXT
bindtextdomain( PACKAGE_NAME, LOCALEDIR );
textdomain( PACKAGE_NAME );
#endif
}
@@ -159,7 +153,6 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{
@@ -200,11 +193,7 @@ int main( int argc, char **argv )
GETOPT_STRING,
long_options,
&opt_index );
#else
int opt = getopt( argc,
argv,
GETOPT_STRING );
#endif
if( opt == -1 )
break;
@@ -337,6 +326,9 @@ int main( int argc, char **argv )
}
}
del_curterm( cur_term );
if( del_curterm( cur_term ) == ERR )
{
fprintf( stderr, _("Error while closing terminfo") );
}
}

View File

@@ -12,4 +12,4 @@ complete -c complete -s u -l unauthorative -d (N_ "Option list is not complete")
complete -c complete -s e -l erase -d (N_ "Remove completion")
complete -c complete -s h -l help -d (N_ "Display help and exit")
complete -c complete -s C -l do-complete -d (N_ "Print all completions for the specified commandline")
complete -c complete -s n -l complete -d (N_ "The completion should only be used if the specified command has a zero exit status") -r
complete -c complete -s n -l condition -d (N_ "The completion should only be used if the specified command has a zero exit status") -r

View File

@@ -4,23 +4,6 @@
# Incomplete, the number of switches for darcs is _huge_
#
#
# Test if a non-switch argument has been given
#
function __fish_use_subcommand
set -l -- cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
switch $i
case '-*'
continue
end
return 1
end
return 0
end
#
# If no subcommand has been specified, complete using all available subcommands
#

View File

@@ -4,3 +4,4 @@ complete -c functions -s a -l all -d (N_ "Show hidden functions")
complete -c functions -s h -l help -d (N_ "Display help and exit")
complete -c functions -s d -l description -d (N_ "Set function description") -x
complete -c functions -s q -l query -d (N_ "Test if function is defined")
complete -c functions -s n -l names -d (N_ "List the names of the functions, but not their definition")

View File

@@ -1,10 +1,19 @@
#Completions for make
# Completions for make
function __fish_print_make_targets
set files Makefile makefile GNUmakefile
grep -h -E '^[^#%=$[:space:]][^#%=$]*:([^=]|$)' $files | cut -d ":" -f 1 | sed -e 's/^ *//;s/ *$//;s/ */\n/g' ^/dev/null
end
# This completion is a bit ugly. It reenables file completion on
# assignments, so e.g. 'make foo FILES=<tab>' will recive standard
# filename completion. Unfortunatly, this turns out to be a bit
# complicated to do.
set -l is_assignment "commandline -ct|grep '..*='"
set -l complete_file_assignment '(commandline -ct)(complete --do-complete=this_command_does_not_exist\ (commandline -ct|sed -e \'s/.*=//\'))'
complete -c make --condition $is_assignment -a $complete_file_assignment
complete -x -c make -a "(__fish_print_make_targets)" -d (N_ "Target")
complete -r -c make -s f -d (N_ "Use file as makefile") -r
complete -x -c make -s C -x -a "(__fish_complete_directory (commandline -ct))" -d (N_ "Change directory")

View File

@@ -63,6 +63,8 @@ complete -c set -n '__fish_is_first_token' -s l -l local -d (N_ "Make variable s
complete -c set -n '__fish_is_first_token' -s U -l universal -d (N_ "Make variable scope universal, i.e. share variable with all the users fish processes on this computer")
complete -c set -n '__fish_is_first_token' -s q -l query -d (N_ "Test if variable is defined")
complete -c set -n '__fish_is_first_token' -s h -l help -d (N_ "Display help and exit")
complete -c set -n '__fish_is_first_token' -s n -l names -d (N_ "List the names of the variables, but not their value")
# Complete using preexisting variable names
complete -c set -n '__fish_is_first_token' -x -a "(set|sed -e 's/ /'\t'Variable: /')"

View File

@@ -2,47 +2,35 @@
# Completions for the svn VCS command
#
function __fish_svn_subcommand_allowed
set -l svncommands add blame cat checkout cleanup commit copy delete diff di help import info list lock log merge mkdir move propdel propedit propget proplist resolved revert status switch unlock update
set -l -- cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
if contains -- $i $svncommands
return 1
end
end
return 0
end
#
# If no subcommand has been specified, complete using all available subcommands
#
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'add\t"'(_ "Place files or directories under version control")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'blame\t"'(_ "Output files/URLs with revision and author information inline")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'cat\t"'(_ "Output content of files/URLs")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'checkout\t"'(_ "Check out a working copy from the repository")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'cleanup\t"'(_ "Recursively clean up the working copy")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'commit\t"'(_ "Send changes from your working copy to the repository")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'import\t"'(_ "Commit an unversioned file or tree into the repository")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'info\t"'(_ "Display information about a local or remote item")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'list\t"'(_ "List directory entries in the repository")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'lock\t"'(_ "Lock working copy paths or URLs in the repository")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'log\t"'(_ "Show the log messages for a set of revision(s) and/or file(s)")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'merge\t"'(_ "Apply the differences between two sources to a working copy path")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'mkdir\t"'(_ "Create a new directory under version control")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'move\t"'(_ "Move and/or rename something in working copy or repository")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'propdel\t"'(_ "Remove a property from files, dirs, or revisions")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'propedit\t"'(_ "Edit a property with an external editor on targets")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'propget\t"'(_ "Print value of a property on files, dirs, or revisions")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'proplist\t"'(_ "List all properties on files, dirs, or revisions")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'resolved\t"'(_ "Remove conflicted state on working copy files or directories")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'revert\t"'(_ "Restore pristine working copy file")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'status\t"'(_ "Print the status of working copy files and directories")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'switch\t"'(_ "Update the working copy to a different URL")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'unlock\t"'(_ "Unlock working copy paths or URLs")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'update\t"'(_ "Bring changes from the repository into the working copy")'"'
complete -c svn -n '__fish_svn_subcommand_allowed' -xa 'help\t"'(_ "Describe the usage of this program or its subcommands")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'add\t"'(_ "Place files or directories under version control")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'blame\t"'(_ "Output files/URLs with revision and author information inline")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'cat\t"'(_ "Output content of files/URLs")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'checkout\t"'(_ "Check out a working copy from the repository")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'cleanup\t"'(_ "Recursively clean up the working copy")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'commit\t"'(_ "Send changes from your working copy to the repository")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'import\t"'(_ "Commit an unversioned file or tree into the repository")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'info\t"'(_ "Display information about a local or remote item")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'list\t"'(_ "List directory entries in the repository")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'lock\t"'(_ "Lock working copy paths or URLs in the repository")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'log\t"'(_ "Show the log messages for a set of revision(s) and/or file(s)")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'merge\t"'(_ "Apply the differences between two sources to a working copy path")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'mkdir\t"'(_ "Create a new directory under version control")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'move\t"'(_ "Move and/or rename something in working copy or repository")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'propdel\t"'(_ "Remove a property from files, dirs, or revisions")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'propedit\t"'(_ "Edit a property with an external editor on targets")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'propget\t"'(_ "Print value of a property on files, dirs, or revisions")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'proplist\t"'(_ "List all properties on files, dirs, or revisions")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'resolved\t"'(_ "Remove conflicted state on working copy files or directories")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'revert\t"'(_ "Restore pristine working copy file")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'status\t"'(_ "Print the status of working copy files and directories")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'switch\t"'(_ "Update the working copy to a different URL")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'unlock\t"'(_ "Unlock working copy paths or URLs")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'update\t"'(_ "Bring changes from the repository into the working copy")'"'
complete -c svn -n '__fish_use_subcommand' -xa 'help\t"'(_ "Describe the usage of this program or its subcommands")'"'
# -s/--revision
complete -c svn -n '__fish_seen_subcommand_from blame cat checkout info list log merge move propdel propedit propget proplist switch update' -x -s r -l revision -d (N_ "Specify revision")

View File

@@ -11,22 +11,33 @@
set -g fish_function_path @datadir@/fish/functions/
set __fish_help_dir @docdir@
# This is a Solaris-specific test to modify the PATH so that
# Posix-conformant tools are used by default.
if test -d /usr/xpg4/bin
if not contains /usr/xpg4/bin $PATH
set PATH /usr/xpg4/bin $PATH
end
end
#
# Make sure there are no invalid entries in the PATH
#
set -l erase_idx
for idx in (seq (count $PATH))
set i $PATH[$idx]
if not test -d $i
set erase_idx $erase_idx $idx
printf (_ '%s: Warning: The directory %s has been removed from your PATH because it does not exist\n') fish $i
end
end
if status --is-interactive
set -l erase_idx
for idx in (seq (count $PATH))
set i $PATH[$idx]
if not test -d $i
set erase_idx $erase_idx $idx
printf (_ '%s: Warning: The directory %s has been removed from your PATH because it does not exist\n') fish $i
end
end
if count $erase_idx >/dev/null
set -e PATH[(echo $erase_idx)]
if count $erase_idx >/dev/null
set -e PATH[(echo $erase_idx)]
end
end
#
@@ -43,12 +54,11 @@ if test "$USER" = root
end
# Make a regular expression that matches any component in the PATH. A
# trailing slash is ok. The sed call is to remove the last '\|'.
# trailing slash is ok. The sed call is to remove the last '|'.
set -l tmp (printf "%s" \^$PATH'/?$|')
set -l path_regexp \((echo $tmp | sed -e "s/.\$//")\)
set -l path_regexp \\\((printf "%s" \^$PATH'\(\|/\)$\|' | sed -e "s/..\$//")\\\)
for i in (printf "%s\n" $path_list|grep -v $path_regexp)
for i in (printf "%s\n" $path_list|grep -E -v $path_regexp)
if test -d $i
set PATH $PATH $i
end
@@ -98,7 +108,7 @@ end
# Completions for the shell and it's builtin commands and functions
#
for i in (builtin -n|grep -v '\(while\|for\|if\|function\|switch\)' )
for i in (builtin -n|grep -E -v '(while|for|if|function|switch)' )
complete -c $i -s h -l help -d "Display help and exit"
end

View File

@@ -0,0 +1,14 @@
function __fish_use_subcommand -d "Test if a non-switch argument has been given in the current commandline"
set -l -- cmd (commandline -poc)
set -e cmd[1]
for i in $cmd
switch $i
case '-*'
continue
end
return 1
end
return 0
end

View File

@@ -18,6 +18,12 @@ function help -d (N_ "Show help for the fish shell")
set h $h expand-variable expand-home expand-brace expand-wildcard
set -l help_topics $h expand-command-substitution expand-process
# 'help -h' should launch 'help help'
switch $argv[1]
case -h --h --he --hel --help
set argv help
end
#
# Find a suitable browser for viewing the help pages. This is needed
# by the help function defined below.
@@ -92,6 +98,16 @@ function help -d (N_ "Show help for the fish shell")
end
if test $fish_browser_bg
switch $fish_browser
case 'htmlview' 'x-www-browser'
printf (_ 'help: Help is being displayed in your default browser\n')
case '*'
printf (_ 'help: Help is being displayed in %s\n') $fish_browser
end
eval $fish_browser file://$__fish_help_dir/$fish_help_page \&
else
eval $fish_browser file://$__fish_help_dir/$fish_help_page

View File

@@ -50,7 +50,7 @@ if command ls --version 1>/dev/null 2>/dev/null
else
# BSD, OS X and a few more support colors through the -G switch instead
if ls / -G 1>/dev/null 2>/dev/null
if command ls / -G 1>/dev/null 2>/dev/null
function ls -d (N_ "List contents of directory")
command ls -G $argv
end

View File

@@ -15,6 +15,10 @@ The library for various signal related issues
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
#include "common.h"
#include "fallback.h"
#include "util.h"
@@ -281,7 +285,7 @@ const static struct lookup_entry lookup[] =
}
,
#endif
#ifdef SIGWIO
#ifdef SIGIO
{
SIGIO,
L"SIGIO",

152
util.c
View File

@@ -50,18 +50,6 @@
*/
#define SB_MAX_SIZE 32767
float minf( float a,
float b )
{
return a<b?a:b;
}
float maxf( float a,
float b )
{
return a>b?a:b;
}
int mini( int a,
int b )
@@ -310,9 +298,14 @@ void *hash_get( hash_table_t *h,
int pos = hash_search( h, (void *)key );
if( h->arr[pos].key == 0 )
{
return 0;
}
else
return h->arr[pos].data;
{
void *res =h->arr[pos].data;
return res;
}
}
void *hash_get_key( hash_table_t *h,
@@ -680,21 +673,43 @@ void al_destroy( array_list_t *l )
free( l->arr );
}
int al_push( array_list_t *l, const void *o )
static int al_push_generic( array_list_t *l, anything_t o )
{
if( l->pos >= l->size )
{
int new_size = l->pos == 0 ? MIN_SIZE : 2 * l->pos;
void *tmp = realloc( l->arr, sizeof( void *)*new_size );
void *tmp = realloc( l->arr, sizeof( anything_t )*new_size );
if( tmp == 0 )
return 0;
l->arr = tmp;
l->size = new_size;
}
l->arr[l->pos++] = (void *)o;
l->arr[l->pos++] = o;
return 1;
}
int al_push( array_list_t *l, const void *o )
{
anything_t v;
v.ptr_val = (void *)o;
return al_push_generic( l, v );
}
int al_push_long( array_list_t *l, long val )
{
anything_t v;
v.long_val = val;
return al_push_generic( l, v );
}
int al_push_func( array_list_t *l, func_ptr_t f )
{
anything_t v;
v.func_val = f;
return al_push_generic( l, v );
}
int al_push_all( array_list_t *a, array_list_t *b )
{
int k;
@@ -707,7 +722,7 @@ int al_push_all( array_list_t *a, array_list_t *b )
}
int al_set( array_list_t *l, int pos, const void *o )
static int al_set_generic( array_list_t *l, int pos, anything_t v )
{
int old_pos;
@@ -715,48 +730,88 @@ int al_set( array_list_t *l, int pos, const void *o )
return 0;
if( pos < l->pos )
{
l->arr[pos] = (void *)o;
l->arr[pos]=v;
return 1;
}
old_pos=l->pos;
l->pos = pos;
if( al_push( l, o ) )
if( al_push_generic( l, v ) )
{
/* fwprintf( stderr, L"Clearing from index %d to index %d\n",
old_pos, pos );
*/
memset( &l->arr[old_pos],
0,
sizeof(void *) * (pos - old_pos) );
sizeof(anything_t) * (pos - old_pos) );
return 1;
}
return 0;
}
int al_set( array_list_t *l, int pos, const void *o )
{
anything_t v;
v.ptr_val = (void *)o;
return al_set_generic( l, pos, v );
}
int al_set_long( array_list_t *l, int pos, long o )
{
anything_t v;
v.long_val = o;
return al_set_generic( l, pos, v );
}
int al_set_func( array_list_t *l, int pos, func_ptr_t o )
{
anything_t v;
v.func_val = o;
return al_set_generic( l, pos, v );
}
static anything_t al_get_generic( array_list_t *l, int pos )
{
anything_t res;
res.ptr_val=0;
if( (pos >= 0) && (pos < l->pos) )
res = l->arr[pos];
return res;
}
void *al_get( array_list_t *l, int pos )
{
if( pos < 0 )
return 0;
if( pos >= l->pos )
return 0;
return l->arr[pos];
return al_get_generic(l,pos).ptr_val;
}
long al_get_long( array_list_t *l, int pos )
{
return al_get_generic(l,pos).long_val;
}
func_ptr_t al_get_func( array_list_t *l, int pos )
{
return al_get_generic(l,pos).func_val;
}
void al_truncate( array_list_t *l, int new_sz )
{
l->pos = new_sz;
}
void *al_pop( array_list_t *l )
static anything_t al_pop_generic( array_list_t *l )
{
void *e = l->arr[--l->pos];
anything_t e = l->arr[--l->pos];
if( (l->pos*3 < l->size) && (l->size < MIN_SIZE) )
{
void ** old_arr = l->arr;
anything_t *old_arr = l->arr;
int old_size = l->size;
l->size = l->size/2;
l->arr = realloc( l->arr, sizeof(void*)*l->size );
l->arr = realloc( l->arr, sizeof(anything_t)*l->size );
if( l->arr == 0 )
{
l->arr = old_arr;
@@ -766,10 +821,43 @@ void *al_pop( array_list_t *l )
return e;
}
void *al_pop( array_list_t *l )
{
return al_pop_generic(l).ptr_val;
}
long al_pop_long( array_list_t *l )
{
return al_pop_generic(l).long_val;
}
func_ptr_t al_pop_func( array_list_t *l )
{
return al_pop_generic(l).func_val;
}
static anything_t al_peek_generic( array_list_t *l )
{
anything_t res;
res.ptr_val=0;
if( l->pos>0)
res = l->arr[l->pos-1];
return res;
}
void *al_peek( array_list_t *l )
{
return al_peek_generic(l).ptr_val;
}
return l->pos>0?l->arr[l->pos-1]:0;
long al_peek_long( array_list_t *l )
{
return al_peek_generic(l).long_val;
}
func_ptr_t al_peek_func( array_list_t *l )
{
return al_peek_generic(l).func_val;
}
int al_empty( array_list_t *l )
@@ -787,14 +875,14 @@ void al_foreach( array_list_t *l, void (*func)( void * ))
{
int i;
for( i=0; i<l->pos; i++ )
func( l->arr[i] );
func( l->arr[i].ptr_val );
}
void al_foreach2( array_list_t *l, void (*func)( void *, void *), void *aux)
{
int i;
for( i=0; i<l->pos; i++ )
func( l->arr[i], aux );
func( l->arr[i].ptr_val, aux );
}
int wcsfilecmp( const wchar_t *a, const wchar_t *b )

98
util.h
View File

@@ -15,6 +15,17 @@
#include <stdarg.h>
#include <unistd.h>
typedef void (*func_ptr_t)();
typedef union
{
long long_val;
void *ptr_val;
func_ptr_t func_val;
}
anything_t;
/**
Data structure for an automatically resizing dynamically allocated queue,
*/
@@ -29,7 +40,7 @@ typedef struct dyn_queue
/** Where to remove elements */
void **get_pos;
}
dyn_queue_t;
dyn_queue_t;
/**
Internal struct used by hash_table_t.
@@ -41,7 +52,7 @@ typedef struct
/** Value */
void *data;
}
hash_struct_t;
hash_struct_t;
/**
Data structure for the hash table implementaion. A hash table allows for
@@ -71,7 +82,7 @@ typedef struct hash_table
/** Comparison function */
int (*compare_func)( void *key1, void *key2 );
}
hash_table_t;
hash_table_t;
/**
Data structure for an automatically resizing dynamically allocated
@@ -99,7 +110,7 @@ priority_queue_t;
typedef struct array_list
{
/** Array containing the data */
void **arr;
anything_t *arr;
/** Position to append elements at*/
int pos;
/** Length of array */
@@ -149,16 +160,6 @@ int maxi( int a, int b );
*/
int mini( int a, int b );
/**
Returns the larger of two floats
*/
float maxf( float a, float b );
/**
Returns the smaller of two floats
*/
float minf( float a, float b );
/*
All the datastuctures below autoresize. The queue, stack and
priority queue are all impemented using an array and are guaranteed
@@ -361,7 +362,8 @@ int pq_get_count( priority_queue_t *q );
void pq_destroy( priority_queue_t *q );
/**
Allocate heap memory for creating a new list and initialize it
Allocate heap memory for creating a new list and initialize
it. Equivalent to calling malloc and al_init.
*/
array_list_t *al_new();
@@ -384,6 +386,24 @@ void al_destroy( array_list_t *l );
\return 1 if succesfull, 0 otherwise
*/
int al_push( array_list_t *l, const void *o );
/**
Append element to list
\param l The list
\param o The element
\return
\return 1 if succesfull, 0 otherwise
*/
int al_push_long( array_list_t *l, long o );
/**
Append element to list
\param l The list
\param o The element
\return
\return 1 if succesfull, 0 otherwise
*/
int al_push_func( array_list_t *l, void (*f)() );
/**
Append all elements of a list to another
@@ -402,6 +422,22 @@ int al_push_all( array_list_t *a, array_list_t *b );
\param o The element
*/
int al_set( array_list_t *l, int pos, const void *o );
/**
Sets the element at the specified index
\param l The array_list_t
\param pos The index
\param o The element
*/
int al_set_long( array_list_t *l, int pos, long v );
/**
Sets the element at the specified index
\param l The array_list_t
\param pos The index
\param o The element
*/
int al_set_func( array_list_t *l, int pos, void (*f)() );
/**
Returns the element at the specified index
@@ -411,6 +447,22 @@ int al_set( array_list_t *l, int pos, const void *o );
\return The element
*/
void *al_get( array_list_t *l, int pos );
/**
Returns the element at the specified index
\param l The array_list_t
\param pos The index
\return The element
*/
long al_get_long( array_list_t *l, int pos );
/**
Returns the element at the specified index
\param l The array_list_t
\param pos The index
\return The element
*/
func_ptr_t al_get_func( array_list_t *l, int pos );
/**
Truncates the list to new_sz items.
@@ -421,6 +473,14 @@ void al_truncate( array_list_t *l, int new_sz );
Removes and returns the last entry in the list
*/
void *al_pop( array_list_t *l );
/**
Removes and returns the last entry in the list
*/
long al_pop_long( array_list_t *l );
/**
Removes and returns the last entry in the list
*/
func_ptr_t al_pop_func( array_list_t *l );
/**
Returns the number of elements in the list
@@ -431,6 +491,14 @@ int al_get_count( array_list_t *l );
Returns the last entry in the list witout removing it.
*/
void *al_peek( array_list_t *l );
/**
Returns the last entry in the list witout removing it.
*/
long al_peek_long( array_list_t *l );
/**
Returns the last entry in the list witout removing it.
*/
func_ptr_t al_peek_func( array_list_t *l );
/**
Returns 1 if the list is empty, 0 otherwise

View File

@@ -395,7 +395,7 @@ static int test_flags( wchar_t *filename,
return 0;
}
if( S_IFDIR & buf.st_mode )
if( S_ISDIR( buf.st_mode ) )
return 1;
if( flags & EXECUTABLES_ONLY )
@@ -684,7 +684,7 @@ int wildcard_expand( const wchar_t *wc,
if( !stat_res )
{
if( buf.st_mode & S_IFDIR )
if( S_ISDIR(buf.st_mode) )
{
new_len = wcslen( new_dir );
new_dir[new_len] = L'/';

29
wutil.c
View File

@@ -9,7 +9,6 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <wchar.h>
@@ -53,12 +52,14 @@
the \c wutil_wcs2str() function.
*/
static char *tmp=0;
/**
Buffer for converting narrow results to wide ones, used by the \c
wutil_str2wcs() function. Avoid usign this without thinking about
it, since sebseuent calls will overwrite previous values.
it, since subsequent calls will overwrite previous values.
*/
static wchar_t *tmp2;
/**
Length of the \c tmp buffer.
*/
@@ -518,3 +519,27 @@ const wchar_t *wgettext( const wchar_t *in )
return wres;
}
wchar_t *wgetenv( const wchar_t *name )
{
char *name_narrow =wutil_wcs2str(name);
char *res_narrow = getenv( name_narrow );
static string_buffer_t *out = 0;
if( !res_narrow )
return 0;
if( !out )
{
out = sb_halloc( global_context );
}
else
{
sb_clear( out );
}
sb_printf( out, L"%s", res_narrow );
return (wchar_t *)out->buff;
}

View File

@@ -128,4 +128,10 @@ wchar_t *wbasename( const wchar_t *path );
*/
const wchar_t *wgettext( const wchar_t *in );
/**
Wide character version of getenv
*/
wchar_t *wgetenv( const wchar_t *name );
#endif