Term-ReadLine-Gnu-1.35/0000705060175006010010000000000013006645264013364 5ustar hirooNoneTerm-ReadLine-Gnu-1.35/Changes0000644060175006010010000005101613006644257014670 0ustar hirooNone -*- Indented-text -*- $Id: Changes 556 2016-11-03 14:24:45Z hayashi $ 1.35 2016-11-03 - readline-7.0 support new function rl_clear_visible_line rl_tty_set_echoing rl_pending_signal new variable rl_persistent_signal_handlers - Gnu.xs: fix a bug of rl_readline_state variable causing on a big-endian, sizeof(int)==4, and sizeof(long)==8 platform with the GNU Readline Library 7.0. [rt.cpan.org #118371] 1.34 2016-06-12 - ppport.h: update from version 1.0007 to version 3.31. - t/utf8_text.t: fix for the fail when PERL_UNICODE environment variable is set. 1.33 2016-06-10 - Gnu.pm, t/utf8_text.t: fix version checks for perl 5.10.0. - t/utf8_text.t: fix the number of skip for systems which do not support en_US.UTF-8 locale. - Gnu.pm: delete old formated 'use VERSION' 1.32 2016-06-06 - improve UTF-8 handling - UTF-8 decoding is done at the interface between Perl and XS. This makes it possible for UTF-8 strings to be get from the GNU Readline Library functions and variables. - add enableUTF8() method - UTF-8 support is enabled when STDIN is in UTF-8 by the -C command-line switch, or PERL_UNICODE environment variable, or IN file handle has utf8 IO layer, or -enableUTF8 method is called. - pop IO layer only when stdio layer is pushed on utf8 layer to support Perl 5.8.x - rl_save_state(), rl_restore_state(), history_get_history_state(), and history_set_history_state() are finally implemented. - update RL_STATE_* definitions - fix rl_readline_state and history_legnth variable to be writable - fix rl_completion_quote_character and rl_completion_found_quate variable to be read only - update POD document - t/*.t: use Test::More and improved - t/utf8_binary.t, t/utf8_text.t: - use en_US.UTF-8 instead of en_US.utf8 for locale - force the GNU Readline Library 8bit through - add variable access test, IO layer check, verbose mode, etc. - use camel characters instead of Japanese kanji characters - t/utf8_binary.t: skip when PERL_UNICODE is set. [rt.cpan.org #114185] - t/utf8.txt: use camel characters instead of Japanese kanji characters - t/callback.t: update comments and code clean-up - use some modern Perl features (but still in 5.8 era) - use file handle references - define export tags - comment out 'use vars' for subroutine name aliase 1.31 2016-03-06 - t/utf8_binary.t, t/utf_text.t: skip on non UTF-8 environment. - t/readline.t: skip the cursor move test for an active CPAN tester's environment 1.30 2016-03-02 - t/utf8_binary.t: add a fix to handle escape sequences which rl_initialize may output. 1.29 2016-02-28 - pop the stdio PerlIO layer only when utf8 layer is included for remote debugging. [rt.cpan.org #110121] - call utf8::decode() for a UTF8-enabled input filehandle. [rt.cpan.org #104239] - call newTTY() any time to set filehandles. - make use of 'our' instead of 'use vars'. - add tests for UTF-8 handling. - pass _rl_store_iostream 'FILE *' in stead of 'PerlIO *'. - remove T_STDIO definition from typemap. - requires Perl 5.8.1 1.28 2015-09-21 - Makefile.PL: revert a change on 1.27 which causes fail on the rlmalloc test. [rt.cpan.org #107201] - t/readline.t, t/history.t: use LC_ALL instead of LANG. 1.27 2015-09-06 - readline-7.0-rc2 support new function rl_callback_sigcleanup - improve POD documents - Gnu.xs: not to use obsoleted typedefs which were obsoleted by ReadLine 6.3 - fix a wrong fix on 1.21 to let completion_function do case insensitive match. [rt.cpan.org #72378] - fix rl_display_match_list to show the first entry of the array. The bug caused segmentation fault with readline-7.0. - some improvement of Makefile.PL: - add support homebrew on Mac OS X. [rt.cpan.org #104389] - print an error string when system() fails. - specify 'int' on 'main()'. - use -O when -D_FORTIFY_SOURCE is defined. 1.26 2015-01-31 - call ornaments() after rl_initialize() to set tty before calling rl_initialize() not to output some charactores to STDIO. [rt.cpan.org #96569, #101196] - make handling of iostreams simple (make _rl_store_iostream() return void and remove _rl_fetch_iostream()) [rt.cpan.org #101078] - fix the Prerequisites section to require Perl 5.8 (it was required since TRG 1.23.). - t/callback.t: add some new Tk-tests from CPAN Testers' site. 1.25 2014-12-13 - fix to call rl_initialize() after I/O stream setting. [rt.cpan.org #96569] - t/readline.t: comment-out stty-command calls. - t/history.t, t/readline.t: print out the corresponding section names in the manuals of the libraries. - eg/perlsh: use 'IO' instead of 'FILEHANDLE' which Perl 5.20 warns. [rt.cpan.org #100883] - fix copyright notices to use the year of first publication. 1.24 2014-03-23 - fix not to make the PerlIO layer empty for Perl 5.8.9 or before. [rt.cpan.org #59832] - update Pod document assuming the use of Pod::Simple::HTMLBatch. - t/00checkver.t: not to use 'display-readline-version' and "use Test;" - INSTALL: add "(Install) Using Package" section. 1.23 2014-03-20 - add description of the pager command bug in Perl debugger which causes segementation fault [rt.perl.org #121456] - fix not to clobber binmode layer (utf-8) on filehandles [rt.cpan.org #59832] - support UTF-8 input as compatible with Term::ReadLine - Now Term::ReadLine::Gnu requires perl 5.8.0 or above - define Term::ReadLine::Gnu::ornaments method [rt.cpan.org #93614] - Makefile.PL: Fix the URL of the bug-tracker [rt.cpan.org #93680] - eg/perlsh: POD syntax fix. [rt.cpan.org #93895] - README: add note for bug-tracker - INSTALL: update "1.3 Trouble Shooting" 1.22 2014-03-05 - make Kwalitee friendly - add MakeMaker options for META.yml - add Changelog - fix POD errors - make .pm versions consistent - use "use warnings" - Makefile.PL dies on the CPAN Test for OpenBSD temporarily (hopefully). 1.21 2014-03-02 - readline-6.3 support (Gnu Readline Library 6.3 requires this release or newers.) new function rl_clear_history new variable rl_signal_event_hook rl_input_available_hook rl_executing_key rl_executing_keyseq rl_key_sequence_length rl_change_environment rl_filename_stat_hook - readline-6.1 support new function rl_free_keymap (enabled) new variable rl_filename_rewrite_hook (now implemented) - make the following variables read-only.: rl_executing_macro, history_length, rl_readline_state, rl_explicit_arg, rl_numeric_arg, rl_editing_mode - Improve backward compatiblity variable and function definitions. - Fix Term::ReadLine::Gnu::XS::_trp_completion_function not to perform a case-sensitive filter. [rt.cpan.org #72378] - fix Gnu.xs:rl_initialize to be compiled with Perl 5.8.5 or before. [rt.cpan.org #61626] - update Pod documents - t/readline.t, t/history.t: add variable access tests. - t/readline.t: consider .svn directory on filename completion test and to set the standard tty setting before re_initialize() being called. - eg/perlsh makes use of the deferred signal (safe signal) feature. - Maefile.PL checks whether the xmalloc exported by readline is indeed called 'xmalloc' or whether it has been renamed to '_rl_malloc'. [rt.cpan.org #65973] - Makefile.PL: add -DTRL_READLINE_VERSION to show GNU Readline Library version in CPAN Tester Reports. - t/00checkver.t: let messages go to stdout. - README: add project home page URL and remove out-of-date descriptions. - INSTALL: add a section "Install on Mac OS X" 1.20 2010-05-02 - Make a copy of the environment variable array to stop segmentation faults on some systems (ex. FreeBSD) - t/readline.t skip the test of rl_readline_version for GNU Readline Library 6.1 which may return a wrong value [rt.cpan.org #54977] - readline-6.1 support new function rl_free_keymap (disabled due to readline-6.1 bug) new variable rl_filename_rewrite_hook (not implemented yet) 1.19 2009-03-21 - make sure the outstream fd inside the readline library is in sync [rt.cpan.org #16440] - fixes to be more CPAN Testers friendly - t/readline.t does not use visible bell for "make test" - Makefile.PL requires perl 5.7.0 or later. (Use Term::ReadLine::Gnu-1.09 for older Perl.) - Makefile.PL exits 0 when /dev/tty cannot be opened. - INSTALL add description of the -DPERL_USE_SAFE_PUTENV issue. If you encounter a segmentation fault, read it. [rt.cpan.org #37194] 1.18 2009-02-27 - better error checking of Makefile.PL for automatic testing on non-supported platfrom (for example one without GNU Readline Library). - readline-6.0 support new function rl_save_state (not supported yet) rl_restore_state (not supported yet) rl_echo_signal_char new variable rl_display_prompt rl_sort_completion_matches rl_completion_invoking_key t/history.t does not fail by hist_expand() which is fixed on readline-6.0 1.17 2008-02-07 - Unnecessary PerlIO_releaseFILE() calls are removed. This fix prevents `make test' from failing on Perl 5.10. - Makefile.PL now fails with the EditLine Library on MacOS X. Use the GNU Readline Library. [rt.cpan.org #28523] - tested with readline-5.2 (which has no new feature to be supported). 1.16 2006-04-02 - fix Makefile.PL to work with the latest Cygwin. (Use 1.15 for old Cygwin.) - readline-5.1 support new function variable_value reset_screen_size new variable prefer_env_winsize 1.15 2004-10-17 - readline-5.0 support new function bind_key_if_unbound bind_keyseq bind_keyseq_if_unbound tty_unset_default_bindings add_history_time history_get_time new variable history_write_timestamps completion_quote_character completion_suppress_quote completion_found_quote completion_word_break_hook - double IO stream close bug fix (more use of PerlIO) [rt.cpan.org #7672] - warning on 'use Term::ReadLine::Gnu;'. 1.14 2003-03-16 - kludge not to cause segmentation fault on Perl 5.8.0 w/PerlIO and FileHandle (ex. CPAN.pm) - clean up Makefile.PL (use strict, fix for HPUX and FreeBSD, fix typo, etc.) 1.13 2002-07-27 - readline-4.3 support new variables rl_completion_suppress_append rl_completion_mark_symlink_dirs new functions rl_replace_line() rl_completion_mode() - tgetstr() calls tput() to apply padding information. No more "$<2>" on prompt. - shadow_redisplay() with ornament works on xterm. 1.12 2002-03-30 - add '-static' flag to 'LDDFLAGS' on Cygwin 1.3. - shadow redisplay does not pester you with warning on a poor terminal, or a terminal with wrong TERM environment variable setting. - update documents - improve coding style of Gnu.xs. (indentation style, more typemap, etc.) 1.11 2001-10-27 - fix bug of filename-list. Now works with perldb. - by setting rl_line_buffer, proper value are set in rl_end and rl_point. - add history-expand-line command - readline-4.2a support new variable rl_readline_version new function rl_get_termcap 1.10 2001-04-22 - readline-4.2 support new variables rl_attemped_completion_over rl_completion_type rl_deprep_term_function rl_directory_rewrite_hook rl_dispatching rl_editing_mode rl_executing_macro rl_explicit_arg rl_gnu_readline_p rl_num_char_to_read rl_numeric_arg rl_prep_term_function rl_readline_state history_word_delimiters new functions rl_add_funmap_entry rl_alphabetic rl_clear_pending_input rl_crlf rl_deprep_terminal rl_execute_next rl_expand_prompt rl_get_screen_size rl_macro_bind rl_macro_dumper rl_prep_terminal rl_push_macro_input rl_set_keyboard_input_timeout rl_set_paren_blink_timeout(usec) rl_set_prompt rl_set_screen_size rl_setkey rl_show_char rl_tty_set_default_bindings rl_tty_set_default_bindings rl_variable_bind rl_variable_dumper rename functions free_undo_list() -> rl_free_undo_list() ding() -> rl_ding() completion_matches() -> rl_completion_matches() filename_completion_function -> rl_filename_completion_function() username_completion_function -> rl_username_completion_function() max_input_history -> history_max_entries - fix bug when ornament string does not use any control characters. - add Gnu/euc_jp.pm which is still experimental. - typemap: redefine FILE * to support perl 5.7. 1.09 2000-04-04 - Perl-5.6 now does not warn without `POLLUTE=1' during `perl Makefile.PL'. (Thanks to PPPort.) - change the default terminal escape sequence to stop underline. - support rl_already_prompted and rl_on_new_line_with_prompt() which are introduced by readline-4.1-beta. - support rl_funmap_names() and rl_last_func. - update documentation. 1.08 1999-12-30 - fix Makefile.PL to search libreadline.* correctly even if it is not included in the paths specified with the configuration variable `libpth'. - add dummy assignment to %ENV before $self->initialize() 1.07 1999-07-19 - search path for the GNU Readline Library is specified by command line argument instead of editing Makefile.PL. - fix bug of t/readline.t which warns for the GNU Readline version 2.1. - Makefile.PL now looks for shared libraries not only for static ones - add support for Cygwin b20.1 and HPUX (HPUX support may be incomplete.) - no change on Gnu.pm and Gnu.xs 1.06 1999-05-05 - fix a bug which causes segmentation fault when completion_matches() returns long list. - fix a bug which causes segmentation fault when perl subroutine returns a list of undef in attempted_completion_function_wrapper(). - disable Autosplit for AutoLoad.pm bug distributed with Perl 5.004 or earlier. - add check if perl is configured with sfio to Makefile.PL. 1.05 1999-04-04 - bug fix Term::ReadLine::Perl compatibility variable `completion_function' and function `rl_filename_list' are now compatible with Term::ReadLine::Perl. Completion code written for Term::ReadLine::Perl, e.g. perl5db.pl, works with this module. search text of list_completion is quoted - add support of new variables and functions introduced by GNU Readline Library Version 4.0 new variable rl_erase_empty_line rl_catch_signals rl_catch_sigwinch rl_pre_input_hook completion_display_matches_hook history_inhibit_expansion_function new function rl_display_match_list() rl_cleanup_after_signal() rl_free_line_state() rl_reset_after_signal() rl_resize_terminal() rl_set_signals() rl_clear_signals() - add support of variables and function which were not supported yet filename_quoting_function filename_dequoting_function char_is_quoted_p ignore_some_completions_function directory_completion_hook rl_get_all_function_names() - add support of functions which are specific to Term::ReadLine::Gnu display_readline_version() change_ornaments() shadow_redisplay() - rename some functions for the orthogonality rl_unbind_function_in_map to rl_unbind_function rl_unbind_command_in_map to rl_unbind_command - `make test' is executed non-interactively and comprehensively - sample code improvement eg/perlsh Perl symbol completion was rewritten and much more improved. SIGINT clears the current line add support \w (current working package) in the prompt string add support `afterinit' hook as Perl debugger. eg/pftp password input is now invisible. displaying of completion candidates are improved by using completion_display_matches_hook. - internal changes Perl code for Term::ReadLine::Gnu::XS package are moved into separate file Gnu/XS.pm and `AutoSplit'ed. replace operate_and_get_next() to one borrowed from bash. 1.04 1999-02-23 - fix a bug by which $if-$endif feature in ~/.inputrc was disabled. - works with GNU Readline Library version 4.0 in which some function names were changed. New functions, that are introduced in the new library, were not supported in this release. 1.03 1998-09-27 - fix a bug when prompt string includes non-printing characters and an input line is longer than terminal width. Constants, RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE, are incorporated from the GNU Readline Library to support this feature. - now works on a system which does not have /etc/termcap and has termcap compatible library, libncurses or libcurses. 1.02 1998-08-14 - fix a bug in Makefile.PL, which quoted a variable, $increadlinedir, with a pair of single quotes - this is an internal revision 1.01 1998-05-13 - support readline-2.2 add rl_unbind_function_in_map() and rl_unbind_command_in_map() Makefile.PL checks the version of the GNU Readline Library - define rl_save_prompt() and rl_restore_prompt() - document fix 'Changes' file is removed. It is merged into README file. fix a bug in a sample program of rl_completion_entry_function 1.00 1998-04-15 - the 1st major release - ornaments feature is now on by default as recent Term::ReadLine and Term::ReadLine::Perl - document fix remove description related to mymalloc - add ornaments-change function to t/readline.t which demonstrates rl_message(). 0.10 1998-03-31 - new functions/variables ornaments support newTTY() (not tested) max_input_history read_history() (an aliase of read_history_range()) unstifle_history() history_search_pos() history_list() history_tokenize() (Thank you, Tim Thomas) history_arg_extract() get_history_event() - new sample/test programs eg/fileman t/history.t - bug fix dynamic loading works on Solaris2.x (define xfree() locally) readline() calls add_history() only when MinLength > 0 Feature `addhistory' is renamed to `addHistory' since Term/ReadLine.pm is fixed. add NULL check for all sv_setpv() remove arguments 'pos' from history_search() - misc change my E-mail address 0.09 Mon Aug 25 00:33:29 1997 - add documentation about readline-2.1.tar.gz - add documentation about Solaris 2.5 with dynamic loading - bug fix fix for Digital Unix C compiler - add two sample programs eg/pftp An ftp client with the GNU Readline support eg/ptksh+ Simple perl/Tk shell which demonstrates the callback functions 0.08 Sun Apr 13 23:24:52 1997 - bug fix: AddHistory() accepts list again. - move perlsh into eg/. - add eg/ptksh+ which demonstrates the callback functions. Thank you Achim. - add eg/pftp: an ftp client which has much the GNU Readline support. - Author's Email address is changed. - internal functions, fetch_var() and store_var(), are removed. 0.07 Wed Mar 19 02:26:06 1997 - interface to internal function and variables are changed. New interface is compatible with new Term::ReadLine.pm which is distributed with Perl 5.003_92 and later. But it is not compatible with previous release. - add method interface to all internal function - add Attribs method to access internal variables - EXPORT_OK contains only some constant definitions - tkRunning support (new ReadLine.pm is required) - add document - bug fixes - XS bugs correspond to callback interface - fix _rl_store_function() and _rl_fetch_function() - fix prototype of append_history - use new _rl_store_rl_line_buffer() instead of reallocate rl_line_buffer. - etc. 0.06 Wed Feb 5 01:26:27 1997 - the first revision on CPAN - support for non ANSI C compiler - rename addhistory to AddHistory - checked by gcc -Wall - fix void_arg_func_wrapper() - add hook for rl_startup_hook in readline() - update documents 0.05 Sat Jan 25 00:06:56 1997 - Fix for Perl 5.002 and 5.003 escape from an strange Exporter's behavior remove white spaces in prototype add argument explicitly 0.04 Thu Jan 23 00:25:45 1997 - This revision supports readline-2.1 or later. readline-2.0 is not supported. - implement almost all GNU Readline/History Library variables and functions - use filehandle directly to access rl_instream and rl_outstream - define operate_and_get_next and bind to "\C-o" by default 0.03 Sun Nov 24 23:34:27 1996 - OS/2 support by Ilya Zakharevich - implement $rl_completer_word_break_characters - define HAVE_STRING_H by checking $Config{strings} - remove verbose prototypes on methods 0.02 Thu Nov 21 00:22:11 1996 - fix to install on SunOS 4.1.3, Solaris 2.3, AIX 4.1.3 0.01 Wed Nov 20 01:14:09 1996 - The 1st alpha release revision (tested on Linux 1.2.13) Term-ReadLine-Gnu-1.35/eg/0000755060175006010010000000000013006645261013761 5ustar hirooNoneTerm-ReadLine-Gnu-1.35/eg/fileman0000755060175006010010000002054112442726575015337 0ustar hirooNone#!/usr/local/bin/perl # # $Id: fileman 454 2014-03-02 14:28:30Z hayashi $ # # This is a sample program of Term::ReadLine::Gnu perl module. The # origin is a C program in the GNU Readline Libarary manual Edition # 2.1, "2.5.4 A Short Completion Example". This program is under GPL. # # Copyright (C) 1989, 1991 Free Software Foundation, Inc. # Original C version # Copyright (C) 1998 Hiroo Hayashi # Perl version # fileman.c -- A tiny application which demonstrates how to use the # GNU Readline library. This application interactively allows users # to manipulate files and their modes. use strict; use warnings; use Term::ReadLine; # A structure which contains information on the commands this program # can understand. my %commands = ('cd' => { func => \&com_cd, doc => "Change to directory DIR" }, 'delete' => { func => \&com_delete, doc => "Delete FILE" }, 'help' => { func => \&com_help, doc => "Display this text" }, '?' => { func => \&com_help, doc => "Synonym for `help'" }, 'list' => { func => \&com_list, doc => "List files in DIR" }, 'ls' => { func => \&com_list, doc => "Synonym for `list'" }, 'pwd' => { func => \&com_pwd, doc => "Print the current working directory" }, 'quit' => { func => \&com_quit, doc => "Quit using Fileman" }, 'rename' => { func => \&com_rename, doc => "Rename FILE to NEWNAME" }, 'stat' => { func => \&com_stat, doc => "Print out statistics on FILE" }, 'view' => { func => \&com_view, doc => "View the contents of FILE" }, ); # The name of this program, as taken from argv[0]. my $progname = $0; # When non-zero, this global means the user is done using this program. my $done = 0; my $term = initialize_readline(); # Bind our completer. $term->MinLine(0); ## disable implict call of add_history() # Loop reading and executing lines until the user quits. while ($done == 0) { my $line = $term->readline ("FileMan: "); last unless defined $line; # Remove leading and trailing whitespace from the line. Then, if # there is anything left, add it to the history list and execute # it. my $s = stripwhite($line); if ($s) { $term->AddHistory($s); ## normally this is done implictly execute_line($s); } } exit 0; # Execute a command line. sub execute_line { my $line = shift; my ($word, $arg) = split(' ', $line); my $command = find_command ($word); unless ($command) { printf STDERR "$word: No such command for FileMan.\n"; return (-1); } # Call the function. return (&{$command->{func}}($arg)); } # Look up NAME as the name of a command, and return a pointer to that # command. Return a NULL pointer if NAME isn't a command name. sub find_command { my $name = shift; return $commands{$name}; } # Strip whitespace from the start and end of STRING. Return a pointer # into STRING. sub stripwhite { my $string = shift; $string =~ s/^\s*//; $string =~ s/\s*$//; return $string; } #/* **************************************************************** */ #/* */ #/* Interface to Readline Completion */ #/* */ #/* **************************************************************** */ # Tell the GNU Readline library how to complete. We want to try to # complete on command names if this is the first word in the line, or # on filenames if not. sub initialize_readline { # Allow conditional parsing of the ~/.inputrc file. my $term = new Term::ReadLine 'FileMan'; # Tell the completer that we want a crack first. $term->Attribs->{attempted_completion_function} = \&fileman_completion; return $term; } # Attempt to complete on the contents of TEXT. START and END bound # the region of rl_line_buffer that contains the word to complete. # TEXT is the word to complete. We can use the entire contents of # rl_line_buffer in case we want to do some simple parsing. Return # the array of matches, or NULL if there aren't any. sub fileman_completion { my ($text, $line, $start, $end) = @_; my @matches = (); # If this word is at the start of the line, then it is a command # to complete. Otherwise it is the name of a file in the current # directory. @matches = $term->completion_matches ($text, \&command_generator) if ($start == 0); return @matches; } # Generator function for command completion. STATE lets us know # whether to start from scratch; without any state (i.e. STATE == 0), # then we start at the top of the list. ## Term::ReadLine::Gnu has list_completion_function similar with this ## function. I defined new one to be compared with original C version. { my $list_index; my @name; sub command_generator { my ($text, $state) = @_; # If this is a new word to complete, initialize now. This # includes saving the length of TEXT for efficiency, and # initializing the index variable to 0. unless ($state) { $list_index = 0; @name = keys(%commands); } # Return the next name which partially matches from the # command list. while ($list_index <= $#name) { $list_index++; return $name[$list_index - 1] if ($name[$list_index - 1] =~ /^$text/); } # If no names matched, then return NULL. return undef; } } #/* **************************************************************** */ #/* */ #/* FileMan Commands */ #/* */ #/* **************************************************************** */ # List the file(s) named in arg. sub com_list { my $arg = shift; no warnings 'uninitialized'; return (system ("ls -FClg $arg")); } sub com_view { my $arg = shift; return 1 unless (valid_argument ("view", $arg)); return (system "more $arg"); } sub com_rename { too_dangerous ("rename"); return (1); } sub com_stat { my $arg = shift; return (1) unless valid_argument ("stat", $arg); my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks); unless (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($arg)) { print STDERR "$arg: $!\n"; return (1); } printf("Statistics for \`$arg\':\n"); printf("%s has %d link%s, and is %d byte%s in length.\n", $arg, $nlink, ($nlink == 1) ? "" : "s", $size, ($size == 1) ? "" : "s"); printf("Inode Last Change at: %s\n", scalar localtime ($ctime)); printf(" Last access at: %s\n", scalar localtime ($atime)); printf(" Last modified at: %s\n", scalar localtime ($mtime)); return (0); } sub com_delete { too_dangerous("delete"); return (1); } # Print out help for ARG, or for all of the commands if ARG is not # present. sub com_help { my $arg = shift; my $printed = 0; if (defined $arg && $commands{$arg}) { printf ("%s\t\t%s.\n", $arg, $commands{$arg}->{doc}); $printed++; } unless ($printed) { defined $arg && print "No commands match \`$arg\'. Possibilties are:\n"; foreach (sort keys(%commands)) { # Print in six columns. if ($printed == 6) { $printed = 0; print "\n"; } print "$_\t"; $printed++; } print "\n" if ($printed); } return (0); } # Change to the directory ARG. sub com_cd { my $arg = shift; unless (chdir ($arg)) { print STDERR "$arg: $!\n"; return 1; } com_pwd(); return (0); } # Print out the current working directory. sub com_pwd { my $dir = $ENV{PWD} || `pwd`; unless ($dir) { print ("Error getting pwd: $dir\n"); return 1; } print ("Current directory is $dir\n"); return 0; } # The user wishes to quit using this program. Just set DONE non-zero. sub com_quit { $done = 1; 0; } # Function which tells you that you can't do this. sub too_dangerous { my $caller = shift; printf STDERR ("%s: Too dangerous for me to distribute. Write it yourself.\n", $caller); } # Return non-zero if ARG is a valid argument for CALLER, else print an # error message and return zero. sub valid_argument { my ($caller, $arg) = @_; if (! $arg) { printf STDERR ("%s: Argument required.\n", $caller); return (0); } return (1); } Term-ReadLine-Gnu-1.35/eg/perlsh0000755060175006010010000002751312442730102015204 0ustar hirooNone#! /usr/local/bin/perl # # $Id: perlsh 475 2014-12-13 03:20:00Z hayashi $ # # Copyright (c) 1996 Hiroo Hayashi. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. =head1 NAME perlsh - one-line perl evaluator with line editing function and variable name completion function =head1 SYNOPSIS perlsh =head1 DESCRIPTION This program reads input a line, and evaluates it by perl interpreter, and prints the result. If the result is a list value then each value of the list is printed line by line. This program can be used as a very strong calculator which has whole perl functions. This is a sample program Term::ReadLine::Gnu module. When you input a line, the line editing function of GNU Readline Library is available. Perl symbol name completion function is also available. =cut package PerlSh; use strict; use warnings; use Term::ReadLine; use POSIX; # for sigaction below use vars qw($PS1 $PS2 $HISTFILE $HISTSIZE $INPUTRC $STRICT $HOSTNAME $LOGNAME $CWP); #$PS1 = '$ '; $PS1='\w[\!]$ '; $PS2 = '> '; $HISTFILE = ($ENV{HOME} || ((getpwuid($<))[7])) . "/.perlsh_history"; $HISTSIZE = 256; $INPUTRC = ($ENV{HOME} || ((getpwuid($<))[7])) . "/.perlshrc"; $STRICT = 0; $HOSTNAME = $ENV{HOSTNAME}; $LOGNAME = $ENV{LOGNAME}; $CWP = 'main'; # current working package package main; if (-f $PerlSh::INPUTRC) { do $PerlSh::INPUTRC; } package PerlSh; use vars qw($term $attribs); # to access as `$PerlSh::term' from prompt $term = new Term::ReadLine 'PerlSh'; $attribs = $term->Attribs; $term->bind_key(ord "^", 'history-expand-line', 'emacs-meta'); $term->bind_key(ord "\cv", 'display-readline-version', 'emacs-ctlx'); $term->bind_key(ord "\cc", 'abort'); # not works yet FIXME!!! if (defined &main::afterinit) { package main; &afterinit; package PerlSh; } &toplevel; # never returns ######################################################################## sub toplevel { # disable implicit add_history() call $term->MinLine(undef); $term->stifle_history($HISTSIZE); if (-f $HISTFILE) { $term->ReadHistory($HISTFILE) or warn "perlsh: cannot read history file: $!\n"; } $attribs->{attempted_completion_function} = \&attempt_perl_completion; $attribs->{special_prefixes} = '$@%&'; $attribs->{completion_display_matches_hook} = \&perl_symbol_display_match_list; # See http://perldoc.perl.org/perlipc.html#Deferred-Signals-%28Safe-Signals%29 # was '$SIG{INT} = sub { ...' sigaction SIGINT, new POSIX::SigAction sub { $term->modifying; $term->delete_text; $attribs->{point} = $attribs->{end} = 0; $term->redisplay; } or die "Error setting SIGINT handler: $!\n"; my ($strict, $command, @result); $strict = $STRICT ? '' : 'no strict;'; while (defined($command = &reader)) { @result = eval ("$strict package $CWP; $command"); use strict; if ($@) { print "Error: $@\n"; next; } printer (@result); $CWP = $1 if ($command =~ /^\s*package\s+([\w:]+)/); } &quit; } sub sigint { $term->modifying; $term->delete_text; $attribs->{point} = $attribs->{end} = 0; $term->redisplay; } sub quit { $term->WriteHistory($HISTFILE) or warn "perlsh: cannot write history file: $!\n"; exit (0); } sub reader { my ($line, $command); $command = ''; while (1) { $line = $term->readline($command ? $PS2 : prompt($PS1)); return undef unless (defined $line); if ($line =~ /\\$/) { chop $line; $command = $command ? $command . " $line" : $line; } else { $command = $command ? $command . " $line" : $line; $term->addhistory($command) if (length($command) > 0); return $command; } } } sub printer { my (@res) = @_; my ($i); foreach $i (@res) { print "$i\n"; } } sub prompt { local($_) = @_; # if reference to a subroutine return the return value of it return &$_ if (ref($_) eq 'CODE'); # \h: hostname, \u: username, \w: package name, \!: history number s/\\h/$HOSTNAME/g; s/\\u/$LOGNAME/g; s/\\w/$CWP/g; s/\\!/$attribs->{history_base} + $attribs->{history_length}/eg; $_; } # # custom completion for Perl # sub perl_symbol_display_match_list ($$$) { my($matches, $num_matches, $max_length) = @_; map { $_ =~ s/^((\$#|[\@\$%&])?).*::(.+)/$3/; }(@{$matches}); $term->display_match_list($matches); $term->forced_update_display; } sub attempt_perl_completion ($$$$) { my ($text, $line, $start, $end) = @_; no strict qw(refs); if (substr($line, 0, $start) =~ m/\$([\w:]+)\s*(->)?\s*{\s*['"]?$/) { # $foo{key, $foo->{key $attribs->{completion_append_character} = '}'; return $term->completion_matches($text, \&perl_hash_key_completion_function); } elsif (substr($line, 0, $start) =~ m/\$([\w:]+)\s*->\s*['"]?$/) { # $foo->method $attribs->{completion_append_character} = ' '; return $term->completion_matches($text, \&perl_method_completion_function); } else { # Perl symbol completion $attribs->{completion_append_character} = ''; return $term->completion_matches($text, \&perl_symbol_completion_function); } } # static global variables for completion functions use vars qw($i @matches); sub perl_hash_key_completion_function ($$) { my($text, $state) = @_; if ($state) { $i++; } else { # the first call $i = 0; # clear index my ($var,$arrow) = (substr($attribs->{line_buffer}, 0, $attribs->{point} - length($text)) =~ m/\$([\w:]+)\s*(->)?\s*{\s*['"]?$/); # }); no strict qw(refs); $var = "${CWP}::$var" unless ($var =~ m/::/); if ($arrow) { my $hashref = eval "\$$var"; @matches = keys %$hashref; } else { @matches = keys %$var; } } for (; $i <= $#matches; $i++) { return $matches[$i] if ($matches[$i] =~ /^\Q$text/); } return undef; } sub _search_ISA ($) { my ($mypkg) = @_; no strict 'refs'; no warnings 'prototype'; my $isa = "${mypkg}::ISA"; return $mypkg, map _search_ISA($_), @$isa; } sub perl_method_completion_function ($$) { my($text, $state) = @_; if ($state) { $i++; } else { # the first call my ($var, $pkg, $sym, $pk); $i = 0; # clear index $var = (substr($attribs->{line_buffer}, 0, $attribs->{point} - length($text)) =~ m/\$([\w:]+)\s*->\s*$/)[0]; $pkg = ref eval (($var =~ m/::/) ? "\$$var" : "\$${CWP}::$var"); no strict qw(refs); @matches = map { $pk = $_ . '::'; grep (/^\w+$/ && ($sym = "${pk}$_", defined *$sym{CODE}), keys %$pk); } _search_ISA($pkg); } for (; $i <= $#matches; $i++) { return $matches[$i] if ($matches[$i] =~ /^\Q$text/); } return undef; } # # Perl symbol name completion # { my ($prefix, %type, @keyword); sub perl_symbol_completion_function ($$) { my($text, $state) = @_; if ($state) { $i++; } else { # the first call my ($pre, $pkg, $sym); $i = 0; # clear index no strict qw(refs); ($prefix, $pre, $pkg) = ($text =~ m/^((\$#|[\@\$%&])?(.*::)?)/); @matches = grep /::$/, $pkg ? keys %$pkg : keys %::; $pkg = ($CWP eq 'main' ? '::' : $CWP . '::') unless $pkg; if ($pre) { # $foo, @foo, $#foo, %foo, &foo @matches = (@matches, grep (/^\w+$/ && ($sym = $pkg . $_, defined *$sym{$type{$pre}}), keys %$pkg)); } else { # foo @matches = (@matches, !$prefix && @keyword, grep (/^\w+$/ && ($sym = $pkg . $_, defined *$sym{CODE} || defined *$sym{IO} ), keys %$pkg)); } } my $entry; for (; $i <= $#matches; $i++) { $entry = $prefix . $matches[$i]; return $entry if ($entry =~ /^\Q$text/); } return undef; } BEGIN { %type = ('$' => 'SCALAR', '*' => 'SCALAR', '@' => 'ARRAY', '$#' => 'ARRAY', '%' => 'HASH', '&' => 'CODE'); # ' # from perl5.004_02 perlfunc @keyword = qw( chomp chop chr crypt hex index lc lcfirst length oct ord pack q qq reverse rindex sprintf substr tr uc ucfirst y m pos quotemeta s split study qr abs atan2 cos exp hex int log oct rand sin sqrt srand pop push shift splice unshift grep join map qw reverse sort unpack delete each exists keys values binmode close closedir dbmclose dbmopen die eof fileno flock format getc print printf read readdir rewinddir seek seekdir select syscall sysread sysseek syswrite tell telldir truncate warn write pack read syscall sysread syswrite unpack vec chdir chmod chown chroot fcntl glob ioctl link lstat mkdir open opendir readlink rename rmdir stat symlink umask unlink utime caller continue die do dump eval exit goto last next redo return sub wantarray caller import local my package use defined dump eval formline local my reset scalar undef wantarray alarm exec fork getpgrp getppid getpriority kill pipe qx setpgrp setpriority sleep system times wait waitpid do import no package require use bless dbmclose dbmopen package ref tie tied untie use accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite endgrent endhostent endnetent endpwent getgrent getgrgid getgrnam getlogin getpwent getpwnam getpwuid setgrent setpwent endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent gmtime localtime time times abs bless chomp chr exists formline glob import lc lcfirst map my no prototype qx qw readline readpipe ref sub sysopen tie tied uc ucfirst untie use dbmclose dbmopen ); } } __END__ =pod Before invoking, this program reads F<~/.perlshrc> and evaluates the content of the file. When this program is terminated, the content of the history buffer is saved in a file F<~/.perlsh_history>, and it is read at next invoking. =head1 VARIABLES You can customize the behavior of C by setting following variables in F<~/.perlshrc>; =over 4 =item C<$PerlSh::PS1> The primary prompt string. The following backslash-escaped special characters can be used. \h: host name \u: user name \w: package name \!: history number The default value is `C<\w[\!]$ >'. =item C<$PerlSh::PS2> The secondary prompt string. The default value is `C >'. =item C<$PerlSh::HISTFILE> The name of the file to which the command history is saved. The default value is C<~/.perlsh_history>. =item C<$PerlSh::HISTSIZE> If not C, this is the maximum number of commands to remember in the history. The default value is 256. =item C<$PerlSh::STRICT> If true, restrict unsafe constructs. See C in perl man page. The default value is 0; =back =head1 FILES =over 4 =item F<~/.perlshrc> This file is eval-ed at initialization. If a subroutine C is defined in this file, it will be eval-ed after initialization. Here is a sample. # -*- mode: perl -*- # decimal to hexa sub h { map { sprintf("0x%x", $_ ) } @_;} sub tk { $t->tkRunning(1); use Tk; $mw = MainWindow->new(); } # for debugging Term::ReadLine::Gnu sub afterinit { *t = \$PerlSh::term; *a = \$PerlSh::attribs; } =item F<~/.perlsh_history> =item F<~/.inputrc> A initialization file for the GNU Readline Library. Refer its manual for details. =back =head1 SEE ALSO L L =head1 AUTHOR Hiroo Hayashi =cut Term-ReadLine-Gnu-1.35/eg/pftp0000755060175006010010000002442112442730102014653 0ustar hirooNone#! /usr/local/bin/perl # # $Id: pftp 475 2014-12-13 03:20:00Z hayashi $ # # Copyright (c) 1997 Hiroo Hayashi. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. =head1 NAME pftp - an ftp client with the GNU Readline support =head1 SYNOPSIS B [B<-u>] [B<-g>] [B<-M>] [B<-h>] [B<-d>] [I] =head1 DESCRIPTION This is an ftp client which has the GNU Readline support. It can complete not only local file name but also remote file name and host name to which login. This is a sample program of Perl Term::ReadLine::Gnu module. =cut use Term::ReadLine; use strict; use warnings; use Net::Domain qw(hostdomain); # libnet use Net::FTP; # libnet-1.05 or later is recommended use File::Listing; # libwww (for parse_dir) use Getopt::Std; use Cwd; # for getcwd use vars qw($AUTOLOAD $opt_d $opt_u $opt_g $opt_M $opt_h); sub usage { print STDERR <<"EOM"; usage : $0 [-d] [-i] [-u] [-g] [-M] [-h] host -d : debug mode -i : interactive mode (not implemented) -u : disable autologin -g : turn off glob -M : show manual page -h : show this message EOM exit 0; } getopts('dugMh') or &usage; &man if $opt_M; &usage if $opt_h; # # setup Term::ReadLine::GNU # my $HOSTFILE = ($ENV{HOME} || (getpwuid($<))[7]) . "/.pftp_hosts"; my $term = Term::ReadLine->new('PFTP'); my $attribs = $term->Attribs; $term->ornaments('md,me,,'); # bold face prompt # # read hostname to which login # my $host; my @hosts = read_hosts($HOSTFILE); if (@ARGV) { $host = shift; } else { $attribs->{completion_word} = \@hosts; $attribs->{completion_append_character} = ''; $attribs->{completion_entry_function} = $attribs->{'list_completion_function'}; no warnings 'uninitialized'; # in case of typing ^D $host = $term->readline('hostname> ') . ''; $host =~ s/^\s+//; $host =~ s/\s+$//; $attribs->{completion_append_character} = ' '; $attribs->{completion_entry_function} = undef; } # # make ftp connection # my $ftp = Net::FTP->new($host, Debug => $opt_d); die "$0: cannot connect \`$host\'\n" unless $ftp; print STDERR $ftp->message; write_hosts($HOSTFILE, $host, @hosts); # # login # my $login = 'anonymous'; my $password = (getpwuid($<))[0] . '@' . hostdomain; if ($opt_u) { $login = $term->readline('login name> ', $login); # mask typed characters for password $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; $password = $term->readline('password> ', $password); undef $attribs->{redisplay_function}; } $ftp->login($login, $password) or die "$0: cannot login: " . $ftp->message; print STDERR $ftp->message; $ftp->binary; # default binary print STDERR $ftp->message; my $pwd = $ftp->pwd; print STDERR $ftp->message; # # setup completion function # my @ftp_cmd_list = qw(cwd cd pwd ls dir get mget put mput lcd help); # completion_display_match_hook is supported by GNU Readline Library # 4.0 and later. Earlier versions ignore it. $attribs->{attempted_completion_function} = sub { my ($text, $line, $start, $end) = @_; if (substr($line, 0, $start) =~ /^\s*$/) { $attribs->{completion_word} = \@ftp_cmd_list; undef $attribs->{completion_display_matches_hook}; return $term->completion_matches($text, $attribs->{'list_completion_function'}); } elsif ($line =~ /^\s*(ls|dir|get|mget)\s/) { $attribs->{completion_display_matches_hook} = \&ftp_display_match_list; return $term->completion_matches($text, \&ftp_filename_completion_function); } elsif ($line =~ /^\s*(cd|cwd)\s/) { $attribs->{completion_display_matches_hook} = \&ftp_display_match_list; return $term->completion_matches($text, \&ftp_dirname_completion_function); } else { # put mput lcd undef $attribs->{completion_display_matches_hook}; return (); # local file name completion } }; # # Command loop # $SIG{INT} = 'IGNORE'; # ignore Control-C while (defined($_ = $term->readline("$login\@$host:$pwd> "))) { no strict 'refs'; next if /^\s*$/; my ($cmd, @args) = $term->history_tokenize($_); if ($cmd eq 'quit' || $cmd eq 'bye') { last; } my $func = "cmd_" . $cmd; &$func(@args); $attribs->{completion_append_character} = ' '; } $ftp->quit; print STDERR $ftp->message; exit (0); ######################################################################## # # complete remote filename # sub ftp_filename_completion_function ( $$ ) { my($text, $state) = @_; ftp_completion_function($text, $state, 0); } sub ftp_dirname_completion_function ( $$ ) { my($text, $state) = @_; ftp_completion_function($text, $state, 1); } { my ($i, $file, $dir, $fdir, $cw); sub ftp_completion_function ( $$$ ) { my($text, $state, $dironly) = @_; my $entry; unless ($state) { $i = 0; # clear counter at the first call ($dir, $file) = ($text =~ m|(.*/)?(.*)$|); $dir = '' unless defined $dir; # to piecify -w $fdir = ($dir =~ m|^/|) ? $dir : "$pwd/$dir"; # full path name $fdir =~ s|//|/|g; $attribs->{completion_append_character} = ' '; return undef unless defined ($cw = rdir($fdir)); } else { $i++; } for (; $i <= $#{$cw}; $i++) { if (($entry = $cw->[$i]) =~ /^$file/ && !($dironly && ($entry !~ m|/$|))) { $attribs->{completion_append_character} = '' if $entry =~ m|/$|; return ($dir . $entry); } } return undef; } } sub ftp_display_match_list { my($matches, $num_matches, $max_length) = @_; map { $_ =~ s|.*/([^/])|$1|; }(@{$matches}); $term->display_match_list($matches); $term->forced_update_display; } ######################################################################## sub AUTOLOAD { # tell a lie to Domain.pm goto &SYS_gethostname if $AUTOLOAD =~/SYS_gethostname$/; $AUTOLOAD =~ s/.*::cmd_//; warn "command \`$AUTOLOAD\' is not defined or not implemented.\n"; } my %rdir; sub rdir { # get remote dir info and save it in %rdir my $dir = shift; return $rdir{$dir} if defined $rdir{$dir}; my $d = $ftp->ls('-F', $dir); if ($d) { foreach (@{$d}) { s|.*/(.)|$1|; # remove directory name s/[*@]$//; } return $rdir{$dir} = $d; } else { return undef; } } sub cmd_cwd { if ($ftp->cwd(@_)) { $pwd = $ftp->pwd(); } else { print STDERR "cwd: cannot chdir to \`$_\'\n" } print STDERR $ftp->message; } # Why this does not work? #*cmd_cd = \&cmd_cwd; sub cmd_cd { &cmd_cwd; } sub cmd_pwd { $pwd = $ftp->pwd(); if ($pwd) { #print STDERR "$pwd\n"; } else { print STDERR "pwd failed.\n"; } print STDERR $ftp->message; } sub cmd_ls { # strip ls option return &cmd_dir if defined $_[0] && $_[0] =~ /^-/ && shift =~ /l/; my $dir = shift || $pwd; my $d = rdir($dir); if (defined $d) { dump_list($d); } else { print STDERR "ls failed\n"; } print STDERR $ftp->message; } # from bash-2.0/lib/readline/complete.c:display_matches() # bash-4.0 and later has rl_display_match_list. Ignore it for compativility. sub dump_list { use integer; my @list = sort @{$_[0]}; my ($len, $max, $limit, $count, $i, $j, $l, $tmp); my $screenwidth = $ENV{COLUMNS} || 80; $max = 0; foreach (@list) { $len = length; $max = $len if $len > $max; } $max += 2; $limit = $screenwidth / $max; $limit-- if ($limit != 1 && ($limit * $max == $screenwidth)); $limit = 1 if $limit == 0; $count = (@list + ($limit - 1))/ $limit; for $i (0..$count - 1) { $l = $i; for $j (0..$limit - 1) { $tmp = $list[$l]; last if $l > @list || ! $tmp; print $tmp; print ' ' x ($max - length $tmp) if $j + 1 < $limit; $l += $count; } print "\n"; } } sub cmd_dir { # strip ls option shift if defined $_[0] && $_[0] =~ /^-/; my $dir = $ftp->dir('-F', @_); print STDERR $ftp->message; my @dir; if ($dir) { foreach (@{$dir}) { print STDERR "$_\n"; my $info = (parse_dir($_, '+0000'))[0]; # GMT next unless $info; # ignore if parse_dir() can not phase. next if $$info[0] =~ m|^\.\.?/$|; # ignore '.' and '..' $$info[0] =~ s|.*/(.)|$1|; # remove directory name $$info[0] =~ s/[*@]$//; push(@dir, $$info[0]); } $rdir{$pwd} = \@dir; } else { print STDERR "dir failed\n"; } } sub cmd_get { $ftp->get(@_); print STDERR $ftp->message; } sub cmd_mget { if ($opt_g) { foreach (@_) { $ftp->get($_); print STDERR $ftp->message; } } else { my $d = $ftp->ls(@_); print STDERR $ftp->message; foreach (sort @{$d}) { $ftp->get($_); print STDERR $ftp->message; } } } sub cmd_put { $ftp->put(@_); print STDERR $ftp->message; } sub cmd_mput { my $f; foreach $f (@_) { foreach ($opt_g ? $f : glob $f) { $ftp->put($_); print STDERR $ftp->message; } } } sub cmd_lcd { my $dir = shift; no warnings 'uninitialized'; if ($dir) { chdir $dir or warn "cannot chdir to $dir: $!\n"; } printf STDERR "local current directory is \`%s\'\n", getcwd(); } sub cmd_help { print STDERR "@ftp_cmd_list\n"; } ################################################################ sub read_hosts { my $file = shift; return () unless -f $file; open(F, $file) or die "$0: cannot open file \`$file\'\n"; my @l = ; close(F); chomp @l; return @l; } sub write_hosts { my $file = shift; my $lastline = ''; open(F, ">$file") or die "$0: cannot open file \`$file\'\n"; foreach (sort @_) { print F ($_, "\n") if $_ ne $lastline; $lastline = $_; } close(F); } ################################################################ # show man page sub man { my $pager = $ENV{'PAGER'} || 'more'; exec "pod2man $0|nroff -man|$pager"; die "cannot exec pod2man, nroff, or $pager : $!\n"; } __END__ =pod =head1 OPTIONS =over 4 =item B<-u> disable autologin. =item B<-g> turn off glob. =item B<-h> show usage. =item B<-M> show thie manual. =item B<-d> debug mode. =item I remote host name. =back =head1 FILES =over 4 =item I<~/.pftp_hosts> This file contains the list of host names. These name are used for completing of remote host name. If the host name which you login is not contained in this file, it will be added automatically. =back =head1 AUTHOR Hiroo Hayashi =head1 BUGS Commands which the author does not know are not supported. =cut Term-ReadLine-Gnu-1.35/eg/ptksh+0000755060175006010010000000561212442730102015107 0ustar hirooNone#!/usr/local/bin/perl -w # # $Id: ptksh+ 475 2014-12-13 03:20:00Z hayashi $ # # POD documentation after __END__ # This program is contributed by Achim Bohnet. It demonstrates how to # use the callback functions in the GNU Readline Library. This script # is essentially equivalent with executing the following lines in # `eg/perlsh'; # $PerlSh::term->tkRunning(1); # use Tk; # $mw = MainWindow->new(); # # Hiroo Hayashi require 5.003_92; use Tk; # Bug: Require script does not work with all possibilities of # missing/existing new MainWindow and MainLoop. Therefore # I have disabled it. # Mainloop in script would be the end. No readline :-( #require shift @ARGV if (@ARGV); package Tk::RL; use Tk; use Term::ReadLine; $name = 'ptksh+'; $mw = MainWindow->new() unless ($mw = Tk::Exists 'MainWindow'); $mw->title($name); $mw->iconname($name); $mw->protocol('WM_DELETE_WINDOW' => \&quit); ##### Gnu Readline Stuff ##### my $term = new Term::ReadLine $name; my $attribs = $term->Attribs; $term->callback_handler_install("$name> ", \&doline); $mw->fileevent(STDIN,'readable', $attribs->{callback_read_char}); sub quit { $mw->fileevent(STDIN,'readable',''); $term->callback_handler_remove(); $mw->destroy; } my $outstream = $attribs->{outstream}; sub doline { my $line = shift; if (defined $line) { if ($line =~ /^p\s(.*)$/) { $line = "print $1, \"!\\n\";"; } eval "{package main; $line }"; print $outstream "$@\n" if $@; $term->add_history($line) if $line ne ""; $attribs->{line_buffer} = ''; # needed for eval errors } else { quit() unless defined $line; } } # To test if Tk is not blocked: Tk::RL::tk_active sub tk_active { print STDERR "I'm working behing the scene\n"; $mw->after(1500,\&tk_active); } #$mw->after(1500,\&tk_active); package main; # be gentle if 'required' script defined $mw; $mw = $Tk::RL::mw if not defined $mw; MainLoop; print "\n"; __END__ =head1 NAME ptksh+ - Simple perl/Tk shell that uses the Gnu Readline features =head1 SYNOPSIS % ptksh+ ptksh+> $b=$mw->Button(-text=>'hello',-command=>sub{print STDERR 'hello'}) ptksh+> $b->pack; ptksh+> ... ptksh+> ^D % =head1 DESCRIPTION This (very) simple perl/Tk shell allows you to enter perl/Tk commands interactively. Additionally it supports command line editing and keeps a history of previously entered commands. It requires C to be installed. You can exit ptksh+ with ^D or using your Window Manager 'Close' item. =head1 SEE ALSO Term::Readline, Term::Readline::Gnu, Tk, perldebug =head1 AUTHOR Achim Bohnet >, URL:L Copyright (c) 1996-1997 Achim Bohnet. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Term-ReadLine-Gnu-1.35/Gnu/0000755060175006010010000000000013006645261014117 5ustar hirooNoneTerm-ReadLine-Gnu-1.35/Gnu/XS.pm0000644060175006010010000003763313006644257015027 0ustar hirooNone# # XS.pm : perl function definition for Term::ReadLine::Gnu # # $Id: XS.pm 556 2016-11-03 14:24:45Z hayashi $ # # Copyright (c) 1999-2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package Term::ReadLine::Gnu::XS; use Carp; use strict; use warnings; use AutoLoader 'AUTOLOAD'; our $VERSION; $VERSION='1.35'; # added for CPAN # make aliases our %Attribs; *Attribs = \%Term::ReadLine::Gnu::Attribs; #use vars qw(*read_history); *read_history = \&read_history_range; # alias for 8 characters limitation imposed by AutoSplit #use vars qw(*rl_unbind_key *rl_unbind_function *rl_unbind_command # *history_list *history_arg_extract); *rl_unbind_key = \&unbind_key; *rl_unbind_function = \&unbind_function; *rl_unbind_command = \&unbind_command; *history_list = \&hist_list; *history_arg_extract = \&hist_arg_extract; # For backward compatibility. Using these name (*_in_map) is deprecated. #use vars qw(*rl_unbind_function_in_map *rl_unbind_command_in_map); *rl_unbind_function_in_map = \&unbind_function; *rl_unbind_command_in_map = \&unbind_command; rl_add_defun('history-expand-line', \&history_expand_line); # bind operate-and-get-next to \C-o by default for the compatibility # with bash and Term::ReadLine::Perl rl_add_defun('operate-and-get-next', \&operate_and_get_next, ord "\co"); rl_add_defun('display-readline-version', \&display_readline_version); rl_add_defun('change-ornaments', \&change_ornaments); # for ornaments() # Prompt-start, prompt-end, command-line-start, command-line-end # -- zero-width beautifies to emit around prompt and the command line. # string encoded: my $rl_term_set = ',,,'; # These variables are used by completion functions. Don't use for # other purpose. my $_i; my @_matches; my @_tstrs; my $_tstrs_init = 0; 1; # Uncomment the following line to enable AutoSplit. If you are using # AutoLoader.pm distributed with Perl 5.004 or earlier, you must # update AutoLoader.pm due to its bug. # 2016/06/07: now it is time to uncomment. Ignore the warning message, # "... some names are not unique ...", during make. __END__ # # Readline Library function wrappers # # Convert keymap name to Keymap if the argument is not reference to Keymap sub _str2map ($) { return ref $_[0] ? $_[0] : (rl_get_keymap_by_name($_[0]) || carp "unknown keymap name \`$_[0]\'\n"); } # Convert function name to Function if the argument is not reference # to Function sub _str2fn ($) { return ref $_[0] ? $_[0] : (rl_named_function($_[0]) || carp "unknown function name \`$_[0]\'\n"); } sub rl_copy_keymap ($) { return _rl_copy_keymap(_str2map($_[0])); } sub rl_discard_keymap ($) { return _rl_discard_keymap(_str2map($_[0])); } sub rl_set_keymap ($) { return _rl_set_keymap(_str2map($_[0])); } # rl_bind_key sub rl_bind_key ($$;$) { if (defined $_[2]) { return _rl_bind_key($_[0], _str2fn($_[1]), _str2map($_[2])); } else { return _rl_bind_key($_[0], _str2fn($_[1])); } } # rl_bind_key_if_unbound sub rl_bind_key_if_unbound ($$;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 5.0) { carp "rl_bind_key_if_unbound() is not supported. Ignored\n"; return; } if (defined $_[2]) { return _rl_bind_key_if_unbound($_[0], _str2fn($_[1]), _str2map($_[2])); } else { return _rl_bind_key_if_unbound($_[0], _str2fn($_[1])); } } # rl_unbind_key sub unbind_key ($;$) { if (defined $_[1]) { return _rl_unbind_key($_[0], _str2map($_[1])); } else { return _rl_unbind_key($_[0]); } } # rl_unbind_function sub unbind_function ($;$) { # libreadline.* in Debian GNU/Linux 2.0 tells wrong value as '2.1-bash' my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 2.2) { carp "rl_unbind_function() is not supported. Ignored\n"; return; } if (defined $_[1]) { return _rl_unbind_function($_[0], _str2map($_[1])); } else { return _rl_unbind_function($_[0]); } } # rl_unbind_command sub unbind_command ($;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 2.2) { carp "rl_unbind_command() is not supported. Ignored\n"; return; } if (defined $_[1]) { return _rl_unbind_command($_[0], _str2map($_[1])); } else { return _rl_unbind_command($_[0]); } } # rl_bind_keyseq sub rl_bind_keyseq ($$;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 5.0) { carp "rl_bind_keyseq() is not supported. Ignored\n"; return; } if (defined $_[2]) { return _rl_bind_keyseq($_[0], _str2fn($_[1]), _str2map($_[2])); } else { return _rl_bind_keyseq($_[0], _str2fn($_[1])); } } sub rl_set_key ($$;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 4.2) { carp "rl_set_key() is not supported. Ignored\n"; return; } if (defined $_[2]) { return _rl_set_key($_[0], _str2fn($_[1]), _str2map($_[2])); } else { return _rl_set_key($_[0], _str2fn($_[1])); } } # rl_bind_keyseq_if_unbound sub rl_bind_keyseq_if_unbound ($$;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 5.0) { carp "rl_bind_keyseq_if_unbound() is not supported. Ignored\n"; return; } if (defined $_[2]) { return _rl_bind_keyseq_if_unbound($_[0], _str2fn($_[1]), _str2map($_[2])); } else { return _rl_bind_keyseq_if_unbound($_[0], _str2fn($_[1])); } } sub rl_macro_bind ($$;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if (defined $_[2]) { return _rl_macro_bind($_[0], $_[1], _str2map($_[2])); } else { return _rl_macro_bind($_[0], $_[1]); } } sub rl_generic_bind ($$$;$) { if ($_[0] == Term::ReadLine::Gnu::ISFUNC) { if (defined $_[3]) { _rl_generic_bind_function($_[1], _str2fn($_[2]), _str2map($_[3])); } else { _rl_generic_bind_function($_[1], _str2fn($_[2])); } } elsif ($_[0] == Term::ReadLine::Gnu::ISKMAP) { if (defined $_[3]) { _rl_generic_bind_keymap($_[1], _str2map($_[2]), _str2map($_[3])); } else { _rl_generic_bind_keymap($_[1], _str2map($_[2])); } } elsif ($_[0] == Term::ReadLine::Gnu::ISMACR) { if (defined $_[3]) { _rl_generic_bind_macro($_[1], $_[2], _str2map($_[3])); } else { _rl_generic_bind_macro($_[1], $_[2]); } } else { carp("Term::ReadLine::Gnu::rl_generic_bind: invalid \`type\'\n"); } } sub rl_call_function ($;$$) { if (defined $_[2]) { return _rl_call_function(_str2fn($_[0]), $_[1], $_[2]); } elsif (defined $_[1]) { return _rl_call_function(_str2fn($_[0]), $_[1]); } else { return _rl_call_function(_str2fn($_[0])); } } sub rl_invoking_keyseqs ($;$) { if (defined $_[1]) { return _rl_invoking_keyseqs(_str2fn($_[0]), _str2map($_[1])); } else { return _rl_invoking_keyseqs(_str2fn($_[0])); } } sub rl_add_funmap_entry ($$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 4.2) { carp "rl_add_funmap_entry() is not supported. Ignored\n"; return; } return _rl_add_funmap_entry($_[0], _str2fn($_[1])); } sub rl_tty_set_default_bindings (;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 4.2) { carp "rl_tty_set_default_bindings() is not supported. Ignored\n"; return; } if (defined $_[0]) { return _rl_tty_set_defaut_bindings(_str2map($_[1])); } else { return _rl_tty_set_defaut_bindings(); } } sub rl_tty_unset_default_bindings (;$) { my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 5.0) { carp "rl_tty_unset_default_bindings() is not supported. Ignored\n"; return; } if (defined $_[0]) { return _rl_tty_unset_defaut_bindings(_str2map($_[1])); } else { return _rl_tty_unset_defaut_bindings(); } } sub rl_message { my $fmt = shift; my $line = sprintf($fmt, @_); _rl_message($line); } sub rl_completion_mode { # libreadline.* in Debian GNU/Linux 2.0 tells wrong value as '2.1-bash' my ($version) = $Attribs{library_version} =~ /(\d+\.\d+)/; if ($version < 4.3) { carp "rl_completion_mode() is not supported. Ignored\n"; return; } return _rl_completion_mode(_str2fn($_[0])); } # # for compatibility with Term::ReadLine::Perl # sub rl_filename_list { my ($text) = @_; # lcd : lowest common denominator my ($lcd, @matches) = rl_completion_matches($text, \&rl_filename_completion_function); return @matches ? @matches : $lcd; } # # History Library function wrappers # # history_list sub hist_list () { my ($i, $history_base, $history_length, @d); $history_base = $Attribs{history_base}; $history_length = $Attribs{history_length}; for ($i = $history_base; $i < $history_base + $history_length; $i++) { push(@d, history_get($i)); } @d; } # history_arg_extract sub hist_arg_extract ( ;$$$ ) { my ($line, $first, $last) = @_; $line = $_ unless defined $line; $first = 0 unless defined $first; $last = ord '$' unless defined $last; # ' $first = ord '$' if defined $first and $first eq '$'; # ' $last = ord '$' if defined $last and $last eq '$'; # ' &_history_arg_extract($line, $first, $last); } sub get_history_event ( $$;$ ) { _get_history_event($_[0], $_[1], defined $_[2] ? ord $_[2] : 0); } # # Ornaments # # This routine originates in Term::ReadLine.pm. # Debian GNU/Linux discourages users from using /etc/termcap. A # subroutine ornaments() defined in Term::ReadLine.pm uses # Term::Caps.pm which requires /etc/termcap. # This module calls termcap (or its compatible) library, which the GNU # Readline Library already uses, instead of Term::Caps.pm. # Some terminals do not support 'ue' (underline end). our %term_no_ue = ( kterm => 1 ); sub ornaments { return $rl_term_set unless @_; $rl_term_set = shift; $rl_term_set ||= ',,,'; $rl_term_set = $term_no_ue{$ENV{TERM}} ? 'us,me,,' : 'us,ue,,' if $rl_term_set eq '1'; my @ts = split /,/, $rl_term_set, 4; my @rl_term_set = map { # non-printing characters must be informed to readline my $t; ($_ and $t = tgetstr($_)) ? (Term::ReadLine::Gnu::RL_PROMPT_START_IGNORE . $t . Term::ReadLine::Gnu::RL_PROMPT_END_IGNORE) : ''; } @ts; $Attribs{term_set} = \@rl_term_set; return $rl_term_set; } # # a sample custom function # # The equivalent of the Bash shell M-^ history-expand-line editing # command. # This routine was borrowed from bash. sub history_expand_line { my ($count, $key) = @_; my ($expanded, $new_line) = history_expand($Attribs{line_buffer}); if ($expanded > 0) { rl_modifying(0, $Attribs{end}); # save undo information $Attribs{line_buffer} = $new_line; } elsif ($expanded < 0) { my $OUT = $Attribs{outstream}; print $OUT "\n$new_line\n"; rl_on_new_line(); } # $expanded == 0 : no change } # The equivalent of the Korn shell C-o operate-and-get-next-history-line # editing command. # This routine was borrowed from bash. sub operate_and_get_next { my ($count, $key) = @_; my $saved_history_line_to_use = -1; my $old_rl_startup_hook; # Accept the current line. rl_call_function('accept-line', 1, $key); # Find the current line, and find the next line to use. */ my $where = where_history(); if ((history_is_stifled() && ($Attribs{history_length} >= $Attribs{max_input_history})) || ($where >= $Attribs{history_length} - 1)) { $saved_history_line_to_use = $where; } else { $saved_history_line_to_use = $where + 1; } $old_rl_startup_hook = $Attribs{startup_hook}; $Attribs{startup_hook} = sub { if ($saved_history_line_to_use >= 0) { rl_call_function('previous-history', $Attribs{history_length} - $saved_history_line_to_use, 0); $Attribs{startup_hook} = $old_rl_startup_hook; $saved_history_line_to_use = -1; } }; } sub display_readline_version { # show version my($count, $key) = @_; # ignored in this function my $OUT = $Attribs{outstream}; print $OUT ("\nTerm::ReadLine::Gnu version: $Term::ReadLine::Gnu::VERSION"); print $OUT ("\nGNU Readline Library version: $Attribs{library_version}\n"); rl_on_new_line(); } # sample function of rl_message() sub change_ornaments { my($count, $key) = @_; # ignored in this function rl_save_prompt; rl_message("[S]tandout, [U]nderlining, [B]old, [R]everse, [V]isible bell: "); my $c = chr rl_read_key; if ($c =~ /s/i) { ornaments('so,me,,'); } elsif ($c =~ /u/i) { ornaments('us,me,,'); } elsif ($c =~ /b/i) { ornaments('md,me,,'); } elsif ($c =~ /r/i) { ornaments('mr,me,,'); } elsif ($c =~ /v/i) { ornaments('vb,,,'); } else { rl_ding; } rl_restore_prompt; rl_clear_message; } # # for tkRunning # sub Tk_getc { &Term::ReadLine::Tk::Tk_loop if $Term::ReadLine::toloop && defined &Tk::DoOneEvent; my $FILE = $Attribs{instream}; return rl_getc($FILE); } # redisplay function for secret input like password # usage: # $a->{redisplay_function} = $a->{shadow_redisplay}; # $line = $t->readline("password> "); sub shadow_redisplay { @_tstrs = _tgetstrs() unless $_tstrs_init; # remove prompt start/end mark from prompt string my $prompt = $Attribs{prompt}; my $s; $s = Term::ReadLine::Gnu::RL_PROMPT_START_IGNORE; $prompt =~ s/$s//g; $s = Term::ReadLine::Gnu::RL_PROMPT_END_IGNORE; $prompt =~ s/$s//g; my $OUT = $Attribs{outstream}; my $oldfh = select($OUT); $| = 1; select($oldfh); print $OUT ($_tstrs[0], # carriage return $_tstrs[1], # clear to EOL $prompt, '*' x length($Attribs{line_buffer})); print $OUT ($_tstrs[2] # cursor left x (length($Attribs{line_buffer}) - $Attribs{point})); $oldfh = select($OUT); $| = 0; select($oldfh); } sub _tgetstrs { my @s = (tgetstr('cr'), # carriage return tgetstr('ce'), # clear to EOL tgetstr('le')); # cursor left warn <<"EOM" unless (defined($s[0]) && defined($s[1]) && defined($s[2])); Your terminal 'TERM=$ENV{TERM}' does not support enough function. Check if your environment variable 'TERM' is set correctly. EOM # suppress warning "Use of uninitialized value in print at ..." $s[0] = $s[0] || ''; $s[1] = $s[1] || ''; $s[2] = $s[2] || ''; $_tstrs_init = 1; return @s; } # callback handler wrapper function for CallbackHandlerInstall method sub _ch_wrapper { my $line = shift; if (defined $line) { if ($Attribs{do_expand}) { my $result; ($result, $line) = history_expand($line); my $outstream = $Attribs{outstream}; print $outstream "$line\n" if ($result); # return without adding line into history if ($result < 0 || $result == 2) { return ''; # don't return `undef' which means EOF. } } # add to history buffer add_history($line) if ($Attribs{MinLength} > 0 && length($line) >= $Attribs{MinLength}); } &{$Attribs{_callback_handler}}($line); } # # List Completion Function # sub list_completion_function ( $$ ) { my($text, $state) = @_; $_i = $state ? $_i + 1 : 0; # clear counter at the first call my $cw = $Attribs{completion_word}; for (; $_i <= $#{$cw}; $_i++) { return $cw->[$_i] if ($cw->[$_i] =~ /^\Q$text/); } return undef; } # # wrapper completion function of 'completion_function' # for compatibility with Term::ReadLine::Perl # sub _trp_completion_function ( $$ ) { my($text, $state) = @_; my $cf; if (not defined ($cf = $Attribs{completion_function})) { carp "_trp_comletion_fuction: internal error\n"; return undef; } if ($state) { $_i++; } else { # the first call $_i = 0; # clear index @_matches = &$cf($text, $Attribs{line_buffer}, $Attribs{point} - length($text)); # return here since $#_matches is 0 instead of -1 when # @_matches = undef return undef unless defined $_matches[0]; } for (; $_i <= $#_matches; $_i++) { # case insensitive match to be compatible with # Term::ReadLine::Perl. # https://rt.cpan.org/Ticket/Display.html?id=72378 return $_matches[$_i] if ($_matches[$_i] =~ /^\Q$text/i); } return undef; } 1; __END__ Term-ReadLine-Gnu-1.35/Gnu.pm0000644060175006010010000016474713006644257014504 0ustar hirooNone# # Gnu.pm --- The GNU Readline/History Library wrapper module # # $Id: Gnu.pm 556 2016-11-03 14:24:45Z hayashi $ # # Copyright (c) 1996-2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # Some of documentation strings in this file are cited from the # GNU Readline/History Library Manual. package Term::ReadLine::Gnu; =head1 NAME Term::ReadLine::Gnu - Perl extension for the GNU Readline/History Library =head1 SYNOPSIS use Term::ReadLine; # Do not "use Term::ReadLine::Gnu;" $term = new Term::ReadLine 'ProgramName'; while ( defined ($_ = $term->readline('prompt>')) ) { ... } =head1 DESCRIPTION =head2 Overview This is an implementation of L using LHistory Library|http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html>. For basic functions object oriented interface is provided. These are described in the section L and L Functions">. This package also has the interface with the almost all functions and variables which are documented in the GNU Readline/History Library Manual. They are documented in the section L Functions"> and L Variables"> briefly. For further details of the GNU Readline/History Library, see L and L. There are some C original features. They are described in the section L Specific Features"> The sample programs under F directory and test programs under F directory in L distribution|http://search.cpan.org/dist/Term-ReadLine-Gnu/> include many examples of this module. =head2 Standard Methods These are standard methods defined by L. =cut use strict; use warnings; use Carp; # use version TRG-1.22 for perl 5.7.x, or TRG-1.09 for older Perl use 5.8.1; # This module can't be loaded directly. BEGIN { if (not defined $Term::ReadLine::VERSION) { croak < [qw(RL_PROMPT_START_IGNORE RL_PROMPT_END_IGNORE)], match_type => [qw(NO_MATCH SINGLE_MATCH MULT_MATCH)], keymap_type => [qw(ISFUNC ISKMAP ISMACR)], undo_code => [qw(UNDO_DELETE UNDO_INSERT UNDO_BEGIN UNDO_END)], rl_state => [qw(RL_STATE_NONE RL_STATE_INITIALIZING RL_STATE_INITIALIZED RL_STATE_TERMPREPPED RL_STATE_READCMD RL_STATE_METANEXT RL_STATE_DISPATCHING RL_STATE_MOREINPUT RL_STATE_ISEARCH RL_STATE_NSEARCH RL_STATE_SEARCH RL_STATE_NUMERICARG RL_STATE_MACROINPUT RL_STATE_MACRODEF RL_STATE_OVERWRITE RL_STATE_COMPLETING RL_STATE_SIGHANDLER RL_STATE_UNDOING RL_STATE_INPUTPENDING RL_STATE_TTYCSAVED RL_STATE_CALLBACK RL_STATE_VIMOTION RL_STATE_MULTIKEY RL_STATE_VICMDONCE RL_STATE_CHARSEARCH RL_STATE_REDISPLAYING RL_STATE_DONE)], ); Exporter::export_ok_tags('prompt'); Exporter::export_ok_tags('match_type'); Exporter::export_ok_tags('keymap_type'); Exporter::export_ok_tags('undo_code'); Exporter::export_ok_tags('rl_state'); bootstrap Term::ReadLine::Gnu $VERSION; # DynaLoader } require Term::ReadLine::Gnu::XS; # Global Variables our($readline_version); # Each variable in the GNU Readline Library is tied to an entry of # this hash (%Attribs). By accessing the hash entry, you can read # and/or write the variable in the GNU Readline Library. See the # package definition of Term::ReadLine::Gnu::Var and following code # for further details. # Normal (non-tied) entries our %Attribs = ( MinLength => 1, do_expand => 0, completion_word => [], term_set => ['', '', '', ''], ); our %Features = ( appname => 1, minline => 1, autohistory => 1, getHistory => 1, setHistory => 1, addHistory => 1, readHistory => 1, writeHistory => 1, preput => 1, attribs => 1, newTTY => 1, tkRunning => Term::ReadLine::Stub->Features->{'tkRunning'}, ornaments => Term::ReadLine::Stub->Features->{'ornaments'}, stiflehistory => 1, ); # # GNU Readline/History Library constant definition # These are included in @EXPORT_OK. # I can define these variables in XS code to use the value defined in # readline.h, etc. But it needs some calling convention change and # will cause compatiblity problem. I hope the definition of these # constant value will not be changed. # for non-printing characters in prompt string sub RL_PROMPT_START_IGNORE { "\001"; } sub RL_PROMPT_END_IGNORE { "\002"; } # for rl_filename_quoting_function sub NO_MATCH { 0; } sub SINGLE_MATCH { 1; } sub MULT_MATCH { 2; } # for rl_generic_bind, rl_function_of_keyseq sub ISFUNC { 0; } sub ISKMAP { 1; } sub ISMACR { 2; } # for rl_add_undo sub UNDO_DELETE { 0; } sub UNDO_INSERT { 1; } sub UNDO_BEGIN { 2; } sub UNDO_END { 3; } # for rl_readline_state which was implemented since 4.2 sub RL_STATE_NONE { 0x00000; } # no state; before first call sub RL_STATE_INITIALIZING { 0x00001; } # initializing sub RL_STATE_INITIALIZED { 0x00002; } # initialization done sub RL_STATE_TERMPREPPED { 0x00004; } # terminal is prepped sub RL_STATE_READCMD { 0x00008; } # reading a command key sub RL_STATE_METANEXT { 0x00010; } # reading input after ESC sub RL_STATE_DISPATCHING { 0x00020; } # dispatching to a command sub RL_STATE_MOREINPUT { 0x00040; } # reading more input in a command function sub RL_STATE_ISEARCH { 0x00080; } # doing incremental search sub RL_STATE_NSEARCH { 0x00100; } # doing non-inc search sub RL_STATE_SEARCH { 0x00200; } # doing a history search sub RL_STATE_NUMERICARG { 0x00400; } # reading numeric argument sub RL_STATE_MACROINPUT { 0x00800; } # getting input from a macro sub RL_STATE_MACRODEF { 0x01000; } # defining keyboard macro sub RL_STATE_OVERWRITE { 0x02000; } # overwrite mode sub RL_STATE_COMPLETING { 0x04000; } # doing completion sub RL_STATE_SIGHANDLER { 0x08000; } # in readline sighandler sub RL_STATE_UNDOING { 0x10000; } # doing an undo sub RL_STATE_INPUTPENDING { 0x02_0000; } # rl_execute_next called sub RL_STATE_TTYCSAVED { 0x04_0000; } # tty special chars saved [5.0] sub RL_STATE_CALLBACK { 0x08_0000; } # using the callback interface [5.1] sub RL_STATE_VIMOTION { 0x10_0000; } # reading vi motion arg [5.1] sub RL_STATE_MULTIKEY { 0x20_0000; } # reading multiple-key command [5.1] sub RL_STATE_VICMDONCE { 0x40_0000; } # entered vi command mode at least once [5.1] sub RL_STATE_CHARSEARCH { 0x80_0000; } # vi mode char search [7.0] sub RL_STATE_REDISPLAYING { # updating terminal display [6.1] $readline_version < 0x0700 ? 0x80_0000 : 0x100_0000; } sub RL_STATE_DONE { # done; accepted line $readline_version < 0x0501 ? 0x8_0000 : ($readline_version < 0x0601 ? 0x80_0000 : ($readline_version < 0x0700 ? 0x100_0000 : 0x200_0000)); } # # Methods Definition # =over 4 =item C returns the actual package that executes the commands. If this package is being used, C is returned. =cut sub ReadLine { 'Term::ReadLine::Gnu'; } =item C returns the handle for subsequent calls to following functions. Argument is the name of the application. Optionally can be followed by two arguments for C and C file handles. These arguments should be globs. =cut # The origin of this function is Term::ReadLine::Perl.pm by Ilya Zakharevich. sub new { my $this = shift; # Package my $class = ref($this) || $this; my $name = shift; my $self = \%Attribs; bless $self, $class; # set rl_readline_name before .inputrc is read in rl_initialize() $Attribs{readline_name} = $name; # some version of Perl cause segmentation fault, if XS module # calls setenv() before the 1st assignment to $ENV{}. $ENV{_TRL_DUMMY} = ''; # UTF-8 condition conpatible with Term:ReadLine $Attribs{utf8_mode} ||= ${^UNICODE} & 1 || defined ${^ENCODING}; #printf "\${^UNICODE}: 0x%X, ", ${^UNICODE}; #print "\${^ENCODING}: ", defined ${^ENCODING} ? 'defined' : 'undef', "\n"; # set tty before calling rl_initialize() not to output some # charactores to STDIO. # https://rt.cpan.org/Ticket/Display.html?id=96569 if (!@_) { my ($in, $out) = $self->findConsole(); open(my $IN,"<$in") || croak "Cannot open $in for read"; open(my $OUT,">$out") || croak "Cannot open $out for write"; if ($Attribs{utf8_mode}) { binmode $IN, ':encoding(UTF-8)'; # not necessary binmode $OUT, ':encoding(UTF-8)'; } $self->newTTY($IN, $OUT); } else { # enable UTF-8 mode if input stream has the utf8 layer. my @layers = PerlIO::get_layers($_[0]); $Attribs{utf8_mode} ||= ($layers[$#layers] eq 'utf8'); $self->newTTY(@_); } # initialize the GNU Readline Library and termcap library # This calls tgetent(). $self->initialize(); # enable ornaments to be compatible with perl5.004_05(?) # This calls tgetstr(). $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/); # keep rl_readline_version value for efficiency $readline_version = $Attribs{readline_version}; $self; } sub DESTROY {} =item C gets an input line, with actual C support. Trailing newline is removed. Returns C on C. C is an optional argument meaning the initial value of input. The optional argument C is granted only if the value C is in C. C may include some escape sequences. Use C to begin a sequence of non-printing characters, and C to end the sequence. =cut # to peacify -w $Term::ReadLine::registered = $Term::ReadLine::registered; sub readline { # should be ReadLine my $self = shift; my ($prompt, $preput) = @_; # A contributed fix for Perl debugger # make sure the outstream fd inside the readline library is # in sync (see http://bugs.debian.org/236018) # This is not a real fix but left for system where this fix works. # Here is the real fix for perl5db.pl. # https://rt.perl.org/Public/Bug/Display.html?id=121456 $Attribs{outstream} = $Attribs{outstream}; # ornament support (now prompt only) $prompt = ${$Attribs{term_set}}[0] . $prompt . ${$Attribs{term_set}}[1]; # `completion_function' support for compatibility with # Term:ReadLine::Perl. Prefer $completion_entry_function, since a # program which uses $completion_entry_function should know # Term::ReadLine::Gnu and have better completion function using # the variable. $Attribs{completion_entry_function} = $Attribs{_trp_completion_function} if (!defined $Attribs{completion_entry_function} && defined $Attribs{completion_function}); # TkRunning support if (not $Term::ReadLine::registered and $Term::ReadLine::toloop and defined &Tk::DoOneEvent) { $self->register_Tk; $Attribs{getc_function} = $Attribs{Tk_getc}; } # call readline() my $line; if (defined $preput) { my $saved_startup_hook = $Attribs{startup_hook}; $Attribs{startup_hook} = sub { $self->rl_insert_text($preput); &$saved_startup_hook if defined $saved_startup_hook; }; $line = $self->rl_readline($prompt); $Attribs{startup_hook} = $saved_startup_hook; } else { $line = $self->rl_readline($prompt); } return undef unless defined $line; # history expansion if ($Attribs{do_expand}) { my $result; ($result, $line) = $self->history_expand($line); my $outstream = $Attribs{outstream}; print $outstream "$line\n" if ($result); # return without adding line into history if ($result < 0 || $result == 2) { return ''; # don't return `undef' which means EOF. } } # add to history buffer $self->add_history($line) if (defined $self->{MinLength} && $self->{MinLength} > 0 && length($line) >= $self->{MinLength}); return $line; } =item C adds the lines to the history of input, from where it can be used if the actual C is present. =cut #use vars '*addhistory'; *addhistory = \&AddHistory; # for backward compatibility sub AddHistory { my $self = shift; foreach (@_) { $self->add_history($_); } } =item C, C return the file handles for input and output or C if C input and output cannot be used for Perl. =cut sub IN { $Attribs{instream}; } sub OUT { $Attribs{outstream}; } =item C If argument C is specified, it is an advice on minimal size of line to be included into history. C means do not include anything into history. Returns the old value. =cut sub MinLine { my $self = shift; my $old_minlength = $self->{MinLength}; $self->{MinLength} = shift; $old_minlength; } =item C returns an array with two strings that give most appropriate names for files for input and output using conventions C<"E$in">, C<"E$out">. =cut # findConsole is defined in ReadLine.pm. =item C returns a reference to a hash which describes internal configuration (variables) of the package. Names of keys in this hash conform to standard conventions with the leading C stripped. See section L Variables"> for supported variables. =cut sub Attribs { \%Attribs; } =item C Returns a reference to a hash with keys being features present in current implementation. Several optional features are used in the minimal interface: C should be present if the first argument to C is recognized, and C should be present if C method is not dummy. C should be present if lines are put into history automatically (maybe subject to C), and C if C method is not dummy. C means the second argument to C method is processed. C and C denote that the corresponding methods are present. C denotes that a Tk application may run while ReadLine is getting input. =cut sub Features { \%Features; } =item C makes Tk event loop run when waiting for user input (i.e., during C method). =cut # tkRunning is defined in ReadLine.pm. =item C See the description of C on L. =item C makes the command line stand out by using termcap data. The argument to C should be 0, 1, or a string of a form C<"aa,bb,cc,dd">. Four components of this string should be names of I, first two will be issued to make the prompt standout, last two to make the input line standout. =cut sub ornaments { my $self = shift; return Term::ReadLine::Gnu::XS::ornaments(@_); } =item C takes two arguments which are input filehandle and output filehandle. Switches to use these filehandles. =cut # used by a program (ex. perldb5.pl) who changes input/output stream. sub newTTY { my ($self, $in, $out) = @_; # borrowed from Term/ReadLine.pm my $sel = select($out); $| = 1; # for DB::OUT select($sel); $Attribs{instream} = $in; $Attribs{outstream} = $out; } =item C Enables UTF-8 support. If STDIN is in UTF-8 by the C<-C> command-line switch or C environment variable, or C file handle has C IO layer, then UTF-8 support is also enabled. In other cases you need this C method. This is an original method of C. =cut sub enableUTF8 { my $self = shift; $Attribs{utf8_mode} = 1; binmode $self->IN, ':encoding(UTF-8)'; # not necessary binmode $self->OUT, ':encoding(UTF-8)'; } =back =cut # documented later sub CallbackHandlerInstall { my $self = shift; my ($prompt, $lhandler) = @_; $Attribs{_callback_handler} = $lhandler; # ornament support (now prompt only) $prompt = ${$Attribs{term_set}}[0] . $prompt . ${$Attribs{term_set}}[1]; $Attribs{completion_entry_function} = $Attribs{_trp_completion_function} if (!defined $Attribs{completion_entry_function} && defined $Attribs{completion_function}); $self->rl_callback_handler_install($prompt, \&Term::ReadLine::Gnu::XS::_ch_wrapper); } # # Additional Supported Methods # # Documentation is after '__END__' for efficiency. # for backward compatibility #use vars qw(*AddDefun *BindKey *UnbindKey *ParseAndBind *StifleHistory); *AddDefun = \&add_defun; *BindKey = \&bind_key; *UnbindKey = \&unbind_key; *ParseAndBind = \&parse_and_bind; *StifleHistory = \&stifle_history; sub SetHistory { my $self = shift; $self->clear_history(); $self->AddHistory(@_); } sub GetHistory { my $self = shift; $self->history_list(); } sub ReadHistory { my $self = shift; ! $self->read_history_range(@_); } sub WriteHistory { my $self = shift; ! $self->write_history(@_); } # # Access Routines for GNU Readline/History Library Variables # package Term::ReadLine::Gnu::Var; use Carp; use strict; use warnings; our %_rl_vars; %_rl_vars = ( rl_line_buffer => ['S', 0], rl_prompt => ['S', 1], rl_library_version => ['S', 2], rl_terminal_name => ['S', 3], rl_readline_name => ['S', 4], rl_basic_word_break_characters => ['S', 5], rl_basic_quote_characters => ['S', 6], rl_completer_word_break_characters => ['S', 7], rl_completer_quote_characters => ['S', 8], rl_filename_quote_characters => ['S', 9], rl_special_prefixes => ['S', 10], history_no_expand_chars => ['S', 11], history_search_delimiter_chars => ['S', 12], rl_executing_macro => ['S', 13], # GRL 4.2 history_word_delimiters => ['S', 14], # GRL 4.2 rl_display_prompt => ['S', 15], # GRL 6.0 rl_executing_keyseq => ['S', 16], # GRL 6.3 rl_point => ['I', 0], rl_end => ['I', 1], rl_mark => ['I', 2], rl_done => ['I', 3], rl_pending_input => ['I', 4], rl_completion_query_items => ['I', 5], rl_completion_append_character => ['C', 6], rl_ignore_completion_duplicates => ['I', 7], rl_filename_completion_desired => ['I', 8], rl_filename_quoting_desired => ['I', 9], rl_inhibit_completion => ['I', 10], history_base => ['I', 11], history_length => ['I', 12], history_max_entries => ['I', 13], max_input_history => ['I', 13], # before GRL 4.2 history_write_timestamps => ['I', 14], # GRL 5.0 history_expansion_char => ['C', 15], history_subst_char => ['C', 16], history_comment_char => ['C', 17], history_quotes_inhibit_expansion => ['I', 18], rl_erase_empty_line => ['I', 19], # GRL 4.0 rl_catch_signals => ['I', 20], # GRL 4.0 rl_catch_sigwinch => ['I', 21], # GRL 4.0 rl_already_prompted => ['I', 22], # GRL 4.1 rl_num_chars_to_read => ['I', 23], # GRL 4.1 rl_dispatching => ['I', 24], # GRL 4.2 rl_gnu_readline_p => ['I', 25], # GRL 4.1 rl_readline_state => ['I', 26], # GRL 4.2 rl_explicit_arg => ['I', 27], # GRL 4.2 rl_numeric_arg => ['I', 28], # GRL 4.2 rl_editing_mode => ['I', 29], # GRL 4.2 rl_attempted_completion_over => ['I', 30], # GRL 4.2 rl_completion_type => ['I', 31], # GRL 4.2 rl_readline_version => ['I', 32], # GRL 4.2a rl_completion_suppress_append => ['I', 33], # GRL 4.3 rl_completion_quote_character => ['C', 34], # GRL 5.0 rl_completion_suppress_quote => ['I', 35], # GRL 5.0 rl_completion_found_quote => ['I', 36], # GRL 5.0 rl_completion_mark_symlink_dirs => ['I', 37], # GRL 4.3 rl_prefer_env_winsize => ['I', 38], # GRL 5.1 rl_sort_completion_matches => ['I', 39], # GRL 6.0 rl_completion_invoking_key => ['C', 40], # GRL 6.0 rl_executing_key => ['I', 41], # GRL 6.3 rl_key_sequence_length => ['I', 42], # GRL 6.3 rl_change_environment => ['I', 43], # GRL 6.3 rl_persistent_signal_handlers => ['I', 44], # GRL 7.0 utf8_mode => ['I', 45], # internal rl_startup_hook => ['F', 0], rl_event_hook => ['F', 1], rl_getc_function => ['F', 2], rl_redisplay_function => ['F', 3], rl_completion_entry_function => ['F', 4], rl_attempted_completion_function => ['F', 5], rl_filename_quoting_function => ['F', 6], rl_filename_dequoting_function => ['F', 7], rl_char_is_quoted_p => ['F', 8], rl_ignore_some_completions_function => ['F', 9], rl_directory_completion_hook => ['F', 10], history_inhibit_expansion_function => ['F', 11], rl_pre_input_hook => ['F', 12], # GRL 4.0 rl_completion_display_matches_hook => ['F', 13], # GRL 4.0 rl_completion_word_break_hook => ['F', 14], # GRL 5.0 rl_prep_term_function => ['F', 15], # GRL 4.2 rl_deprep_term_function => ['F', 16], # GRL 4.2 rl_directory_rewrite_hook => ['F', 17], # GRL 4.2 rl_filename_rewrite_hook => ['F', 18], # GRL 6.1 rl_signal_event_hook => ['F', 19], # GRL 6.3 rl_input_available_hook => ['F', 20], # GRL 6.3 rl_filename_stat_hook => ['F', 21], # GRL 6.3 rl_instream => ['IO', 0], rl_outstream => ['IO', 1], rl_executing_keymap => ['K', 0], rl_binding_keymap => ['K', 1], rl_last_func => ['LF', 0], ); my @stream; sub TIESCALAR { my $class = shift; my $name = shift; return bless \$name, $class; } sub FETCH { my $self = shift; confess "wrong type" unless ref $self; my $name = $$self; if (! defined $_rl_vars{$name}) { confess "Term::ReadLine::Gnu::Var::FETCH: Unknown variable name `$name'\n"; return undef ; } my ($type, $id) = @{$_rl_vars{$name}}; if ($type eq 'S') { return _rl_fetch_str($id); } elsif ($type eq 'I') { return _rl_fetch_int($id); } elsif ($type eq 'C') { return chr(_rl_fetch_int($id)); } elsif ($type eq 'F') { return _rl_fetch_function($id); } elsif ($type eq 'IO') { # STORE was called in new() before coming here return $stream[$id]; } elsif ($type eq 'K') { return _rl_fetch_keymap($id); } elsif ($type eq 'LF') { return _rl_fetch_last_func(); } else { carp "Term::ReadLine::Gnu::Var::FETCH: Illegal type `$type'\n"; return undef; } } sub STORE { my $self = shift; confess "wrong type" unless ref $self; my $name = $$self; if (! defined $_rl_vars{$name}) { confess "Term::ReadLine::Gnu::Var::STORE: Unknown variable name `$name'\n"; return undef ; } my $value = shift; my ($type, $id) = @{$_rl_vars{$name}}; if ($type eq 'S') { if ($name eq 'rl_line_buffer') { return _rl_store_rl_line_buffer($value); } else { return _rl_store_str($value, $id); } } elsif ($type eq 'I') { return _rl_store_int($value, $id); } elsif ($type eq 'C') { return chr(_rl_store_int(ord($value), $id)); } elsif ($type eq 'F') { return _rl_store_function($value, $id); } elsif ($type eq 'IO') { _rl_store_iostream($value, $id); # _rl_store_iostream() calls PerlIO_findFILE(). It pushes the # 'stdio' layer on perl 5.10 and later. We must pop the stdio # layer. # https://rt.cpan.org/Ticket/Display.html?id=59832 # But we must pop the 'stdio' layer only when utf8 layer is # included for remote debugging. # https://rt.cpan.org/Ticket/Display.html?id=110121 if ($] >= 5.010) { my @layers = PerlIO::get_layers($value); if ((grep /^utf8$/, @layers) > 0 && $layers[$#layers] eq 'stdio') { binmode($value, ":pop"); } } return $stream[$id] = $value; } elsif ($type eq 'K' || $type eq 'LF') { carp "Term::ReadLine::Gnu::Var::STORE: read only variable `$name'\n"; return undef; } else { carp "Term::ReadLine::Gnu::Var::STORE: Illegal type `$type'\n"; return undef; } } package Term::ReadLine::Gnu; use Carp; use strict; use warnings; # # set value of %Attribs # # Tie all Readline/History variables foreach (keys %Term::ReadLine::Gnu::Var::_rl_vars) { my $name; ($name = $_) =~ s/^rl_//; # strip leading `rl_' tie $Attribs{$name}, 'Term::ReadLine::Gnu::Var', $_; } # add reference to some functions { my ($name, $fname); no strict 'refs'; # allow symbolic reference map { ($name = $_) =~ s/^rl_//; # strip leading `rl_' $fname = 'Term::ReadLine::Gnu::XS::' . $_; $Attribs{$name} = \&$fname; # symbolic reference } qw(rl_getc rl_redisplay rl_callback_read_char rl_display_match_list rl_filename_completion_function rl_username_completion_function list_completion_function _trp_completion_function); # auto-splited subroutines cannot be processed in the map loop above use strict 'refs'; $Attribs{shadow_redisplay} = \&Term::ReadLine::Gnu::XS::shadow_redisplay; $Attribs{Tk_getc} = \&Term::ReadLine::Gnu::XS::Tk_getc; $Attribs{list_completion_function} = \&Term::ReadLine::Gnu::XS::list_completion_function; } package Term::ReadLine::Gnu::AU; use Carp; no strict qw(refs vars); use warnings; sub AUTOLOAD { { $AUTOLOAD =~ s/.*:://; } # preserve match data my $name; if (exists $Term::ReadLine::Gnu::XS::{"rl_$AUTOLOAD"}) { $name = "Term::ReadLine::Gnu::XS::rl_$AUTOLOAD"; } elsif (exists $Term::ReadLine::Gnu::XS::{"$AUTOLOAD"}) { $name = "Term::ReadLine::Gnu::XS::$AUTOLOAD"; } else { croak "Cannot do `$AUTOLOAD' in Term::ReadLine::Gnu"; } no warnings 'redefine'; # Why is this line necessary ??? *$AUTOLOAD = sub { shift; &$name(@_); }; goto &$AUTOLOAD; } 1; __END__ =head2 C Functions All these GNU Readline/History Library functions supported are callable via method interface and have names which conform to standard conventions with the leading C stripped. For example C function is called as C<$term-Efoo()>. The titles of the following sections are same as the titles of the corresponding sections in the "Programming with GNU Readline" section in the L. Refer them for further details. Although it is preferred to use method interface, most methods have lower level functions in C package. To use them a full qualified name is required. =head3 Basic Behavior The function C prints a prompt and then reads and returns a single line of text from the user. $_ = $term->readline('Enter a line: '); You can change key-bindings using C function. The first argument, C, is the character that you want bind. The second argument, C, is the function to call when C is pressed. The C can be a reference to a Perl function (see L) or a "named function" named by C function or commands described in the "Bindable Readline Commands" section in the L. $term->bind_key(ord "\ci, 'tab-insert'); The above example binds Control-I to the 'tab-insert' command. =head3 Custom Functions You can write new functions using Perl. The calling sequence for a command foo looks like sub foo ($count, $key) { ... } where C<$count> is the numeric argument (or 1 if defaulted) and C<$key> is the key that invoked this function. Here is an example; sub reverse_line { # reverse a whole line my($count, $key) = @_; # ignored in this sample function $t->modifying(0, $a->{end}); # save undo information $a->{line_buffer} = reverse $a->{line_buffer}; } See the "Writing a New Function" section in the L for further details. =head3 Readline Convenience Functions =head4 Naming a Function =over 4 =item C Add name to a Perl function C. If optional argument C is specified, bind it to the C. Returns reference to C. Example: # name `reverse-line' to a function reverse_line(), # and bind it to "\C-t" $term->add_defun('reverse-line', \&reverse_line, ord "\ct"); =back =head4 Selecting a Keymap =over 4 =item C Keymap rl_make_bare_keymap() =item C Keymap rl_copy_keymap(Keymap|str map) =item C Keymap rl_make_keymap() =item C Keymap rl_discard_keymap(Keymap|str map) =item C void rl_free_keymap(Keymap|str map) =item C Keymap rl_get_keymap() =item C Keymap rl_set_keymap(Keymap|str map) =item C Keymap rl_get_keymap_by_name(str name) =item C str rl_get_keymap_name(Keymap map) =back =head4 Binding Keys =over 4 =item C int rl_bind_key(int key, FunctionPtr|str function, Keymap|str map = rl_get_keymap()) Bind C to the C. C is the name added by the C method. If optional argument C is specified, binds in C. Returns non-zero in case of error. =item C int rl_bind_key_if_unbound(int key, FunctionPtr|str function, Keymap|str map = rl_get_keymap()) # GRL 5.0 =item C int rl_unbind_key(int key, Keymap|str map = rl_get_keymap()) Bind C to the null function. Returns non-zero in case of error. =item C int rl_unbind_function(FunctionPtr|str function, Keymap|str map = rl_get_keymap()) =item C int rl_unbind_command(str command, Keymap|str map = rl_get_keymap()) =item C int rl_bind_keyseq(str keyseq, FunctionPtr|str function, Keymap|str map = rl_get_keymap()) # GRL 5.0 =item C int rl_set_key(str keyseq, FunctionPtr|str function, Keymap|str map = rl_get_keymap()) # GRL 4.2 =item C int rl_bind_keyseq_if_unbound(str keyseq, FunctionPtr|str function, Keymap|str map = rl_get_keymap()) # GRL 5.0 =item C int rl_generic_bind(int type, str keyseq, FunctionPtr|Keymap|str data, Keymap|str map = rl_get_keymap()) =item C void rl_parse_and_bind(str line) Parse C as if it had been read from the F<~/.inputrc> file and perform any key bindings and variable assignments found. For further detail see L. =item C int rl_read_init_file(str filename = '~/.inputrc') =back =head4 Associating Function Names and Bindings =over 4 =item C FunctionPtr rl_named_function(str name) =item C str rl_get_function_name(FunctionPtr function) # TRG original =item C (FunctionPtr|Keymap|str data, int type) rl_function_of_keyseq(str keyseq, Keymap|str map = rl_get_keymap()) =item C (@str) rl_invoking_keyseqs(FunctionPtr|str function, Keymap|str map = rl_get_keymap()) =item C void rl_function_dumper(int readable = 0) =item C void rl_list_funmap_names() =item C (@str) rl_funmap_names() =item C int rl_add_funmap_entry(char *name, FunctionPtr|str function) =back =head4 Allowing Undoing =over 4 =item C int rl_begin_undo_group() =item C int rl_end_undo_group() =item C int rl_add_undo(int what, int start, int end, str text) =item C void rl_free_undo_list() =item C int rl_do_undo() =item C int rl_modifying(int start = 0, int end = rl_end) =back =head4 Redisplay =over 4 =item C void rl_redisplay() =item C int rl_forced_update_display() =item C int rl_on_new_line() =item C int rl_on_new_line_with_prompt() # GRL 4.1 =item C int rl_clear_visible_line() # GRL 7.0 =item C int rl_reset_line_state() =item C int rl_crlf() =item C int rl_show_char(int c) =item C int rl_message(str fmt, ...) =item C int rl_clear_message() =item C void rl_save_prompt() =item C void rl_restore_prompt() =item C int rl_expand_prompt(str prompt) =item C int rl_set_prompt(const str prompt) # GRL 4.2 =back =head4 Modifying Text =over 4 =item C int rl_insert_text(str text) =item C int rl_delete_text(int start = 0, int end = rl_end) =item C str rl_copy_text(int start = 0, int end = rl_end) =item C int rl_kill_text(int start = 0, int end = rl_end) =item C int rl_push_macro_input(str macro) =back =head4 Character Input =over 4 =item C int rl_read_key() =item C int rl_getc(FILE *STREAM) =item C int rl_stuff_char(int c) =item C int rl_execute_next(int c) =item C int rl_clear_pending_input() # GRL 4.2 =item C int rl_set_keyboard_input_timeout(int usec) # GRL 4.2 =back =head4 Terminal Management =over 4 =item C void rl_prep_terminal(int META_FLAG) =item C void rl_deprep_terminal() =item C void rl_tty_set_default_bindings([Keymap|str map = rl_get_keymap()]) # GRL 4.0 =item C void rl_tty_unset_default_bindings([Keymap|str map = rl_get_keymap()]) # GRL 5.0 =item C int rl_tty_set_echoing(int value) # GRL 7.0 =item C int rl_reset_terminal(str terminal_name = getenv($TERM)) =back =head4 Utility Functions =over 4 =item C READLINE_STATE rl_save_state() # GRL 6.0 =item C int rl_restore_state(READLINE_STATE) # GRL 6.0 =item C Not implemented since not required for Perl. int rl_free(void *mem) # GRL 6.0 =item C int rl_replace_line(str text, int clear_undo = 0) # GRL 4.3 =item C Not implemented since not required for Perl. int rl_extend_line_buffer(int len) =item C int rl_initialize() =item C int rl_ding() =item C int rl_alphabetic(int C) # GRL 4.2 =item C void rl_display_match_list(\@matches, len = $#maches, max) # GRL 4.0 Since the first element of an array C<@matches> as treated as a possible completion, it is not displayed. See the descriptions of C. When C is omitted, the max length of an item in C<@matches> is used. =back =head4 Miscellaneous Functions =over 4 =item C int rl_macro_bind(const str keyseq, const str macro, Keymap map) =item C int rl_macro_dumper(int readline) =item C int rl_variable_bind(const str variable, const str value) =item C str rl_variable_value(const str variable) # GRL 5.1 =item C int rl_variable_dumper(int readline) =item C int rl_set_paren_blink_timeout(usec) # GRL 4.2 =item C str rl_get_termcap(cap) =item C void rl_clear_history() # GRL 6.3 =back =head4 Alternate Interface =over 4 =item C void rl_callback_handler_install(str prompt, pfunc lhandler) =item C void rl_callback_read_char() =item C # GRL 7.0 void rl_callback_sigcleanup() =item C void rl_callback_handler_remove() =back =head3 Readline Signal Handling =over 4 =item C int rl_pending_signal() # GRL 7.0 =item C void rl_cleanup_after_signal() # GRL 4.0 =item C void rl_free_line_state() # GRL 4.0 =item C void rl_reset_after_signal() # GRL 4.0 =item C void rl_echo_signal_char(int sig) # GRL 6.0 =item C void rl_resize_terminal() # GRL 4.0 =item C void rl_set_screen_size(int ROWS, int COLS) # GRL 4.2 =item C (int rows, int cols) rl_get_screen_size() # GRL 4.2 =item C void rl_reset_screen_size() # GRL 5.1 =item C int rl_set_signals() # GRL 4.0 =item C int rl_clear_signals() # GRL 4.0 =back =head3 Completion Functions =over 4 =item C int rl_complete_internal(int what_to_do = TAB) =item C int rl_completion_mode(FunctionPtr|str function) # GRL 4.3 =item C (@str) rl_completion_matches(str text, pfunc func = filename_completion_function) =item C str rl_filename_completion_function(str text, int state) =item C str rl_username_completion_function(str text, int state) =item C str list_completion_function(str text, int state) # TRG original =back =head3 History Functions =head4 Initializing History and State Management =over 4 =item C void using_history() =item C HISTORY_STATE history_get_hitory_state() # GRL 6.3 =item C void history_set_hitory_state(HISTORY_STATE) # GRL 6.3 =back =head4 History List Management =over 4 =item C void add_history(str string) =item C void add_history_time(str string) # GRL 5.0 =item C str remove_history(int which) =item C Not implemented since Term::ReadLine::Gnu does not support the member 'data' of HIST_ENTRY structure. remove_history() frees the memory. histdata_t free_history_entry(HIST_ENTRY *histent) # GRL 5.0 =item C str replace_history_entry(int which, str string) =item C void clear_history() =item C int stifle_history(int max|undef) stifles the history list, remembering only the last C entries. If C is undef, remembers all entries. This is a replacement of C. =item C int unstifle_history() This is equivalent with C. =item C int history_is_stifled() =item C sets the history of input, from where it can be used if the actual C is present. =back =head4 Information About the History List =over 4 =item C Not implemented since not required for Perl. HIST_ENTRY **history_list() =item C int where_history() =item C str current_history() =item C str history_get(offset) =item C time_t history_get_time(offset) # GRL 5.0 =item C int history_total_bytes() =item C returns the history of input as a list, if actual C is present. =back =head4 Moving Around the History List =over 4 =item C int history_set_pos(int pos) =item C str previous_history() =item C str next_history() =back =head4 Searching the History List =over 4 =item C int history_search(str string, int direction = -1) =item C int history_search_prefix(str string, int direction = -1) =item C int history_search_pos(str string, int direction = -1, int pos = where_history()) =back =head4 Managing the History File =over 4 =item C int read_history(str filename = '~/.history', int from = 0, int to = -1) int read_history_range(str filename = '~/.history', int from = 0, int to = -1) adds the contents of C to the history list, a line at a time. If C is false, then read from F<~/.history>. Start reading at line C and end at C. If C is omitted or zero, start at the beginning. If C is omitted or less than C, then read until the end of the file. Returns true if successful, or false if not. C is an alias of C. =item C int write_history(str filename = '~/.history') writes the current history to C, overwriting C if necessary. If C is false, then write the history list to F<~/.history>. Returns true if successful, or false if not. =item C int append_history(int nelements, str filename = '~/.history') =item C int history_truncate_file(str filename = '~/.history', int nlines = 0) =back =head4 History Expansion =over 4 =item C (int result, str expansion) history_expand(str string) Note that this function returns C in the scalar context. =item C (str text, int cindex) = get_history_event(str string, int cindex, char qchar = '\0') =item C (@str) history_tokenize(str string) =item C str history_arg_extract(str string, int first = 0, int last = '$') =back =head2 C Variables Following GNU Readline/History Library variables can be accessed by a Perl program. See L and L for details of each variable. You can access them by using C methods. Names of keys in this hash conform to standard conventions with the leading C stripped. Examples: $attribs = $term->Attribs; $v = $attribs->{library_version}; # rl_library_version $v = $attribs->{history_base}; # history_base =head3 Readline Variables str rl_line_buffer int rl_point int rl_end int rl_mark int rl_done int rl_num_chars_to_read (GRL 4.1) int rl_pending_input int rl_dispatching int rl_erase_empty_line (GRL 4.0) str rl_prompt (read only) str rl_display_prompt int rl_already_prompted (GRL 4.1) str rl_library_version (read only) int rl_readline_version (read only) int rl_gnu_readline_p (GRL 4.1, read only) str rl_terminal_name str rl_readline_name filehandle rl_instream filehandle rl_outstream int rl_prefer_env_winsize (GRL 5.1) pfunc rl_last_func (GRL 4.2, read only) pfunc rl_startup_hook pfunc rl_pre_input_hook (GRL 4.0) pfunc rl_event_hook pfunc rl_getc_function pfunc rl_signal_event_hook (GRL 6.3) pfunc rl_input_available_hook (GRL 6.3) pfunc rl_redisplay_function pfunc rl_prep_term_function (GRL 2.1) pfunc rl_deprep_term_function (GRL 2.1) Keymap rl_executing_keymap (read only) Keymap rl_binding_keymap (read only) str rl_executing_macro (GRL 4.2, read only) int rl_executing_key (GRL 6.3, read only) str rl_executing_keyseq (GRL 6.3, read only) int rl_key_sequence_length (read only) int rl_readline_state (GRL 4.2) int rl_explicit_arg (read only) int rl_numeric_arg (read only) int rl_editing_mode (read only) =head3 Signal Handling Variables int rl_catch_signals (GRL 4.0) int rl_catch_sigwinch (GRL 4.0) int rl_persistent_signal_handlers (GRL 7.0) int rl_change_environment (GRL 6.3) =head3 Completion Variables pfunc rl_completion_entry_function pfunc rl_attempted_completion_function pfunc rl_filename_quoting_function pfunc rl_filename_dequoting_function pfunc rl_char_is_quoted_p pfunc rl_ignore_some_completions_function pfunc rl_directory_completion_hook pfunc rl_directory_rewrite_hook (GRL 4.2) pfunc rl_filename_stat_hook (GRL 6.3) pfunc rl_filename_rewrite_hook (GRL 6.1) pfunc rl_completion_display_matches_hook (GRL 4.0) str rl_basic_word_break_characters str rl_basic_quote_characters str rl_completer_word_break_characters pfunc rl_completion_word_break_hook (GRL 5.0) str rl_completer_quote_characters str rl_filename_quote_characters str rl_special_prefixes int rl_completion_query_items int rl_completion_append_character int rl_completion_suppress_append (GRL 4.3) int rl_completion_quote_character (GRL 5.0, read only) int rl_completion_suppress_quote (GRL 5.0) int rl_completion_found_quote (GRL 5.0, read only) int rl_completion_mark_symlink_dirs (GRL 4.3) int rl_ignore_completion_duplicates int rl_filename_completion_desired int rl_filename_quoting_desired int rl_attempted_completion_over int rl_sort_completion_matches (GRL 6.0) int rl_completion_type (read only) int rl_completion_invoking_key (GRL 6.0, read only) int rl_inhibit_completion =head3 History Variables int history_base int history_length int history_max_entries (called `max_input_history', read only) int history_write_timestamps (GRL 5.0) char history_expansion_char char history_subst_char char history_comment_char str history_word_delimiters (GRL 4.2) str history_search_delimiter_chars str history_no_expand_chars int history_quotes_inhibit_expansion pfunc history_inhibit_expansion_function =head3 Function References rl_getc rl_redisplay rl_callback_read_char rl_display_match_list rl_filename_completion_function rl_username_completion_function list_completion_function shadow_redisplay Tk_getc =head2 Custom Completion In this section variables and functions for custom completion are described along with examples. Most of descriptions in this section came from L. =over 4 =item C This variable holds reference refers to a generator function for C. A generator function is called repeatedly from C, returning a string each time. The arguments to the generator function are C and C. C is the partial word to be completed. C is zero the first time the function is called, allowing the generator to perform any necessary initialization, and a positive non-zero integer for each subsequent call. When the generator function returns C this signals C that there are no more possibilities left. If this variable set to undef, built-in C is used. A sample generator function, C, is defined in Gnu.pm. You can use it as follows; use Term::ReadLine; ... my $term = new Term::ReadLine 'sample'; my $attribs = $term->Attribs; ... $attribs->{completion_entry_function} = $attribs->{list_completion_function}; ... $attribs->{completion_word} = [qw(reference to a list of words which you want to use for completion)]; $term->readline("custom completion>"); See also C. =item C A reference to an alternative function to create matches. The function is called with C, C, C, and C. C is a current input buffer string. C and C are indices in C saying what the boundaries of C are. If this function exists and returns null list or C, or if this variable is set to C, then an internal function C will call the value of C to generate matches, otherwise the array of strings returned will be used. The default value of this variable is C. You can use it as follows; use Term::ReadLine; ... my $term = new Term::ReadLine 'sample'; my $attribs = $term->Attribs; ... sub sample_completion { my ($text, $line, $start, $end) = @_; # If first word then username completion, else filename completion if (substr($line, 0, $start) =~ /^\s*$/) { return $term->completion_matches($text, $attribs->{'username_completion_function'}); } else { return (); } } ... $attribs->{attempted_completion_function} = \&sample_completion; =item C Returns an array of strings which is a list of completions for C. If there are no completions, returns C. The first entry in the returned array is the substitution for C. The remaining entries are the possible completions. C is a generator function which has two arguments, and returns a string. The first argument is C. The second is a state argument; it is zero on the first call, and non-zero on subsequent calls. C returns C to the caller when there are no more matches. If the value of C is undef, built-in C is used. C is a Perl wrapper function of an internal function C. See also C. =item C A variable whose content is a reference to a function which returns a list of candidates to complete. This variable is compatible with L and very easy to use. use Term::ReadLine; ... my $term = new Term::ReadLine 'sample'; my $attribs = $term->Attribs; ... $attribs->{completion_function} = sub { my ($text, $line, $start) = @_; return qw(a list of candidates to complete); }; =item C A sample generator function defined by C. Example code at C shows how to use this function. =back =head2 C Specific Features =head3 C Specific Functions =over 4 =item C This method provides the function C with the following additional feature compatible with C method; ornament feature, L compatible completion function, history expansion, and addition to history buffer. =item C int rl_call_function(FunctionPtr|str function, count = 1, key = -1) =item C Returns a list of all function names. =item C A redisplay function for password input. You can use it as follows; $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; $line = $term->readline("password> "); =item C Returns candidates of filenames to complete. This function can be used with C and is implemented for the compatibility with L. =item C See the description of section L<"Custom Completion"|"Custom Completion">. =back =head3 C Specific Variables =over 4 =item C When true, the history expansion is enabled. By default false. =item C See the description of section L<"Custom Completion"|"Custom Completion">. =item C A reference to a list of candidates to complete for C. =back =head3 C Specific Commands =over 4 =item C The equivalent of the Bash C editing command. =item C The equivalent of the Korn shell C editing command and the Bash C. This command is bound to C<\C-o> by default for the compatibility with the Bash and L. =item C Shows the version of C and the one of the GNU Readline Library. =item C Change ornaments interactively. =back =head1 FILES =over 4 =item F<~/.inputrc> Readline init file. Using this file it is possible that you would like to use a different set of key bindings. When a program which uses the GNU Readline library starts up, the init file is read, and the key bindings are set. The conditional init constructs is supported. The program name which is specified by the first argument of C method is used as the application construct. For example, when your program calls C method as follows; ... $term = new Term::ReadLine 'PerlSh'; ... your F<~/.inputrc> can define key bindings only for the program as follows; ... $if PerlSh Meta-Rubout: backward-kill-word "\C-x\C-r": re-read-init-file "\e[11~": "Function Key 1" $endif ... For further details, see the section "Readline Init File" in the L =back =head1 EXPORTS No symbols are exported by default. The following tags are defined and their symbols can be exported. =over 4 =item prompt RL_PROMPT_START_IGNORE RL_PROMPT_END_IGNORE =item match_type NO_MATCH SINGLE_MATCH MULT_MATCH =item keymap_type ISFUNC ISKMAP ISMACR =item undo_code UNDO_DELETE UNDO_INSERT UNDO_BEGIN UNDO_END =item rl_state RL_STATE_NONE RL_STATE_INITIALIZING RL_STATE_INITIALIZED RL_STATE_TERMPREPPED RL_STATE_READCMD RL_STATE_METANEXT RL_STATE_DISPATCHING RL_STATE_MOREINPUT RL_STATE_ISEARCH RL_STATE_NSEARCH RL_STATE_SEARCH RL_STATE_NUMERICARG RL_STATE_MACROINPUT RL_STATE_MACRODEF RL_STATE_OVERWRITE RL_STATE_COMPLETING RL_STATE_SIGHANDLER RL_STATE_UNDOING RL_STATE_INPUTPENDING RL_STATE_TTYCSAVED RL_STATE_CALLBACK RL_STATE_VIMOTION RL_STATE_MULTIKEY RL_STATE_VICMDONCE RL_STATE_CHARSEARCH RL_STATE_REDISPLAYING RL_STATE_DONE =back They can be exported as follows; use Term::ReadLine; BEGIN { import Term::ReadLine::Gnu qw(:keymap_type RL_STATE_INITIALIZED); } =head1 ENVIRONMENT The environment variable C governs which ReadLine clone is loaded. See the ENVIRONMENT section on L for further details. =head1 SEE ALSO =over 4 =item L =item L =item L =item Sample and test programs (F and F) in L distribution|http://search.cpan.org/dist/Term-ReadLine-Gnu/> =item L =item Works which use Term::ReadLine::Gnu =over 4 =item Distributions which depend on Term::ReadLine::Gnu on L L =item L perl -d =item L The Perl Shell is a shell that combines the interactive nature of a Unix shell with the power of Perl. A programmable completion feature compatible with bash is implemented. =item L SPP (Synopsys Plus Perl) is a Perl module that wraps around Synopsys' shell programs. SPP is inspired by the original dc_perl written by Steve Golson, but it's an entirely new implementation. Why is it called SPP and not dc_perl? Well, SPP was written to wrap around any of Synopsys' shells. =item LLinux)|http://p-f-m.sourceforge.net/> Pfm is a terminal-based file manager written in Perl, based on PFM.COM for MS-DOS (originally by Paul Culley and Henk de Heer). =item L soundgrab is designed to help you slice up a big long raw audio file (by default 44.1 kHz 2 channel signed sixteen bit little endian) and save your favorite sections to other files. It does this by providing you with a cassette player like command line interface. =item L PDL (``Perl Data Language'') gives standard Perl the ability to compactly store and speedily manipulate the large N-dimensional data arrays which are the bread and butter of scientific computing. =item L PIQT is an interactive query tool using the Perl DBI database interface. It supports ReadLine, provides a built in scripting language with a Lisp like syntax, an online help system, and uses wrappers to interface to the DBD modules. =item L A visual shell and CLI shell supplement. =back If you know any other works you recommend, please let me know. =back =head1 AUTHOR Hiroo Hayashi Chiroo.hayashi@computer.orgE> L =head1 TODO GTK+ support in addition to Tk. =head1 BUGS =over 4 =item Submit a bug report to L. =item C can define up to 16 functions. =item Some functions and variables do not have test code yet. Your contribution is welcome. See F for details. =item If the pager command (| or ||) in Perl debugger causes segmentation fault, you need to fix F. See L for details. =back =head1 LICENSE Copyright (c) 1996-2016 Hiroo Hayashi. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Term-ReadLine-Gnu-1.35/Gnu.xs0000644060175006010010000022034613006641755014506 0ustar hirooNone/* * Gnu.xs --- GNU Readline wrapper module * * $Id: Gnu.xs 555 2016-11-03 14:04:27Z hayashi $ * * Copyright (c) 1996-2016 Hiroo Hayashi. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the same terms as Perl itself. */ #ifdef __cplusplus extern "C" { #endif #define PERLIO_NOT_STDIO 0 #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define NEED_sv_2pv_flags #include "ppport.h" #ifdef __cplusplus } #endif #include #ifdef __CYGWIN__ #include #endif /* __CYGWIN__ */ #include #include /* * Perl 5.005 requires an ANSI C Compiler. Good news. * But I should still support legacy C compilers now. */ /* Adapted from BSD /usr/include/sys/cdefs.h. */ #if defined (__STDC__) # if !defined (PARAMS) # define PARAMS(protos) protos # endif #else /* !__STDC__ */ # if !defined (PARAMS) # define PARAMS(protos) () # endif #endif /* !__STDC__ */ /* * In Readline 4.2 many variables, function arguments, and function * return values are now declared `const' where appropriate. */ #if (RL_READLINE_VERSION < 0x0402) #define CONST #else /* (RL_READLINE_VERSION >= 0x0402) */ #define CONST const #endif /* (RL_READLINE_VERSION >= 0x0402) */ typedef char * t_utf8; /* string which must not be xfreed */ typedef char * t_utf8_free; /* string which must be xfreed */ /* * utf8_mode is set in the Perl side, and it must be set before * calling sv_2mortal_utf8() */ static int utf8_mode = 0; static SV* sv_2mortal_utf8(SV *sv) { sv = sv_2mortal(sv); if (utf8_mode) sv_utf8_decode(sv); return sv; } /* * compatibility definitions */ #if (RL_READLINE_VERSION < 0x0402) typedef int rl_command_func_t PARAMS((int, int)); typedef char *rl_compentry_func_t PARAMS((const char *, int)); typedef char **rl_completion_func_t PARAMS((const char *, int, int)); typedef char *rl_quote_func_t PARAMS((char *, int, char *)); typedef char *rl_dequote_func_t PARAMS((char *, int)); typedef int rl_compignore_func_t PARAMS((char **)); typedef void rl_compdisp_func_t PARAMS((char **, int, int)); typedef int rl_hook_func_t PARAMS((void)); typedef int rl_getc_func_t PARAMS((FILE *)); typedef int rl_linebuf_func_t PARAMS((char *, int)); /* `Generic' function pointer typedefs */ typedef int rl_intfunc_t PARAMS((int)); #define rl_ivoidfunc_t rl_hook_func_t typedef int rl_icpfunc_t PARAMS((char *)); typedef int rl_icppfunc_t PARAMS((char **)); typedef void rl_voidfunc_t PARAMS((void)); typedef void rl_vintfunc_t PARAMS((int)); typedef void rl_vcpfunc_t PARAMS((char *)); typedef void rl_vcppfunc_t PARAMS((char **)); /* rl_last_func() is defined in rlprivate.h */ extern rl_command_func_t *rl_last_func; #endif /* (RL_READLINE_VERSION < 0x0402) */ #if (RL_READLINE_VERSION < 0x0500) typedef char *rl_cpvfunc_t PARAMS((void)); #endif /* (RL_READLINE_VERSION < 0x0500) */ #if (RL_READLINE_VERSION < 0x0201) /* features introduced by GNU Readline 2.1 */ static rl_vintfunc_t *rl_prep_term_function; static rl_voidfunc_t *rl_deprep_term_function; #endif /* (RL_READLINE_VERSION < 0x0201) */ #if (RL_READLINE_VERSION < 0x0202) /* features introduced by GNU Readline 2.2 */ static int rl_unbind_function_in_map (func, map) rl_command_func_t *func; Keymap map; { register int i, rval; for (i = rval = 0; i < KEYMAP_SIZE; i++) { if (map[i].type == ISFUNC && map[i].function == func) { map[i].function = (rl_command_func_t *)NULL; rval = 1; } } return rval; } static int rl_unbind_command_in_map (command, map) const char *command; Keymap map; { rl_command_func_t *func; func = rl_named_function (command); if (func == 0) return 0; return (rl_unbind_function_in_map (func, map)); } #endif /* (RL_READLINE_VERSION < 0x0202) */ #if (RL_VERSION_MAJOR < 4) /* documented by Readline 4.0 but already implemented since 2.0 or 2.1. */ extern void rl_extend_line_buffer PARAMS((int)); extern char **rl_funmap_names PARAMS((void)); extern int rl_add_funmap_entry PARAMS((CONST char *, rl_command_func_t *)); extern void rl_prep_terminal PARAMS((int)); extern void rl_deprep_terminal PARAMS((void)); extern int rl_execute_next PARAMS((int)); /* features introduced by GNU Readline 4.0 */ /* dummy variable/function definition */ static int rl_erase_empty_line = 0; static rl_hook_func_t *rl_pre_input_hook; static int rl_catch_signals = 1; static int rl_catch_sigwinch = 1; static rl_compdisp_func_t *rl_completion_display_matches_hook; static void rl_display_match_list(){} static void rl_cleanup_after_signal(){} static void rl_free_line_state(){} static void rl_reset_after_signal(){} static void rl_resize_terminal(){} /* * Before GNU Readline Library Version 4.0, rl_save_prompt() was * _rl_save_prompt and rl_restore_prompt() was _rl_restore_prompt(). */ extern void _rl_save_prompt PARAMS((void)); extern void _rl_restore_prompt PARAMS((void)); static void rl_save_prompt() { _rl_save_prompt(); } static void rl_restore_prompt() { _rl_restore_prompt(); } #endif /* (RL_VERSION_MAJOR < 4) */ #if (RL_READLINE_VERSION < 0x0401) /* features introduced by GNU Readline 4.1 */ static int rl_already_prompted = 0; static int rl_num_chars_to_read = 0; static int rl_gnu_readline_p = 1; static int rl_on_new_line_with_prompt(){ return 0; } #endif /* (RL_READLINE_VERSION < 0x0401) */ #if (RL_READLINE_VERSION < 0x0402) /* documented by 4.2 but implemented since 2.1 */ extern int rl_explicit_arg; extern int rl_numeric_arg; extern int rl_editing_mode; /* features introduced by GNU Readline 4.2 */ static int rl_set_prompt(){ return 0; } static int rl_clear_pending_input(){ return 0; } static int rl_set_keyboard_input_timeout(){ return 0; } static int rl_alphabetic(){ return 0; } static int rl_set_paren_blink_timeout(){ return 0; } static void rl_set_screen_size(int row, int col){} static void rl_get_screen_size(int *row, int *col){ *row = *col = 0; } static char *rl_executing_macro = NULL; /* was _rl_executing_macro */ static int rl_readline_state = 2; /* RL_STATE_INITIALIZED */ static rl_icppfunc_t *rl_directory_rewrite_hook = NULL; static char *history_word_delimiters = " \t\n;&()|<>"; /* documented by 4.2a but implemented since 2.1 */ extern char *rl_get_termcap PARAMS((const char *)); /* features introduced by GNU Readline 4.2a */ static int rl_readline_version = RL_READLINE_VERSION; /* Provide backwards-compatible entry points for old function names which are rename from readline-4.2. */ static void rl_free_undo_list () { free_undo_list (); } static int rl_crlf () { return crlf (); } static void rl_tty_set_default_bindings (keymap) Keymap keymap; { #if (RL_VERSION_MAJOR >= 4) rltty_set_default_bindings (keymap); #endif /* (RL_VERSION_MAJOR >= 4) */ } static int rl_ding () { return ding (); } static char ** rl_completion_matches (s, f) char *s; rl_compentry_func_t *f; { return completion_matches (s, f); } static char * rl_username_completion_function (s, i) const char *s; int i; { return username_completion_function ((char *)s, i); } static char * rl_filename_completion_function (s, i) const char *s; int i; { return filename_completion_function ((char *)s, i); } #endif /* (RL_READLINE_VERSION >= 0x0402) */ #if (RL_READLINE_VERSION < 0x0403) /* features introduced by GNU Readline 4.3 */ static int rl_completion_suppress_append = 0; static int rl_completion_mark_symlink_dirs = 0; static void rl_replace_line(){} static int rl_completion_mode(){ return 0; } /* documented by 6.0 but implemented since 4.3 */ struct readline_state { }; static int rl_save_state(struct readline_state *sp){ return 0; } static int rl_restore_state(struct readline_state *sp){ return 0; } #endif /* (RL_READLINE_VERSION < 0x0403) */ typedef struct readline_state readline_state_t; /* for typemap */ #if (RL_VERSION_MAJOR < 5) /* features introduced by GNU Readline 5.0 */ static rl_cpvfunc_t *rl_completion_word_break_hook = NULL; static int rl_completion_quote_character = 0; static int rl_completion_suppress_quote = 0; static int rl_completion_found_quote = 0; static int history_write_timestamps = 0; static int rl_bind_key_if_unbound_in_map(){ return 0; } static int rl_bind_keyseq_in_map(){ return 0; } static int rl_bind_keyseq_if_unbound_in_map(){ return 0; } static void rl_tty_unset_default_bindings(){} static void add_history_time(){} static time_t history_get_time(){ return 0; } #endif /* (RL_VERSION_MAJOR < 5) */ #if (RL_READLINE_VERSION < 0x0501) /* features introduced by GNU Readline 5.1 */ static int rl_prefer_env_winsize = 0; static t_utf8 rl_variable_value(CONST char * v){ return NULL; } static void rl_reset_screen_size(){} #endif /* (RL_READLINE_VERSION < 0x0501) */ #if (RL_VERSION_MAJOR < 6) /* documented by 6.0 but implemented since 2.1 */ extern char *rl_display_prompt; /* features introduced by GNU Readline 6.0 */ static int rl_sort_completion_matches = 1; static int rl_completion_invoking_key = 0; static void rl_echo_signal_char(int sig){} #endif /* (RL_VERSION_MAJOR < 6) */ #if (RL_READLINE_VERSION < 0x0601) /* features introduced by GNU Readline 6.1 */ static rl_dequote_func_t *rl_filename_rewrite_hook; /* Convenience function that discards, then frees, MAP. */ static void xfree(void *); static void rl_free_keymap (map) Keymap map; { rl_discard_keymap (map); xfree ((char *)map); } #endif /* (RL_READLINE_VERSION < 0x0601) */ /* No feature to be handled by this module is introduced by GNU Readline 6.2 */ #if (RL_READLINE_VERSION < 0x0603) /* documented by 6.3 but implemented since 2.1 */ extern int rl_key_sequence_length; #if (RL_READLINE_VERSION > 0x0600) /* externed by 6.3 but implemented since 6.1 */ extern void rl_free_keymap PARAMS((Keymap)); #endif /* features introduced by GNU Readline 6.3 */ static rl_hook_func_t *rl_signal_event_hook = NULL; static rl_hook_func_t *rl_input_available_hook = NULL; static int rl_executing_key = 0; static char *rl_executing_keyseq = NULL; static int rl_change_environment = 1; static rl_icppfunc_t *rl_filename_stat_hook = NULL; void rl_clear_history (void) {} /* documented by 6.3 but implemented since 2.1 static HISTORY_STATE *history_get_hitory_state(); static void *history_set_hitory_state(HISTORY_STATE *state) */ #endif /* (RL_READLINE_VERSION < 0x0603) */ #if (RL_READLINE_VERSION < 0x0700) /* features introduced by GNU Readline 7.0 */ static int rl_clear_visible_line(void) { return 0; } static int rl_tty_set_echoing(int value) { return 0; } static void rl_callback_sigcleanup (void) {} static int rl_pending_signal(void) { return 0; } static int rl_persistent_signal_handlers = 0; #endif /* (RL_READLINE_VERSION < 0x0700) */ #if (RL_READLINE_VERSION == 0x0700) /* not defined in readline.h */ extern int rl_tty_set_echoing PARAMS((int)); #endif /* (RL_READLINE_VERSION == 0x0700) */ /* * utility/dummy functions */ /* from GNU Readline:xmalloc.h */ #ifndef PTR_T #ifdef __STDC__ # define PTR_T void * #else # define PTR_T char * #endif #endif /* !PTR_T */ /* from GNU Readline:xmalloc.c */ extern PTR_T xmalloc PARAMS((int)); extern char *tgetstr PARAMS((const char *, char **)); extern int tputs PARAMS((const char *, int, int (*)(int))); /* * Using xfree() in GNU Readline Library causes problem with Solaris * 2.5. It seems that the DLL mechanism of Solaris 2.5 links another * xfree() that does not do NULL argument check. * I choose this as default since some other OSs may have same problem. * usemymalloc=n is required. */ static void xfree (string) PTR_T string; { if (string) free (string); } static char * dupstr(s) /* duplicate string */ CONST char * s; { /* * Use xmalloc(), because allocated block will be freed in the GNU * Readline Library routine. * Don't make a macro, because the variable 's' is evaluated twice. */ int len = strlen(s) + 1; char *d = xmalloc(len); Copy(s, d, len, char); /* Is Copy() better than strcpy() in XS? */ return d; } /* * for tputs XS routine */ static char *tputs_ptr; static int tputs_char(c) int c; { return *tputs_ptr++ = c; } /* * return name of FUNCTION. * I asked Chet Ramey to add this function in readline/bind.c. But he * did not, since he could not find any reasonable excuse. */ static const char * rl_get_function_name (function) rl_command_func_t *function; { register int i; rl_initialize_funmap (); for (i = 0; funmap[i]; i++) if (funmap[i]->function == function) return ((const char *)funmap[i]->name); /* cast is for oldies */ return NULL; } /* * from readline-4.0:complete.c * Redefine here since the function defined as static in complete.c. * This function is used for default value for rl_filename_quoting_function. */ static char * rl_quote_filename PARAMS((char *s, int rtype, char *qcp)); static char * rl_quote_filename (s, rtype, qcp) char *s; int rtype; char *qcp; { char *r; r = xmalloc (strlen (s) + 2); *r = *rl_completer_quote_characters; strcpy (r + 1, s); if (qcp) *qcp = *rl_completer_quote_characters; return r; } /* * string variable table for _rl_store_str(), _rl_fetch_str() */ static struct str_vars { char **var; int accessed; int read_only; } str_tbl[] = { /* When you change length of rl_line_buffer, you must call rl_extend_line_buffer(). See _rl_store_rl_line_buffer() */ { &rl_line_buffer, 0, 0 }, /* 0 */ { &rl_prompt, 0, 1 }, /* 1 */ { (char **)&rl_library_version, 0, 1 }, /* 2 */ { (char **)&rl_terminal_name, 0, 0 }, /* 3 */ { (char **)&rl_readline_name, 0, 0 }, /* 4 */ { (char **)&rl_basic_word_break_characters, 0, 0 }, /* 5 */ { (char **)&rl_basic_quote_characters, 0, 0 }, /* 6 */ { (char **)&rl_completer_word_break_characters, 0, 0 }, /* 7 */ { (char **)&rl_completer_quote_characters, 0, 0 }, /* 8 */ { (char **)&rl_filename_quote_characters, 0, 0 }, /* 9 */ { (char **)&rl_special_prefixes, 0, 0 }, /* 10 */ { &history_no_expand_chars, 0, 0 }, /* 11 */ { &history_search_delimiter_chars, 0, 0 }, /* 12 */ { &rl_executing_macro, 0, 1 }, /* 13 */ { &history_word_delimiters, 0, 0 }, /* 14 */ { &rl_display_prompt, 0, 0 }, /* 15 */ { &rl_executing_keyseq, 0, 1 } /* 16 */ }; /* * integer variable table for _rl_store_int(), _rl_fetch_int() */ static struct int_vars { int *var; int charp; int read_only; int ulong; } int_tbl[] = { { &rl_point, 0, 0, 0}, /* 0 */ { &rl_end, 0, 0, 0}, /* 1 */ { &rl_mark, 0, 0, 0}, /* 2 */ { &rl_done, 0, 0, 0}, /* 3 */ { &rl_pending_input, 0, 0, 0}, /* 4 */ { &rl_completion_query_items, 0, 0, 0}, /* 5 */ { &rl_completion_append_character, 0, 0, 0}, /* 6 */ { &rl_ignore_completion_duplicates, 0, 0, 0}, /* 7 */ { &rl_filename_completion_desired, 0, 0, 0}, /* 8 */ { &rl_filename_quoting_desired, 0, 0, 0}, /* 9 */ { &rl_inhibit_completion, 0, 0, 0}, /* 10 */ { &history_base, 0, 0, 0}, /* 11 */ { &history_length, 0, 0, 0}, /* 12 */ #if (RL_READLINE_VERSION >= 0x0402) { &history_max_entries, 0, 1, 0}, /* 13 */ #else /* (RL_READLINE_VERSION < 0x0402) */ { &max_input_history, 0, 1, 0}, /* 13 */ #endif /* (RL_READLINE_VERSION < 0x0402) */ { &history_write_timestamps, 0, 0, 0}, /* 14 */ { (int *)&history_expansion_char, 1, 0, 0}, /* 15 */ { (int *)&history_subst_char, 1, 0, 0}, /* 16 */ { (int *)&history_comment_char, 1, 0, 0}, /* 17 */ { &history_quotes_inhibit_expansion, 0, 0, 0}, /* 18 */ { &rl_erase_empty_line, 0, 0, 0}, /* 19 */ { &rl_catch_signals, 0, 0, 0}, /* 20 */ { &rl_catch_sigwinch, 0, 0, 0}, /* 21 */ { &rl_already_prompted, 0, 0, 0}, /* 22 */ { &rl_num_chars_to_read, 0, 0, 0}, /* 23 */ { &rl_dispatching, 0, 0, 0}, /* 24 */ { &rl_gnu_readline_p, 0, 1, 0}, /* 25 */ #if (RL_READLINE_VERSION >= 0x0700) /* * rl_readline_state becomes unsigned long on RL 7.0 * It still holds 32bit value. */ { (int *)&rl_readline_state, 0, 0, 1}, /* 26 */ #else { &rl_readline_state, 0, 0, 0}, /* 26 */ #endif { &rl_explicit_arg, 0, 1, 0}, /* 27 */ { &rl_numeric_arg, 0, 1, 0}, /* 28 */ { &rl_editing_mode, 0, 1, 0}, /* 29 */ { &rl_attempted_completion_over, 0, 0, 0}, /* 30 */ { &rl_completion_type, 0, 0, 0}, /* 31 */ { &rl_readline_version, 0, 1, 0}, /* 32 */ { &rl_completion_suppress_append, 0, 0, 0}, /* 33 */ { &rl_completion_quote_character, 0, 1, 0}, /* 34 */ { &rl_completion_suppress_quote, 0, 0, 0}, /* 35 */ { &rl_completion_found_quote, 0, 1, 0}, /* 36 */ { &rl_completion_mark_symlink_dirs, 0, 0, 0}, /* 37 */ { &rl_prefer_env_winsize, 0, 0, 0}, /* 38 */ { &rl_sort_completion_matches, 0, 0, 0}, /* 39 */ { &rl_completion_invoking_key, 0, 1, 0}, /* 40 */ { &rl_executing_key, 0, 1, 0}, /* 41 */ { &rl_key_sequence_length, 0, 1, 0}, /* 42 */ { &rl_change_environment, 0, 0, 0}, /* 43 */ { &rl_persistent_signal_handlers, 0, 0, 0}, /* 44 */ { &utf8_mode, 0, 0, 0} /* 45 */ }; /* * function pointer variable table for _rl_store_function(), * _rl_fetch_funtion() */ static int startup_hook_wrapper PARAMS((void)); static int event_hook_wrapper PARAMS((void)); static int getc_function_wrapper PARAMS((PerlIO *)); static void redisplay_function_wrapper PARAMS((void)); static char *completion_entry_function_wrapper PARAMS((const char *, int));; static char **attempted_completion_function_wrapper PARAMS((char *, int, int)); static char *filename_quoting_function_wrapper PARAMS((char *text, int match_type, char *quote_pointer)); static char *filename_dequoting_function_wrapper PARAMS((char *text, int quote_char)); static int char_is_quoted_p_wrapper PARAMS((char *text, int index)); static void ignore_some_completions_function_wrapper PARAMS((char **matches)); static int directory_completion_hook_wrapper PARAMS((char **textp)); static int history_inhibit_expansion_function_wrapper PARAMS((char *str, int i)); static int pre_input_hook_wrapper PARAMS((void)); static void completion_display_matches_hook_wrapper PARAMS((char **matches, int len, int max)); static char *completion_word_break_hook_wrapper PARAMS((void)); static int prep_term_function_wrapper PARAMS((int meta_flag)); static int deprep_term_function_wrapper PARAMS((void)); static int directory_rewrite_hook_wrapper PARAMS((char **dirnamep)); static char *filename_rewrite_hook_wrapper PARAMS((char *text, int quote_char)); static int signal_event_hook_wrapper PARAMS((void)); static int input_available_hook_wrapper PARAMS((void)); static int filename_stat_hook_wrapper PARAMS((char **fnamep)); enum { STARTUP_HOOK, EVENT_HOOK, GETC_FN, REDISPLAY_FN, CMP_ENT, ATMPT_COMP, FN_QUOTE, FN_DEQUOTE, CHAR_IS_QUOTEDP, IGNORE_COMP, DIR_COMP, HIST_INHIBIT_EXP, PRE_INPUT_HOOK, COMP_DISP_HOOK, COMP_WD_BRK_HOOK, PREP_TERM, DEPREP_TERM, DIR_REWRITE, FN_REWRITE, SIG_EVT, INP_AVL, FN_STAT }; typedef int XFunction (); static struct fn_vars { XFunction **rlfuncp; /* GNU Readline Library variable */ XFunction *defaultfn; /* default function */ XFunction *wrapper; /* wrapper function */ SV *callback; /* Perl function */ } fn_tbl[] = { { &rl_startup_hook, NULL, startup_hook_wrapper, NULL }, /* 0 */ { &rl_event_hook, NULL, event_hook_wrapper, NULL }, /* 1 */ { &rl_getc_function, rl_getc, getc_function_wrapper, NULL }, /* 2 */ { (XFunction **)&rl_redisplay_function, /* 3 */ (XFunction *)rl_redisplay, (XFunction *)redisplay_function_wrapper, NULL }, { (XFunction **)&rl_completion_entry_function, /* 4 */ NULL, (XFunction *)completion_entry_function_wrapper, NULL }, { (XFunction **)&rl_attempted_completion_function, /* 5 */ NULL, (XFunction *)attempted_completion_function_wrapper, NULL }, { (XFunction **)&rl_filename_quoting_function, /* 6 */ (XFunction *)rl_quote_filename, (XFunction *)filename_quoting_function_wrapper, NULL }, { (XFunction **)&rl_filename_dequoting_function, /* 7 */ NULL, (XFunction *)filename_dequoting_function_wrapper, NULL }, { (XFunction **)&rl_char_is_quoted_p, /* 8 */ NULL, (XFunction *)char_is_quoted_p_wrapper, NULL }, { (XFunction **)&rl_ignore_some_completions_function, /* 9 */ NULL, (XFunction *)ignore_some_completions_function_wrapper, NULL }, { (XFunction **)&rl_directory_completion_hook, /* 10 */ NULL, (XFunction *)directory_completion_hook_wrapper, NULL }, { (XFunction **)&history_inhibit_expansion_function, /* 11 */ NULL, (XFunction *)history_inhibit_expansion_function_wrapper, NULL }, { &rl_pre_input_hook, NULL, pre_input_hook_wrapper, NULL }, /* 12 */ { (XFunction **)&rl_completion_display_matches_hook, /* 13 */ NULL, (XFunction *)completion_display_matches_hook_wrapper, NULL }, { (XFunction **)&rl_completion_word_break_hook, /* 14 */ NULL, (XFunction *)completion_word_break_hook_wrapper, NULL }, { (XFunction **)&rl_prep_term_function, /* 15 */ (XFunction *)rl_prep_terminal, (XFunction *)prep_term_function_wrapper, NULL }, { (XFunction **)&rl_deprep_term_function, /* 16 */ (XFunction *)rl_deprep_terminal, (XFunction *)deprep_term_function_wrapper, NULL }, { (XFunction **)&rl_directory_rewrite_hook, /* 17 */ NULL, (XFunction *)directory_rewrite_hook_wrapper, NULL }, { (XFunction **)&rl_filename_rewrite_hook, /* 18 */ NULL, (XFunction *)filename_rewrite_hook_wrapper, NULL }, { (XFunction **)&rl_signal_event_hook, /* 19 */ NULL, (XFunction *)signal_event_hook_wrapper, NULL }, { (XFunction **)&rl_input_available_hook, /* 20 */ NULL, (XFunction *)input_available_hook_wrapper, NULL }, { (XFunction **)&rl_filename_stat_hook, /* 21 */ NULL, (XFunction *)filename_stat_hook_wrapper, NULL } }; /* * Perl function wrappers */ /* * common utility wrappers */ /* for rl_voidfunc_t : void fn(void) */ static int voidfunc_wrapper(type) int type; { dSP; int count; int ret; SV *svret; ENTER; SAVETMPS; PUSHMARK(sp); count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:voidfunc_wrapper: Internal error\n"); svret = POPs; ret = SvIOK(svret) ? SvIV(svret) : -1; PUTBACK; FREETMPS; LEAVE; return ret; } /* for rl_vintfunc_t : void fn(int) */ static int vintfunc_wrapper(type, arg) int type; int arg; { dSP; int count; int ret; SV *svret; ENTER; SAVETMPS; PUSHMARK(sp); XPUSHs(sv_2mortal(newSViv(arg))); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:vintfunc_wrapper: Internal error\n"); svret = POPs; ret = SvIOK(svret) ? SvIV(svret) : -1; PUTBACK; FREETMPS; LEAVE; return ret; } /* for rl_vcpfunc_t : void fn(char *) */ #if 0 static int vcpfunc_wrapper(type, text) int type; char *text; { dSP; int count; int ret; SV *svret; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:vcpfunc_wrapper: Internal error\n"); svret = POPs; ret = SvIOK(svret) ? SvIV(svret) : -1; PUTBACK; FREETMPS; LEAVE; return ret; } #endif /* for rl_vcppfunc_t : void fn(char **) */ #if 0 static int vcppfunc_wrapper(type, arg) int type; char **arg; { dSP; int count; SV *sv; int ret; SV *svret; char *rstr; ENTER; SAVETMPS; if (arg && *arg) { sv = sv_2mortal(newSVpv(*arg, 0)); } else { sv = &PL_sv_undef; } PUSHMARK(sp); XPUSHs(sv); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:vcppfunc_wrapper: Internal error\n"); svret = POPs; ret = SvIOK(svret) ? SvIV(svret) : -1; rstr = SvPV(sv, PL_na); if (strcmp(*arg, rstr) != 0) { xfree(*arg); *arg = dupstr(rstr); } PUTBACK; FREETMPS; LEAVE; return ret; } #endif /* for rl_hook_func_t, rl_ivoidfunc_t : int fn(void) */ static int hook_func_wrapper(type) int type; { dSP; int count; int ret; ENTER; SAVETMPS; PUSHMARK(sp); count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:hook_func_wrapper: Internal error\n"); ret = POPi; /* warns unless integer */ PUTBACK; FREETMPS; LEAVE; return ret; } /* for rl_intfunc_t : int fn(int) */ #if 0 static int intfunc_wrapper(type, arg) int type; int arg; { dSP; int count; int ret; ENTER; SAVETMPS; PUSHMARK(sp); XPUSHs(sv_2mortal(newSViv(arg))); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:intfunc_wrapper: Internal error\n"); ret = POPi; /* warns unless integer */ PUTBACK; FREETMPS; LEAVE; return ret; } #endif /* for rl_icpfunc_t : int fn(char *) */ #if 0 static int icpfunc_wrapper(type, text) int type; char *text; { dSP; int count; int ret; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:icpfunc_wrapper: Internal error\n"); ret = POPi; /* warns unless integer */ PUTBACK; FREETMPS; LEAVE; return ret; } #endif /* for rl_icppfunc_t : int fn(char **) */ static int icppfunc_wrapper(type, arg) int type; char **arg; { dSP; int count; SV *sv; int ret; char *rstr; ENTER; SAVETMPS; if (arg && *arg) { sv = sv_2mortal(newSVpv(*arg, 0)); } else { sv = &PL_sv_undef; } PUSHMARK(sp); XPUSHs(sv); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:icppfunc_wrapper: Internal error\n"); ret = POPi; rstr = SvPV(sv, PL_na); if (strcmp(*arg, rstr) != 0) { xfree(*arg); *arg = dupstr(rstr); } PUTBACK; FREETMPS; LEAVE; return ret; } /* for rl_cpvfunc_t : (char *)fn(void) */ static char * cpvfunc_wrapper(type) int type; { dSP; int count; char *str; SV *svret; ENTER; SAVETMPS; PUSHMARK(sp); count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:cpvfunc_wrapper: Internal error\n"); svret = POPs; str = SvOK(svret) ? dupstr(SvPV(svret, PL_na)) : NULL; PUTBACK; FREETMPS; LEAVE; return str; } /* for rl_cpifunc_t : (char *)fn(int) */ #if 0 static char * cpifunc_wrapper(type, arg) int type; int arg; { dSP; int count; char *str; SV *svret; ENTER; SAVETMPS; PUSHMARK(sp); XPUSHs(sv_2mortal(newSViv(arg))); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:cpifunc_wrapper: Internal error\n"); svret = POPs; str = SvOK(svret) ? dupstr(SvPV(svret, PL_na)) : NULL; PUTBACK; FREETMPS; LEAVE; return str; } #endif /* for rl_cpcpfunc_t : (char *)fn(char *) */ #if 0 static char * cpcpfunc_wrapper(type, text) int type; char *text; { dSP; int count; char *str; SV *svret; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:cpcpfunc_wrapper: Internal error\n"); svret = POPs; str = SvOK(svret) ? dupstr(SvPV(svret, PL_na)) : NULL; PUTBACK; FREETMPS; LEAVE; return str; } #endif /* for rl_cpcppfunc_t : (char *)fn(char **) */ #if 0 static char * cpcppfunc_wrapper(type, arg) int type; char **arg; { dSP; int count; SV *sv; char *str; SV *svret; char *rstr; ENTER; SAVETMPS; if (arg && *arg) { sv = sv_2mortal(newSVpv(*arg, 0)); } else { sv = &PL_sv_undef; } PUSHMARK(sp); XPUSHs(sv); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:cpcppfunc_wrapper: Internal error\n"); svret = POPs; str = SvOK(svret) ? dupstr(SvPV(svret, PL_na)) : NULL; rstr = SvPV(sv, PL_na); if (strcmp(*arg, rstr) != 0) { xfree(*arg); *arg = dupstr(rstr); } PUTBACK; FREETMPS; LEAVE; return str; } #endif /* * for rl_icpintfunc_t : int fn(char *, int) */ static int icpintfunc_wrapper(type, text, index) int type; char *text; int index; { dSP; int count; int ret; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal_utf8(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } XPUSHs(sv_2mortal(newSViv(index))); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:icpintfunc_wrapper: Internal error\n"); ret = POPi; /* warns unless integer */ PUTBACK; FREETMPS; LEAVE; return ret; } /* * for rl_dequote_func_t : (char *)fn(char *, int) */ static char * dequoting_function_wrapper(type, text, quote_char) int type; char *text; int quote_char; { dSP; int count; SV *replacement; char *str; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal_utf8(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } XPUSHs(sv_2mortal(newSViv(quote_char))); PUTBACK; count = call_sv(fn_tbl[type].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:dequoting_function_wrapper: Internal error\n"); replacement = POPs; str = SvOK(replacement) ? dupstr(SvPV(replacement, PL_na)) : NULL; PUTBACK; FREETMPS; LEAVE; return str; } /* * Specific wrappers for each variable */ static int startup_hook_wrapper() { return voidfunc_wrapper(STARTUP_HOOK); } static int event_hook_wrapper() { return voidfunc_wrapper(EVENT_HOOK); } static int getc_function_wrapper(fp) PerlIO *fp; { /* * 'PerlIO *fp' is ignored. Use rl_instream instead in the getc_function. * How can I pass 'PerlIO *fp'? */ return voidfunc_wrapper(GETC_FN); } static void redisplay_function_wrapper() { voidfunc_wrapper(REDISPLAY_FN); } /* * call a perl function as rl_completion_entry_function * for rl_compentry_func_t : (char *)fn(const char *, int) */ static char * completion_entry_function_wrapper(text, state) const char *text; int state; { dSP; int count; SV *match; char *str; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal_utf8(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } XPUSHs(sv_2mortal(newSViv(state))); PUTBACK; count = call_sv(fn_tbl[CMP_ENT].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:completion_entry_function_wrapper: Internal error\n"); match = POPs; str = SvOK(match) ? dupstr(SvPV(match, PL_na)) : NULL; PUTBACK; FREETMPS; LEAVE; return str; } /* * call a perl function as rl_attempted_completion_function * for rl_completion_func_t : (char **)fn(const char *, int, int) */ static char ** attempted_completion_function_wrapper(text, start, end) char *text; int start; int end; { dSP; int count; char **matches; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal_utf8(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } if (rl_line_buffer) { XPUSHs(sv_2mortal_utf8(newSVpv(rl_line_buffer, 0))); } else { XPUSHs(&PL_sv_undef); } XPUSHs(sv_2mortal(newSViv(start))); XPUSHs(sv_2mortal(newSViv(end))); PUTBACK; count = call_sv(fn_tbl[ATMPT_COMP].callback, G_ARRAY); SPAGAIN; /* cf. ignore_some_completions_function_wrapper() */ if (count > 0) { int i; int dopack = -1; /* * The returned array may contain some undef items. * Pack the array in such case. */ matches = (char **)xmalloc (sizeof(char *) * (count + 1)); matches[count] = NULL; for (i = count - 1; i >= 0; i--) { SV *v = POPs; if (SvOK(v)) { matches[i] = dupstr(SvPV(v, PL_na)); } else { matches[i] = NULL; if (i != 0) dopack = i; /* lowest index of hole */ } } /* pack undef items */ if (dopack > 0) { /* don't pack matches[0] */ int j = dopack; for (i = dopack; i < count; i++) { if (matches[i]) matches[j++] = matches[i]; } matches[count = j] = NULL; } if (count == 2) { /* only one match */ xfree(matches[0]); matches[0] = matches[1]; matches[1] = NULL; } else if (count == 1 && !matches[0]) { /* in case of a list of undef */ xfree(matches); matches = NULL; } } else { matches = NULL; } PUTBACK; FREETMPS; LEAVE; return matches; } /* * call a perl function as rl_filename_quoting_function * for rl_quote_func_t : (char *)fn(char *, int, char *) */ static char * filename_quoting_function_wrapper(text, match_type, quote_pointer) char *text; int match_type; char *quote_pointer; { dSP; int count; SV *replacement; char *str; ENTER; SAVETMPS; PUSHMARK(sp); if (text) { XPUSHs(sv_2mortal_utf8(newSVpv(text, 0))); } else { XPUSHs(&PL_sv_undef); } XPUSHs(sv_2mortal(newSViv(match_type))); if (quote_pointer) { XPUSHs(sv_2mortal(newSVpv(quote_pointer, 0))); } else { XPUSHs(&PL_sv_undef); } PUTBACK; count = call_sv(fn_tbl[FN_QUOTE].callback, G_SCALAR); SPAGAIN; if (count != 1) croak("Gnu.xs:filename_quoting_function_wrapper: Internal error\n"); replacement = POPs; str = SvOK(replacement) ? dupstr(SvPV(replacement, PL_na)) : NULL; PUTBACK; FREETMPS; LEAVE; return str; } static char * filename_dequoting_function_wrapper(text, quote_char) char *text; int quote_char; { return dequoting_function_wrapper(FN_DEQUOTE, text, quote_char); } static int char_is_quoted_p_wrapper(text, index) char *text; int index; { return icpintfunc_wrapper(CHAR_IS_QUOTEDP, text, index); } /* * call a perl function as rl_ignore_some_completions_function * for rl_compignore_func_t : int fn(char **) */ static void ignore_some_completions_function_wrapper(matches) char **matches; { dSP; int count, i, only_one_match; only_one_match = matches[1] == NULL ? 1 : 0; ENTER; SAVETMPS; PUSHMARK(sp); /* matches[0] is the maximal matching substring. So it may NULL, even rest * of matches[] has values. */ if (matches[0]) { XPUSHs(sv_2mortal_utf8(newSVpv(matches[0], 0))); /* xfree(matches[0]);*/ } else { XPUSHs(&PL_sv_undef); } for (i = 1; matches[i]; i++) { XPUSHs(sv_2mortal_utf8(newSVpv(matches[i], 0))); xfree(matches[i]); } /*xfree(matches);*/ PUTBACK; count = call_sv(fn_tbl[IGNORE_COMP].callback, G_ARRAY); SPAGAIN; if (only_one_match) { if (count == 0) { /* no match */ xfree(matches[0]); matches[0] = NULL; } /* else only one match */ } else if (count > 0) { int i; int dopack = -1; /* * The returned array may contain some undef items. * Pack the array in such case. */ matches[count] = NULL; for (i = count - 1; i > 0; i--) { /* don't pop matches[0] */ SV *v = POPs; if (SvOK(v)) { matches[i] = dupstr(SvPV(v, PL_na)); } else { matches[i] = NULL; dopack = i; /* lowest index of undef */ } } /* pack undef items */ if (dopack > 0) { /* don't pack matches[0] */ int j = dopack; for (i = dopack; i < count; i++) { if (matches[i]) matches[j++] = matches[i]; } matches[count = j] = NULL; } if (count == 1) { /* no match */ xfree(matches[0]); matches[0] = NULL; } else if (count == 2) { /* only one match */ xfree(matches[0]); matches[0] = matches[1]; matches[1] = NULL; } } else { /* no match */ xfree(matches[0]); matches[0] = NULL; } PUTBACK; FREETMPS; LEAVE; } static int directory_completion_hook_wrapper(textp) char **textp; { return icppfunc_wrapper(DIR_COMP, textp); } static int history_inhibit_expansion_function_wrapper(text, index) char *text; int index; { return icpintfunc_wrapper(HIST_INHIBIT_EXP, text, index); } static int pre_input_hook_wrapper() { return voidfunc_wrapper(PRE_INPUT_HOOK); } #if (RL_VERSION_MAJOR >= 4) /* * call a perl function as rl_completion_display_matches_hook * for rl_compdisp_func_t : void fn(char **, int, int) */ static void completion_display_matches_hook_wrapper(matches, len, max) char **matches; int len; int max; { dSP; int i; AV *av_matches; /* copy C matches[] array into perl array */ av_matches = newAV(); /* matches[0] is the maximal matching substring. So it may NULL, even rest * of matches[] has values. */ if (matches[0]) { av_push(av_matches, sv_2mortal_utf8(newSVpv(matches[0], 0))); } else { av_push(av_matches, &PL_sv_undef); } for (i = 1; matches[i]; i++) if (matches[i]) { av_push(av_matches, sv_2mortal_utf8(newSVpv(matches[i], 0))); } else { av_push(av_matches, &PL_sv_undef); } PUSHMARK(sp); XPUSHs(sv_2mortal(newRV_inc((SV *)av_matches))); /* push reference of array */ XPUSHs(sv_2mortal(newSViv(len))); XPUSHs(sv_2mortal(newSViv(max))); PUTBACK; call_sv(fn_tbl[COMP_DISP_HOOK].callback, G_DISCARD); } #else /* (RL_VERSION_MAJOR < 4) */ static void completion_display_matches_hook_wrapper(matches, len, max) char **matches; int len; int max; { /* dummy */ } #endif /* (RL_VERSION_MAJOR < 4) */ static char * completion_word_break_hook_wrapper() { return cpvfunc_wrapper(COMP_WD_BRK_HOOK); } static int prep_term_function_wrapper(meta_flag) int meta_flag; { return vintfunc_wrapper(PREP_TERM, meta_flag); } static int deprep_term_function_wrapper() { return voidfunc_wrapper(DEPREP_TERM); } static int directory_rewrite_hook_wrapper(dirnamep) char **dirnamep; { return icppfunc_wrapper(DIR_REWRITE, dirnamep); } static char * filename_rewrite_hook_wrapper(text, quote_char) char *text; int quote_char; { return dequoting_function_wrapper(FN_REWRITE, text, quote_char); } static int signal_event_hook_wrapper() { return hook_func_wrapper(SIG_EVT); } static int input_available_hook_wrapper() { return hook_func_wrapper(INP_AVL); } static int filename_stat_hook_wrapper(fnamep) char **fnamep; { return icppfunc_wrapper(FN_STAT, fnamep); } /* * If you need more custom functions, define more funntion_wrapper_xx() * and add entry on fntbl[]. */ static int function_wrapper PARAMS((int count, int key, int id)); static int fw_00(c, k) int c; int k; { return function_wrapper(c, k, 0); } static int fw_01(c, k) int c; int k; { return function_wrapper(c, k, 1); } static int fw_02(c, k) int c; int k; { return function_wrapper(c, k, 2); } static int fw_03(c, k) int c; int k; { return function_wrapper(c, k, 3); } static int fw_04(c, k) int c; int k; { return function_wrapper(c, k, 4); } static int fw_05(c, k) int c; int k; { return function_wrapper(c, k, 5); } static int fw_06(c, k) int c; int k; { return function_wrapper(c, k, 6); } static int fw_07(c, k) int c; int k; { return function_wrapper(c, k, 7); } static int fw_08(c, k) int c; int k; { return function_wrapper(c, k, 8); } static int fw_09(c, k) int c; int k; { return function_wrapper(c, k, 9); } static int fw_10(c, k) int c; int k; { return function_wrapper(c, k, 10); } static int fw_11(c, k) int c; int k; { return function_wrapper(c, k, 11); } static int fw_12(c, k) int c; int k; { return function_wrapper(c, k, 12); } static int fw_13(c, k) int c; int k; { return function_wrapper(c, k, 13); } static int fw_14(c, k) int c; int k; { return function_wrapper(c, k, 14); } static int fw_15(c, k) int c; int k; { return function_wrapper(c, k, 15); } static struct fnnode { rl_command_func_t *wrapper; /* C wrapper function */ SV *pfn; /* Perl function */ } fntbl[] = { { fw_00, NULL }, { fw_01, NULL }, { fw_02, NULL }, { fw_03, NULL }, { fw_04, NULL }, { fw_05, NULL }, { fw_06, NULL }, { fw_07, NULL }, { fw_08, NULL }, { fw_09, NULL }, { fw_10, NULL }, { fw_11, NULL }, { fw_12, NULL }, { fw_13, NULL }, { fw_14, NULL }, { fw_15, NULL } }; static int function_wrapper(count, key, id) int count; int key; int id; { dSP; PUSHMARK(sp); XPUSHs(sv_2mortal(newSViv(count))); XPUSHs(sv_2mortal(newSViv(key))); PUTBACK; call_sv(fntbl[id].pfn, G_DISCARD); return 0; } static SV *callback_handler_callback = NULL; static void callback_handler_wrapper(line) char *line; { dSP; PUSHMARK(sp); if (line) { XPUSHs(sv_2mortal_utf8(newSVpv(line, 0))); } else { XPUSHs(&PL_sv_undef); } PUTBACK; call_sv(callback_handler_callback, G_DISCARD); } #if 0 /* 2016/06/07 worked but no advantage */ /* to keep PerlIO given by _rl_store_iostream() */ static PerlIO *perlio_in; static PerlIO *perlio_out; /* for rl_getc_function */ static int trg_getc() { return PerlIO_getc(perlio_in); } /* for rl_input_available_hook */ static int trg_input_available() { return PerlIO_get_cnt(perlio_in) > 0; } #endif /* * make separate name space for low level XS functions and their methods */ MODULE = Term::ReadLine::Gnu PACKAGE = Term::ReadLine::Gnu::XS ######################################################################## # # Gnu Readline Library # ######################################################################## # # 2.1 Basic Behavior # # The function name "readline()" is reserved for a method name. t_utf8_free rl_readline(prompt = NULL) CONST char * prompt PROTOTYPE: ;$ CODE: RETVAL = readline(prompt); OUTPUT: RETVAL # # 2.4 Readline Convenience Functions # # # 2.4.1 Naming a Function # rl_command_func_t * rl_add_defun(name, fn, key = -1) CONST char * name SV * fn int key PROTOTYPE: $$;$ CODE: { int i; int nentry = sizeof(fntbl)/sizeof(struct fnnode); /* search an empty slot */ for (i = 0; i < nentry; i++) if (! fntbl[i].pfn) break; if (i >= nentry) { warn("Gnu.xs:rl_add_defun: custom function table is full. The maximum number of custum function is %d.\n", nentry); XSRETURN_UNDEF; } fntbl[i].pfn = newSVsv(fn); /* rl_add_defun() always returns 0. */ rl_add_defun(dupstr(name), fntbl[i].wrapper, key); RETVAL = fntbl[i].wrapper; } OUTPUT: RETVAL # # 2.4.2 Selection a Keymap # Keymap rl_make_bare_keymap() PROTOTYPE: Keymap _rl_copy_keymap(map) Keymap map PROTOTYPE: $ CODE: RETVAL = rl_copy_keymap(map); OUTPUT: RETVAL Keymap rl_make_keymap() PROTOTYPE: Keymap _rl_discard_keymap(map) Keymap map PROTOTYPE: $ CODE: rl_discard_keymap(map); RETVAL = map; OUTPUT: RETVAL # comment out until GNU Readline 6.2 will be released. void rl_free_keymap(map) Keymap map PROTOTYPE: $ Keymap rl_get_keymap() PROTOTYPE: Keymap _rl_set_keymap(map) Keymap map PROTOTYPE: $ CODE: rl_set_keymap(map); RETVAL = map; OUTPUT: RETVAL Keymap rl_get_keymap_by_name(name) CONST char * name PROTOTYPE: $ # Do not free the string returned. char * rl_get_keymap_name(map) Keymap map PROTOTYPE: $ # # 2.4.3 Binding Keys # int _rl_bind_key(key, function, map = rl_get_keymap()) int key rl_command_func_t * function Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_bind_key_in_map(key, function, map); OUTPUT: RETVAL int _rl_bind_key_if_unbound(key, function, map = rl_get_keymap()) int key rl_command_func_t * function Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_bind_key_if_unbound_in_map(key, function, map); OUTPUT: RETVAL int _rl_unbind_key(key, map = rl_get_keymap()) int key Keymap map PROTOTYPE: $;$ CODE: RETVAL = rl_unbind_key_in_map(key, map); OUTPUT: RETVAL # rl_unbind_function_in_map() and rl_unbind_command_in_map() are introduced # by readline-2.2. int _rl_unbind_function(function, map = rl_get_keymap()) rl_command_func_t * function Keymap map PROTOTYPE: $;$ CODE: RETVAL = rl_unbind_function_in_map(function, map); OUTPUT: RETVAL int _rl_unbind_command(command, map = rl_get_keymap()) CONST char * command Keymap map PROTOTYPE: $;$ CODE: RETVAL = rl_unbind_command_in_map(command, map); OUTPUT: RETVAL int _rl_bind_keyseq(keyseq, function, map = rl_get_keymap()) const char *keyseq rl_command_func_t * function Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_bind_keyseq_in_map(keyseq, function, map); OUTPUT: RETVAL # rl_set_key() is introduced by readline-4.2 and equivalent with # rl_generic_bind(ISFUNC, keyseq, (char *)function, map). int _rl_set_key(keyseq, function, map = rl_get_keymap()) CONST char * keyseq rl_command_func_t * function Keymap map PROTOTYPE: $$;$ CODE: #if (RL_READLINE_VERSION >= 0x0402) RETVAL = rl_set_key(keyseq, function, map); #else RETVAL = rl_generic_bind(ISFUNC, keyseq, (char *)function, map); #endif OUTPUT: RETVAL int _rl_bind_keyseq_if_unbound(keyseq, function, map = rl_get_keymap()) const char *keyseq rl_command_func_t * function Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_bind_keyseq_if_unbound_in_map(keyseq, function, map); OUTPUT: RETVAL int _rl_generic_bind_function(keyseq, function, map = rl_get_keymap()) CONST char * keyseq rl_command_func_t * function Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_generic_bind(ISFUNC, keyseq, (char *)function, map); OUTPUT: RETVAL int _rl_generic_bind_keymap(keyseq, keymap, map = rl_get_keymap()) CONST char * keyseq Keymap keymap Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_generic_bind(ISKMAP, keyseq, (char *)keymap, map); OUTPUT: RETVAL int _rl_generic_bind_macro(keyseq, macro, map = rl_get_keymap()) CONST char * keyseq CONST char * macro Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_generic_bind(ISMACR, keyseq, dupstr(macro), map); OUTPUT: RETVAL void rl_parse_and_bind(line) char * line PROTOTYPE: $ CODE: { char *s = dupstr(line); rl_parse_and_bind(s); /* Some NULs may be inserted in "s". */ xfree(s); } int rl_read_init_file(filename = NULL) CONST char * filename PROTOTYPE: ;$ # # 2.4.4 Associating Function Names and Bindings # int _rl_call_function(function, count = 1, key = -1) rl_command_func_t * function int count int key PROTOTYPE: $;$$ CODE: RETVAL = (*function)(count, key); OUTPUT: RETVAL rl_command_func_t * rl_named_function(name) CONST char * name PROTOTYPE: $ # Do not free the string returned. const char * rl_get_function_name(function) rl_command_func_t * function PROTOTYPE: $ void rl_function_of_keyseq(keyseq, map = rl_get_keymap()) CONST char * keyseq Keymap map PROTOTYPE: $;$ PPCODE: { int type; rl_command_func_t *p = rl_function_of_keyseq(keyseq, map, &type); SV *sv; if (p) { sv = sv_newmortal(); switch (type) { case ISFUNC: sv_setref_pv(sv, "rl_command_func_tPtr", (void*)p); break; case ISKMAP: sv_setref_pv(sv, "Keymap", (void*)p); break; case ISMACR: if (p) { sv_setpv(sv, (char *)p); } break; default: warn("Gnu.xs:rl_function_of_keyseq: illegal type `%d'\n", type); XSRETURN_EMPTY; /* return NULL list */ } EXTEND(sp, 2); PUSHs(sv); PUSHs(sv_2mortal(newSViv(type))); } else ; /* return NULL list */ } void _rl_invoking_keyseqs(function, map = rl_get_keymap()) rl_command_func_t * function Keymap map PROTOTYPE: $;$ PPCODE: { char **keyseqs; keyseqs = rl_invoking_keyseqs_in_map(function, map); if (keyseqs) { int i, count; /* count number of entries */ for (count = 0; keyseqs[count]; count++) ; EXTEND(sp, count); for (i = 0; i < count; i++) { PUSHs(sv_2mortal(newSVpv(keyseqs[i], 0))); xfree(keyseqs[i]); } xfree((char *)keyseqs); } else { /* return null list */ } } void rl_function_dumper(readable = 0) int readable PROTOTYPE: ;$ void rl_list_funmap_names() PROTOTYPE: # return list of all function name. (Term::Readline::Gnu specific function) void rl_get_all_function_names() PROTOTYPE: PPCODE: { int i, count; /* count number of entries */ for (count = 0; funmap[count]; count++) ; EXTEND(sp, count); for (i = 0; i < count; i++) { PUSHs(sv_2mortal(newSVpv(funmap[i]->name, 0))); } } void rl_funmap_names() PROTOTYPE: PPCODE: { const char **funmap; /* don't free returned memory */ funmap = (const char **)rl_funmap_names();/* cast is for oldies */ if (funmap) { int i, count; /* count number of entries */ for (count = 0; funmap[count]; count++) ; EXTEND(sp, count); for (i = 0; i < count; i++) { PUSHs(sv_2mortal(newSVpv(funmap[i], 0))); } } else { /* return null list */ } } int _rl_add_funmap_entry(name, function) CONST char * name rl_command_func_t * function PROTOTYPE: $$ CODE: RETVAL = rl_add_funmap_entry(name, function); OUTPUT: RETVAL # # 2.4.5 Allowing Undoing # int rl_begin_undo_group() PROTOTYPE: int rl_end_undo_group() PROTOTYPE: void rl_add_undo(what, start, end, text) int what int start int end char * text PROTOTYPE: $$$$ CODE: /* rl_free_undo_list will free the duplicated memory */ rl_add_undo((enum undo_code)what, start, end, dupstr(text)); void rl_free_undo_list() PROTOTYPE: int rl_do_undo() PROTOTYPE: int rl_modifying(start = 0, end = rl_end) int start int end PROTOTYPE: ;$$ # # 2.4.6 Redisplay # void rl_redisplay() PROTOTYPE: int rl_forced_update_display() PROTOTYPE: int rl_on_new_line() PROTOTYPE: int rl_on_new_line_with_prompt() PROTOTYPE: int rl_clear_visible_line() PROTOTYPE: int rl_reset_line_state() PROTOTYPE: int rl_show_char(i) int i PROTOTYPE: $ int _rl_message(text) const char * text PROTOTYPE: $ CODE: RETVAL = rl_message(text); OUTPUT: RETVAL int rl_crlf() PROTOTYPE: int rl_clear_message() PROTOTYPE: void rl_save_prompt() PROTOTYPE: void rl_restore_prompt() PROTOTYPE: int rl_expand_prompt(prompt) # should be defined as 'const char *' char * prompt int rl_set_prompt(prompt) const char * prompt # # 2.4.7 Modifying Text # int rl_insert_text(text) CONST char * text PROTOTYPE: $ int rl_delete_text(start = 0, end = rl_end) int start int end PROTOTYPE: ;$$ t_utf8_free rl_copy_text(start = 0, end = rl_end) int start int end PROTOTYPE: ;$$ int rl_kill_text(start = 0, end = rl_end) int start int end PROTOTYPE: ;$$ # rl_push_macro_input() is documented by readline-4.2 but it has been # implemented from 2.2.1. void rl_push_macro_input(macro) CONST char * macro PROTOTYPE: $ CODE: rl_push_macro_input(dupstr(macro)); # # 2.4.8 Character Input # int rl_read_key() PROTOTYPE: int rl_getc(stream) FILE * stream PROTOTYPE: $ int rl_stuff_char(c) int c PROTOTYPE: $ int rl_execute_next(c) int c PROTOTYPE: $ int rl_clear_pending_input() PROTOTYPE: int rl_set_keyboard_input_timeout(usec) int usec PROTOTYPE: $ # # 2.4.9 Terminal Management # void rl_prep_terminal(meta_flag) int meta_flag PROTOTYPE: $ void rl_deprep_terminal() PROTOTYPE: void _rl_tty_set_default_bindings(kmap = rl_get_keymap()) Keymap kmap PROTOTYPE: ;$ CODE: rl_tty_set_default_bindings(kmap); void _rl_tty_unset_default_bindings(kmap = rl_get_keymap()) Keymap kmap PROTOTYPE: ;$ CODE: rl_tty_unset_default_bindings(kmap); int rl_tty_set_echoing(value) int value PROTOTYPE: $ int rl_reset_terminal(terminal_name = NULL) CONST char * terminal_name PROTOTYPE: ;$ # # 2.4.10 Utility Functions # readline_state_t * rl_save_state() PROTOTYPE: CODE: { readline_state_t *state; Newx(state, 1, readline_state_t); rl_save_state(state); RETVAL = state; } OUTPUT: RETVAL int rl_restore_state(state) readline_state_t * state MODULE = Term::ReadLine::Gnu PACKAGE = readline_state_tPtr PREFIX = my_ void my_DESTROY(state) readline_state_t * state CODE: { #warn("readline_state_tPtr::DESTROY\n"); Safefree(state); } MODULE = Term::ReadLine::Gnu PACKAGE = Term::ReadLine::Gnu::XS void rl_replace_line(text, clear_undo = 0) const char *text int clear_undo PROTOTYPE: $;$ int rl_initialize() PROTOTYPE: CODE: { RETVAL = rl_initialize(); /* * Perl optionally maintains its own envirnment variable array * using its own memory management functions. On the other hand * the GNU Readline Library sets variables, $LINES and $COLUMNS, * by using the C library function putenv() in * rl_initialize(). When Perl frees the memory for the variables * during the destruction (perl.c:perl_destruct()), it may cause * segmentation faults. * * CPAN ticket #37194 * https://rt.cpan.org/Public/Bug/Display.html?id=37194 * * To solve the problem, make a copy of the whole environment * variable array which might be reallocated by rl_initialize(). */ /* from perl.c:perl_destruct() */ #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV) \ && !defined(PERL_DARWIN) # if ((PERL_VERSION > 8) || (PERL_VERSION == 8 && PERL_SUBVERSION >= 6)) /* Perl 5.8.6 introduced PL_use_safe_putenv. */ if (environ != PL_origenviron && !PL_use_safe_putenv # else if (environ != PL_origenviron # endif # ifdef USE_ITHREADS /* only main thread can free environ[0] contents */ && PL_curinterp == aTHX # endif ) { int i, len; char *s; char **tmpenv; for (i = 0; environ[i]; i++) ; /* * We cannot use New*() which uses safemalloc() instead of * safesysmalloc(). */ tmpenv = (char **)safesysmalloc((i+1)*sizeof(char *)); for (i = 0; environ[i]; i++) { len = strlen(environ[i]); s = (char*)safesysmalloc((len+1)*sizeof(char)); Copy(environ[i], s, len+1, char); tmpenv[i] = s; } tmpenv[i] = NULL; environ = tmpenv; } #endif } OUTPUT: RETVAL int rl_ding() PROTOTYPE: int rl_alphabetic(c) int c PROTOTYPE: $ void rl_display_match_list(pmatches, plen = -1, pmax = -1) SV * pmatches int plen int pmax PROTOTYPE: $;$$ CODE: { unsigned int len, max, i; STRLEN l; char **matches; AV *av_matches; SV **pvp; if (SvTYPE(SvRV(pmatches)) != SVt_PVAV) { warn("Gnu.xs:_rl_display_match_list: the 1st arguments must be a reference to an array\n"); return; } av_matches = (AV *)SvRV(ST(0)); /* index zero contains a possible match and is not counted */ if ((len = av_len(av_matches) + 1 - 1) == 0) return; matches = (char **)xmalloc (sizeof(char *) * (len + 2)); max = 0; for (i = 0; i <= len; i++) { pvp = av_fetch(av_matches, i, 0); if (SvPOKp(*pvp)) { matches[i] = dupstr(SvPV(*pvp, l)); if (l > max) max = l; } } matches[len + 1] = NULL; rl_display_match_list(matches, plen < 0 ? len : plen, pmax < 0 ? max : pmax); for (i = 1; i <= len; i++) xfree(matches[i]); xfree(matches); } # # 2.4.11 Miscellaneous Functions # # rl_macro_bind() is documented by readline-4.2 but it has been implemented # from 2.2.1. # It is equivalent with # rl_generic_bind(ISMACR, keyseq, (char *)macro_keys, map). int _rl_macro_bind(keyseq, macro, map = rl_get_keymap()) CONST char * keyseq CONST char * macro Keymap map PROTOTYPE: $$;$ CODE: RETVAL = rl_macro_bind(keyseq, macro, map); OUTPUT: RETVAL # rl_macro_dumper is documented by Readline 4.2, # but have been implemented for 2.2.1. void rl_macro_dumper(readable = 0) int readable PROTOTYPE: ;$ # rl_variable_bind() is documented by readline-4.2 but it has been implemented # from 2.2.1. int rl_variable_bind(name, value) CONST char * name CONST char * value PROTOTYPE: $$ # rl_variable_dumper is documented by Readline 4.2, # but have been implemented for 2.2.1. # Do not free the string returned. t_utf8 rl_variable_value(variable) CONST char * variable PROTOTYPE: $ void rl_variable_dumper(readable = 0) int readable PROTOTYPE: ;$ int rl_set_paren_blink_timeout(usec) int usec PROTOTYPE: $ # rl_get_termcap() is documented by readline-4.2 but it has been implemented # from 2.2.1. # Do not free the string returned. char * rl_get_termcap(cap) CONST char * cap PROTOTYPE: $ # # 2.4.12 Alternate Interface # void rl_callback_handler_install(prompt, lhandler) const char * prompt SV * lhandler PROTOTYPE: $$ CODE: { static char *cb_prompt = NULL; int len = strlen(prompt) + 1; /* The value of prompt may be used after return from this routine. */ if (cb_prompt) { Safefree(cb_prompt); } New(0, cb_prompt, len, char); Copy(prompt, cb_prompt, len, char); /* * Don't remove braces. The definition of SvSetSV() of * Perl 5.003 has a problem. */ if (callback_handler_callback) { SvSetSV(callback_handler_callback, lhandler); } else { callback_handler_callback = newSVsv(lhandler); } rl_callback_handler_install(cb_prompt, callback_handler_wrapper); } void rl_callback_read_char() PROTOTYPE: void rl_callback_sigcleanup() PROTOTYPE: void rl_callback_handler_remove() PROTOTYPE: # # 2.5 Readline Signal Handling # int rl_pending_signal() PROTOTYPE: void rl_cleanup_after_signal() PROTOTYPE: void rl_free_line_state() PROTOTYPE: void rl_reset_after_signal() PROTOTYPE: void rl_echo_signal_char(sig) int sig PROTOTYPE: $ void rl_resize_terminal() PROTOTYPE: void rl_set_screen_size(rows, cols) int rows int cols PROTOTYPE: $$ void rl_get_screen_size() PROTOTYPE: PPCODE: { int rows, cols; rl_get_screen_size(&rows, &cols); EXTEND(sp, 2); PUSHs(sv_2mortal(newSViv(rows))); PUSHs(sv_2mortal(newSViv(cols))); } void rl_reset_screen_size() PROTOTYPE: int rl_set_signals() PROTOTYPE: int rl_clear_signals() PROTOTYPE: # # 2.6 Custom Completers # int rl_complete_internal(what_to_do = TAB) int what_to_do PROTOTYPE: ;$ int _rl_completion_mode(function) rl_command_func_t * function PROTOTYPE: $ CODE: RETVAL = rl_completion_mode(function); OUTPUT: RETVAL void rl_completion_matches(text, fn = NULL) CONST char * text SV * fn PROTOTYPE: $;$ PPCODE: { char **matches; if (SvTRUE(fn)) { /* use completion_entry_function temporarily */ XFunction *rlfunc_save = *(fn_tbl[CMP_ENT].rlfuncp); /* ??? */ SV *callback_save = fn_tbl[CMP_ENT].callback; fn_tbl[CMP_ENT].callback = newSVsv(fn); matches = rl_completion_matches(text, completion_entry_function_wrapper); SvREFCNT_dec(fn_tbl[CMP_ENT].callback); fn_tbl[CMP_ENT].callback = callback_save; *(fn_tbl[CMP_ENT].rlfuncp) = rlfunc_save; /* ??? */ } else matches = rl_completion_matches(text, NULL); /* * Without the next line the Perl internal stack is broken * under some condition. Perl bug or undocumented feature * !!!? */ SPAGAIN; sp -= 2; if (matches) { int i, count; /* count number of entries */ for (count = 0; matches[count]; count++) ; EXTEND(sp, count); for (i = 0; i < count; i++) { PUSHs(sv_2mortal_utf8(newSVpv(matches[i], 0))); xfree(matches[i]); } xfree((char *)matches); } else { /* return null list */ } } t_utf8_free rl_filename_completion_function(text, state) const char * text int state PROTOTYPE: $$ t_utf8_free rl_username_completion_function(text, state) const char * text int state PROTOTYPE: $$ ######################################################################## # # Gnu History Library # ######################################################################## # # 2.3.1 Initializing History and State Management # void using_history() PROTOTYPE: HISTORY_STATE * history_get_history_state() PROTOTYPE: void history_set_history_state(state) HISTORY_STATE * state MODULE = Term::ReadLine::Gnu PACKAGE = HISTORY_STATEPtr PREFIX = my_ void my_DESTROY(state) HISTORY_STATE * state CODE: { #warn("HISTORY_STATEPtr::DESTROY\n"); xfree(state); } MODULE = Term::ReadLine::Gnu PACKAGE = Term::ReadLine::Gnu::XS # # 2.3.2 History List Management # void add_history(string) CONST char * string PROTOTYPE: $ void add_history_time(string) CONST char * string PROTOTYPE: $ HIST_ENTRY * remove_history(which) int which PROTOTYPE: $ OUTPUT: RETVAL CLEANUP: if (RETVAL) { xfree(RETVAL->line); #if (RL_VERSION_MAJOR >= 5) xfree(RETVAL->timestamp); #endif /* (RL_VERSION_MAJOR >= 5) */ xfree(RETVAL->data); xfree((char *)RETVAL); } # free_history_entry() is introduced by GNU Readline Library 5.0. # Since Term::ReadLine::Gnu does not support the member 'data' of HIST_ENTRY # structure, remove_history() covers it. # The 3rd parameter (histdata_t) is not supported. Does anyone use it? HIST_ENTRY * replace_history_entry(which, line) int which CONST char * line PROTOTYPE: $$ CODE: RETVAL = replace_history_entry(which, line, (char *)NULL); OUTPUT: RETVAL CLEANUP: if (RETVAL) { xfree(RETVAL->line); #if (RL_VERSION_MAJOR >= 5) xfree(RETVAL->timestamp); #endif /* (RL_VERSION_MAJOR >= 5) */ xfree(RETVAL->data); xfree((char *)RETVAL); } void clear_history() PROTOTYPE: int stifle_history(i) SV * i PROTOTYPE: $ CODE: { if (SvOK(i)) { int max = SvIV(i); stifle_history(max); RETVAL = max; } else { RETVAL = unstifle_history(); } } OUTPUT: RETVAL int unstifle_history() PROTOTYPE: int history_is_stifled() PROTOTYPE: # # 2.3.3 Information about the History List # # history_list() is implemented as a perl function in Gnu.pm. int where_history() PROTOTYPE: HIST_ENTRY * current_history() PROTOTYPE: HIST_ENTRY * history_get(offset) int offset PROTOTYPE: $ # To keep compatibility, I cannot make a function whose argument # is "HIST_ENTRY *". time_t history_get_time(offset) int offset PROTOTYPE: $ CODE: { HIST_ENTRY *he = history_get(offset); if (he) RETVAL = history_get_time(he); else RETVAL = 0; } OUTPUT: RETVAL int history_total_bytes() PROTOTYPE: # # 2.3.4 Moving Around the History List # int history_set_pos(pos) int pos PROTOTYPE: $ HIST_ENTRY * previous_history() PROTOTYPE: HIST_ENTRY * next_history() PROTOTYPE: # # 2.3.5 Searching the History List # int history_search(string, direction = -1) CONST char * string int direction PROTOTYPE: $;$ int history_search_prefix(string, direction = -1) CONST char * string int direction PROTOTYPE: $;$ int history_search_pos(string, direction = -1, pos = where_history()) CONST char * string int direction int pos PROTOTYPE: $;$$ # # 2.3.6 Managing the History File # int read_history_range(filename = NULL, from = 0, to = -1) CONST char * filename int from int to PROTOTYPE: ;$$$ int write_history(filename = NULL) CONST char * filename PROTOTYPE: ;$ int append_history(nelements, filename = NULL) int nelements CONST char * filename PROTOTYPE: $;$ int history_truncate_file(filename = NULL, nlines = 0) CONST char * filename int nlines PROTOTYPE: ;$$ # # 2.3.7 History Expansion # void history_expand(line) # should be defined as 'const char *' char * line PROTOTYPE: $ PPCODE: { char *expansion; int result; result = history_expand(line, &expansion); EXTEND(sp, 2); PUSHs(sv_2mortal(newSViv(result))); PUSHs(sv_2mortal_utf8(newSVpv(expansion, 0))); xfree(expansion); } void _get_history_event(string, cindex, qchar = 0) CONST char * string int cindex int qchar PROTOTYPE: $$;$ PPCODE: { char *text; text = get_history_event(string, &cindex, qchar); EXTEND(sp, 2); if (text) { /* don't free `text' */ PUSHs(sv_2mortal_utf8(newSVpv(text, 0))); } else { PUSHs(&PL_sv_undef); } PUSHs(sv_2mortal(newSViv(cindex))); } void history_tokenize(text) CONST char * text PROTOTYPE: $ PPCODE: { char **tokens; tokens = history_tokenize(text); if (tokens) { int i, count; /* count number of entries */ for (count = 0; tokens[count]; count++) ; EXTEND(sp, count); for (i = 0; i < count; i++) { PUSHs(sv_2mortal_utf8(newSVpv(tokens[i], 0))); xfree(tokens[i]); } xfree((char *)tokens); } else { /* return null list */ } } #define DALLAR '$' /* define for xsubpp bug */ t_utf8_free _history_arg_extract(line, first = 0 , last = DALLAR) CONST char * line int first int last PROTOTYPE: $;$$ CODE: RETVAL = history_arg_extract(first, last, line); OUTPUT: RETVAL # # GNU Readline/History Library Variable Access Routines # MODULE = Term::ReadLine::Gnu PACKAGE = Term::ReadLine::Gnu::Var void _rl_store_str(pstr, id) const char * pstr int id PROTOTYPE: $$ CODE: { size_t len; ST(0) = sv_newmortal(); if (id < 0 || id >= sizeof(str_tbl)/sizeof(struct str_vars)) { warn("Gnu.xs:_rl_store_str: Illegal `id' value: `%d'", id); XSRETURN_UNDEF; } if (str_tbl[id].read_only) { warn("Gnu.xs:_rl_store_str: store to read only variable"); XSRETURN_UNDEF; } /* * Use xmalloc() and xfree() instead of New() and Safefree(), * because this block may be reallocated by the GNU Readline Library. */ if (str_tbl[id].accessed && *str_tbl[id].var) { /* * First time a variable is used by this routine, * it may be a static area. So it cannot be freed. */ xfree(*str_tbl[id].var); *str_tbl[id].var = NULL; } str_tbl[id].accessed = 1; /*printf("%d: %s\n", id, pstr);*/ len = strlen(pstr) + 1; *str_tbl[id].var = xmalloc(len); Copy(pstr, *str_tbl[id].var, len, char); /* return variable value */ if (*str_tbl[id].var) { sv_setpv(ST(0), *str_tbl[id].var); } } void _rl_store_rl_line_buffer(pstr) const char * pstr PROTOTYPE: $ CODE: { size_t len; ST(0) = sv_newmortal(); if (pstr) { len = strlen(pstr); /* * Old manual did not document this function, but can be * used. */ rl_extend_line_buffer(len + 1); Copy(pstr, rl_line_buffer, len + 1, char); /* rl_line_buffer is not NULL here */ sv_setpv(ST(0), rl_line_buffer); /* fix rl_end and rl_point */ rl_end = len; if (rl_point > len) rl_point = len; } } void _rl_fetch_str(id) int id PROTOTYPE: $ CODE: { ST(0) = sv_newmortal(); if (id < 0 || id >= sizeof(str_tbl)/sizeof(struct str_vars)) { warn("Gnu.xs:_rl_fetch_str: Illegal `id' value: `%d'", id); } else { if (*(str_tbl[id].var)) { sv_setpv(ST(0), *(str_tbl[id].var)); if (utf8_mode) { sv_utf8_decode(ST(0)); } } } } void _rl_store_int(pint, id) int pint int id PROTOTYPE: $$ CODE: { ST(0) = sv_newmortal(); if (id < 0 || id >= sizeof(int_tbl)/sizeof(struct int_vars)) { warn("Gnu.xs:_rl_store_int: Illegal `id' value: `%d'", id); XSRETURN_UNDEF; } if (int_tbl[id].read_only) { warn("Gnu.xs:_rl_store_int: store to read only variable"); XSRETURN_UNDEF; } /* set C variable */ if (int_tbl[id].charp) *((char *)(int_tbl[id].var)) = (char)pint; else if (int_tbl[id].ulong) *((unsigned long *)(int_tbl[id].var)) = (unsigned long)pint; else *(int_tbl[id].var) = pint; /* return variable value */ sv_setiv(ST(0), pint); } void _rl_fetch_int(id) int id PROTOTYPE: $ CODE: { ST(0) = sv_newmortal(); if (id < 0 || id >= sizeof(int_tbl)/sizeof(struct int_vars)) { warn("Gnu.xs:_rl_fetch_int: Illegal `id' value: `%d'", id); /* return undef */ } else { if (int_tbl[id].charp) sv_setiv(ST(0), (int)*((char *)(int_tbl[id].var))); else if (int_tbl[id].ulong) sv_setiv(ST(0), (int)*((unsigned long *)(int_tbl[id].var))); else sv_setiv(ST(0), *(int_tbl[id].var)); } } #if 1 /* http://perldoc.perl.org/perlxs.html#Inserting-POD%2c-Comments-and-C-Preprocessor-Directives */ void _rl_store_iostream(stream, id) FILE *stream int id PROTOTYPE: $$ CODE: { switch (id) { case 0: rl_instream = stream; break; case 1: rl_outstream = stream; #ifdef __CYGWIN__ { /* Cygwin b20.1 library converts NL to CR-NL automatically. But it does not do it on a file stream made by Perl. Set terminal attribute explicitly */ struct termios tio; tcgetattr(fileno(rl_outstream), &tio); tio.c_iflag |= ICRNL; tio.c_oflag |= ONLCR; tcsetattr(fileno(rl_outstream), TCSADRAIN, &tio); } #endif /* __CYGWIN__ */ break; default: warn("Gnu.xs:_rl_store_iostream: Illegal `id' value: `%d'", id); break; } PerlIO_debug("TRG:store_iostream id %d fd %d\n", id, fileno(stream)); } #else /* 2016/06/07 worked but no advantage */ void _rl_store_iostream(iop, id) PerlIO *iop int id PROTOTYPE: $$ CODE: { int fd = -1; switch (id) { case 0: perlio_in = iop; rl_instream = PerlIO_findFILE(iop); fd = fileno(rl_instream); break; case 1: perlio_out = iop; rl_outstream = PerlIO_findFILE(iop); fd = fileno(rl_outstream); #ifdef __CYGWIN__ { /* Cygwin b20.1 library converts NL to CR-NL automatically. But it does not do it on a file stream made by Perl. Set terminal attribute explicitly */ struct termios tio; tcgetattr(fd, &tio); tio.c_iflag |= ICRNL; tio.c_oflag |= ONLCR; tcsetattr(fd, TCSADRAIN, &tio); } #endif /* __CYGWIN__ */ break; default: warn("Gnu.xs:_rl_store_iostream: Illegal `id' value: `%d'", id); break; } PerlIO_debug("TRG:store_iostream id %d fd %d\n", id, fd); } #endif #if 0 /* not used since 1.26 */ PerlIO * _rl_fetch_iostream(id) int id PROTOTYPE: $ CODE: { switch (id) { case 0: if (instreamPIO == NULL) RETVAL = instreamPIO = PerlIO_importFILE(rl_instream, NULL); else RETVAL = instreamPIO; break; case 1: if (outstreamPIO == NULL) RETVAL = outstreamPIO = PerlIO_importFILE(rl_outstream, NULL); else RETVAL = outstreamPIO; break; default: warn("Gnu.xs:_rl_fetch_iostream: Illegal `id' value: `%d'", id); XSRETURN_UNDEF; break; } PerlIO_debug("TRG:fetch_iostream id %d fd %d\n", id, PerlIO_fileno(RETVAL)); } OUTPUT: RETVAL #endif Keymap _rl_fetch_keymap(id) int id PROTOTYPE: $ CODE: { switch (id) { case 0: RETVAL = rl_executing_keymap; break; case 1: RETVAL = rl_binding_keymap; break; default: warn("Gnu.xs:_rl_fetch_keymap: Illegal `id' value: `%d'", id); XSRETURN_UNDEF; break; } } OUTPUT: RETVAL void _rl_store_function(fn, id) SV * fn int id PROTOTYPE: $$ CODE: { /* * If "fn" is undef, default value of the GNU Readline * Library is set. */ ST(0) = sv_newmortal(); if (id < 0 || id >= sizeof(fn_tbl)/sizeof(struct fn_vars)) { warn("Gnu.xs:_rl_store_function: Illegal `id' value: `%d'", id); XSRETURN_UNDEF; } if (SvTRUE(fn)) { /* * Don't remove braces. The definition of SvSetSV() of * Perl 5.003 has a problem. */ if (fn_tbl[id].callback) { SvSetSV(fn_tbl[id].callback, fn); } else { fn_tbl[id].callback = newSVsv(fn); } *(fn_tbl[id].rlfuncp) = fn_tbl[id].wrapper; } else { if (fn_tbl[id].callback) { SvSetSV(fn_tbl[id].callback, &PL_sv_undef); } *(fn_tbl[id].rlfuncp) = fn_tbl[id].defaultfn; } /* return variable value */ sv_setsv(ST(0), fn); } void _rl_fetch_function(id) int id PROTOTYPE: $ CODE: { ST(0) = sv_newmortal(); if (id < 0 || id >= sizeof(fn_tbl)/sizeof(struct fn_vars)) { warn("Gnu.xs:_rl_fetch_function: Illegal `id' value: `%d'", id); /* return undef */ } else if (fn_tbl[id].callback && SvTRUE(fn_tbl[id].callback)) { sv_setsv(ST(0), fn_tbl[id].callback); } } rl_command_func_t * _rl_fetch_last_func() PROTOTYPE: CODE: RETVAL = rl_last_func; OUTPUT: RETVAL MODULE = Term::ReadLine::Gnu PACKAGE = Term::ReadLine::Gnu::XS void tgetstr(id) const char * id PROTOTYPE: $ CODE: ST(0) = sv_newmortal(); if (id) { /* * The magic number `2032' is derived from bash * terminal.c:_rl_init_terminal_io(). */ char buffer[2032]; char *bp = buffer; char *t; t = tgetstr(id, &bp); /* don't free returned string */ if (t) { char buf[2032]; /* call tputs() to apply padding information */ tputs_ptr = buf; tputs(t, 1, tputs_char); *tputs_ptr = '\0'; sv_setpv(ST(0), buf); } } # # Local Variables: # c-default-style: "gnu" # End: # Term-ReadLine-Gnu-1.35/INSTALL0000644060175006010010000001157312530031606014417 0ustar hirooNone-*- Indented-text -*- # $Id: INSTALL 487 2015-05-23 08:00:11Z hayashi $ 1. How to Install Term::ReadLine::Gnu You need the GNU Readline library installed. Except for this, you can install this module by the standard method, i.e. % perl Makefile.PL; make install 1.1 Install GNU Readline library 2.1 or later and their header files. See the section `How to Install GNU Readline Library'. 1.2 Make and install % perl Makefile.PL [--prefix=...] [--includedir=...] [--libdir=...] % make % make test % make install If you have installed the GNU Readline Library (libreadline.{a,so} and readline/readline.h, etc.) on directories for which your perl is not configured to search (refer the value of ccflags and libpath in the output of `perl -V'), specify the paths as follows; % perl Makefile.PL --includedir=/mydir/include --libdir=/mydir/lib This example is equivalent to the following; % perl Makefile.PL --prefix=/mydir If you are not an administrator and cannot install Perl module in your system directory, try perldoc perlfaq8 and see the section 'How do I keep my own module/library directory?' (This section is found in the Perl 5.6 documentation). 1.3 Trouble Shooting If you have any trouble when using or installing this module or find a bug, please open a ticket on the bug tracker at rt.cpan.org; It will help other people who have same problems. When you report your trouble, be sure to send me the following information; - output of % perl -V % perl Makefile.PL verbose % make test TEST_VERBOSE=1 % perl -Mblib t/00checkver.t % echo $TERM - terminal emulator which you are using - compiler which is used to compile the GNU Readline Library (libreadline.a) if you can know. 1.3.1 Segmentation fault by the pager command in Perl debugger If the pager command (| or ||) in Perl debugger causes segmentation fault, you need to fix perl5db.pl. See for details. 2. How to Install GNU Readline Library Now this module supports only GNU Readline Library 2.1 and later. But GNU Readline 2.2 has some bugs, so Use 2.2.1 instead. GNU Readline Library 4.2 is not supported. Use 4.2a instead. If you have any reasons in which use must use one of the follows; GNU Readline Library 2.1 libreadline.a in bash-2.0.tar.gz Cygwin b20.1 see INSTALL file which is included in Term-ReadLine-Gnu-1.11. Executing `perl Makefile.PL` detects which version of the GNU Readline Library is already installed and warns you if you have the unsupported version. In the following example, the install prefix directory is `/usr/local/gnu'. You can specify any directory for the GNU Readline library and its header files, by editing `LIBS' and/or `INC' section in Makefile.PL. 2.1. Install from the GNU Readline Library Source 1. get and extract readline-XX.tar.gz 2. configure % ./configure --prefix=/usr/local/gnu 3. make and install % make install 2.1.1. Install on Mac OS X /usr/bin/perl on Mac OS X 10.5 (Leopard) and later supports 32bit/64bit universal binary. Make Makefile as follows; # tested only on Mavericks ARCHFLAGS='-arch x86_64' perl Makefile.PL --prefix=/usr/local/gnu Or build 32bit/64bit-universal GNU Readline Library as follows. (works on GNU Readline 6.3 and later) Enable the following lines in support/shobj-conf in GNU Readline 6.3 distribution; # for 32 and 64bit universal library #SHOBJ_ARCHFLAGS='-arch i386 -arch x86_64' #SHOBJ_CFLAGS=${SHOBJ_CFLAGS}' -arch i386 -arch x86_64' run configure script and do 'make install' and make Makefile simply; # tested only on Mavericks perl Makefile.PL --prefix=/usr/local/gnu 2.2. Using Package 2.2.1. RPM on Linux On Linux you need to install 'ncurses-devel' package in addition to 'readline-devel' package. On distributions using RPM do follows; % sudo yum install ncurses-devel % sudo yum install readline-devel 2.2.2. homebrew on Mac OS X 1. Install homebrew See http://brew.sh/. 2. Use homebrew to install the GNU Readline Library: % brew install readline Because the GNU Readline library conflicts with the the similarly-named-but-different library installed in the base OS, homebrew does not link readline into /usr/local (it is "keg-only"). Makefile.PL uses `brew prefix readline' to find and use the "keg" directory so things work seamlessly. 3. Build Term::ReadLine::Gnu as described above: % perl Makefile.PL % make % make test % make install `brew cleanup' will not remove keg-only formula, to avoid breaking things that have been linked against it. However, if you force it, `brew cleanup --force', then it will remove the keg-only formula and Term::ReadLine::Gnu will cease to work. You'll need to rebuild Term::ReadLine::GNU so that it links against whichever newer version you have installed. EOF Term-ReadLine-Gnu-1.35/Makefile.PL0000644060175006010010000002513012665047417015352 0ustar hirooNone# # Makefile.PL for Term::ReadLine::Gnu # # $Id: Makefile.PL 505 2016-02-29 14:00:39Z hayashi $ # # Copyright (c) 1996 Hiroo Hayashi. All rights reserved. # # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # OS/2 support was contributed by Ilya Zakharevich. # # # Usage: perl Makefile.PL [--prefix=...] [--includedir=...] [--libdir=...] # [OPTIMIZE=...] # # Read INSTALL for more details. ######################################################################## use strict; use ExtUtils::MakeMaker; use Config; use Getopt::Long; use 5.008; use 5.8.1; my ($defs, $libs, $lddflags, $RLLIB, $RLINC); # exit 0 before creating the Makefile to be CPAN Testers friendly # see http://wiki.cpantester.org/wiki/CPANAuthorNotes my $err = $ENV{AUTOMATED_TESTING} ? 0 : 1; # test /dev/tty for CPAN Testers if ($ENV{AUTOMATED_TESTING} && !open(SESAMI, '/dev/tty')) { warn "cannot open /dev/tty\n"; exit 0; } # I could not reach a tester, "Chris Williams (BINGOS)". if ($ENV{AUTOMATED_TESTING} && ($Config{osname} eq 'openbsd')) { die "OS unsupported\nPlease contact the author.\n"; } $defs = ($Config{strings} =~ m|/string.h$|) ? '-DHAVE_STRING_H' : ''; # pacify warnings for -D_FORTIFY_SOURCE which perl 5.20.0 started using if ($Config{ccflags} =~ /-D_FORTIFY_SOURCE=/) { $defs .= ' -O'; } # Parse command line to specify paths for the GNU Readline Library { my ($prefix, $libdir, $incdir); GetOptions("prefix=s" => \$prefix, "libdir=s" => \$libdir, "includedir=s" => \$incdir); $RLLIB = defined $libdir ? "-L$libdir" : (defined $prefix ? "-L$prefix/lib" : ''); $RLINC = defined $incdir ? "-I$incdir" : (defined $prefix ? "-I$prefix/include" : ''); } if ($Config{osname} eq 'os2') { # Check ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/ $libs = '-lreadline_import'; $defs .= ' -DOS2_USEDLL'; $lddflags = ''; } else { # if user hasn't provided RLLIB or RLINC.... # OS X uses libedit, but they've named it libreadline... # see if user has installed gnu readline via homebrew if ($Config{osname} eq 'darwin' && !($RLLIB || $RLINC)) { my $homebrew_prefix = `brew --prefix readline`; if ($homebrew_prefix) { chomp $homebrew_prefix; $RLLIB = "-L$homebrew_prefix/lib"; $RLINC = "-I$homebrew_prefix/include"; } } # Search libtermcap, libncurses, or libcurses in this order. # I emulate the behavior of the configure script for bash, and don't # know why AIX prefers curses. # libtermcap.a on HPUX cannot be used for dynamically linked binary. # Old Cygwin may require setting false (0). my $PREFER_CURSES = $Config{osname} eq 'aix' || $Config{osname} eq 'hpux' || $Config{osname} eq 'cygwin'; my $TERMCAP_LIB = (! $PREFER_CURSES && &search_lib('-ltermcap')) || &search_lib('-lncurses') || &search_lib('-lcurses'); unless ($TERMCAP_LIB) { warn "Could not find neither libtermcap.a, libncurses.a, or libcurses.\n"; exit $err; } $libs = "-lreadline $TERMCAP_LIB"; # Latest Perl in FreeBSD does not need this hack. (Dec.2002) $libs .= ' -lcrypt' if ($Config{osname} =~ /freebsd/i); $lddflags = ''; # If you are using old Cygwin, enable the following line. #$lddflags = ($Config{osname} =~ /cygwin/i) ? '-static' : ''; } # Check version of GNU Readline Library (for version 4.2 and before) { my ($rlmajorver, $rlminorver) = check_readline_version($RLINC, $RLLIB, $defs, $lddflags, $libs); if ($rlmajorver < 4 || $rlmajorver == 4 && $rlminorver <= 2) { $defs .= " -DRL_READLINE_VERSION=" . sprintf("0x%02x%02x", $rlmajorver, $rlminorver); $defs .= " -DRL_VERSION_MAJOR=$rlmajorver"; $defs .= " -DRL_VERSION_MINOR=$rlminorver"; } # to show GNU Readline Library version in CPAN Tester Reports $defs .= " -DTRG_READLINE_VERSION=" . sprintf("0x%02x%02x", $rlmajorver, $rlminorver); } # Check whether xmalloc has been renamed to _rl_malloc (Gentoo Linux) if (my $extra_defs = guess_malloc_names($RLINC, $RLLIB, $defs, $lddflags, $libs)) { $defs .= " $extra_defs"; } # generate a Makefile WriteMakefile ( ABSTRACT_FROM => 'Gnu.pm', AUTHOR => 'Hiroo HAYASHI ', NAME => 'Term::ReadLine::Gnu', LICENSE => 'perl', EXE_FILES => [ 'eg/perlsh' ], META_MERGE => { resources => { license => 'http://dev.perl.org/licenses/', homepage => 'http://sourceforge.net/projects/perl-trg/', bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Term-ReadLine-Gnu', repository => 'https://sourceforge.net/p/perl-trg/code/HEAD/tree/', }, }, VERSION_FROM => 'Gnu.pm', MIN_PERL_VERSION => '5.8.1', LIBS => [ "$RLLIB $libs" ], LDDLFLAGS => "$RLLIB $Config{lddlflags}", dynamic_lib => { OTHERLDFLAGS => $lddflags }, DEFINE => $defs, ($Config{osname} eq 'os2' ? ( IMPORTS => { xfree => 'emxlibcm.401' }, # Yuck! ) : () ), INC => $RLINC, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' }, clean => { FILES => "rlver.c rlver$Config{_exe} rlmalloc.c rlmalloc$Config{_exe}" }, ); if ($Config{usesfio} eq 'true') { warn <<'EOM'; ******************** !!!Warning!!! ********************* ** Your Perl is configured as `usesfio' equals true. ** ** Term::ReadLine::Gnu may not work with your Perl. ** ** If it works, let me know your result of `perl -V'. ** ******************************************************** EOM } exit(0); ######################################################################## # Search a library '$lib' in $Config{libpth} directories, and return # $lib if exist or undef unless exist. # ExtUtils::Liblist::ext() do similar job as this subroutine, but it # warns unnecessary messages. sub search_lib { my ($lib) = @_; unless ($lib =~ /^-l/) { warn "search_lib: illegal arguments, \`$lib\'.\n"; return undef; } my $libbase = 'lib' . substr($lib, 2) . $Config{lib_ext}; my $libbase_so = 'lib' . substr($lib, 2) . "." . $Config{so}; foreach (split(' ', $Config{libpth})) { if (-f $_ . '/' . $libbase) { # print "$_/$libbase\n"; print "Found \`$_/$libbase\'.\n"; return $lib; } elsif (-f $_ . '/' . $libbase_so) { # print "$_/$libbase_so\n"; print "Found \`$_/$libbase_so\'.\n"; return $lib; } } return undef; } ######################################################################## # Check libreadline.a version # # Readline 4.2a introduced the macro # RL_READLINE_VERSION # RL_VERSION_MAJOR # RL_VERSION_MINOR # Someday we don't need this subroutine.. sub check_readline_version { my ($RLINC, $RLLIB, $defs, $lddflags, $libs) = @_; my $frlver = 'rlver.c'; # make temp file open(F, ">$frlver") || die "Cannot open $frlver:$!\n"; print F <<'EOF'; /* used by Makefile.pl to check the version of the GNU Readline Library */ #include #include int main() { puts(rl_library_version); return 0; } EOF close(F); # compile it my $comp_cmd = "$Config{cc} $RLINC $Config{ccflags} $defs $frlver -o rlver $RLLIB $lddflags $Config{ldflags} $libs"; print $comp_cmd, "\n"; system($comp_cmd); if ($?) { warn <>>\n"; # $rlver may be '8.21-beta3', '4.2a', or etc. return $rlver =~ /(\d+)\.(\d+)/; } ######################################################################## # Check whether the xmalloc exported by readline is indeed called # 'xmalloc' or whether it has been renamed to '_rl_malloc'. # Contributed by KENTNL at cpan.org # Gentoo Linux requires this hack, because it renames xmalloc, # xrealloc, and xfree. It is not a good idea. Yes, I agree with Chet. # https://rt.cpan.org/Ticket/Display.html?id=65973 sub guess_malloc_names { my ($RLINC, $RLLIB, $defs, $lddflags, $libs) = @_; my $frlmalloc = 'rlmalloc.c'; my @symbol_sets = ( { # try defaults first # xmalloc => 'xmalloc', # xrealloc => 'xrealloc', # xfree => 'xfree', }, { xmalloc => '_rl_malloc', xrealloc => '_rl_realloc', xfree => '_rl_free', }, ); # make temp file open(my $F, ">", $frlmalloc) || die "Cannot open $frlmalloc: $!\n"; print {$F} <<'EOF'; /* used by Makefile.pl to check the names of xmalloc etc. of the GNU Readline Library */ #include #include /* we assume support for ANSI C */ extern void *xmalloc(int); extern void *xrealloc(void *, int); extern void xfree(void *); int main() { char *p; p = xmalloc(1); p[0] = 'o'; p = xrealloc(p, 3); p[1] = 'k'; p[2] = '\0'; puts(p); xfree(p); return 0; } EOF close($F); my $extra_defs; for my $symbol_set (@symbol_sets) { my $xdef = join " ", map "-D$_=$symbol_set->{$_}", sort keys %$symbol_set; # compile it my $comp_cmd = "$Config{cc} $RLINC $Config{ccflags} $defs $xdef $frlmalloc -o rlmalloc $RLLIB $lddflags $Config{ldflags} $libs"; print $comp_cmd, "\n"; unless (system($comp_cmd) || `./rlmalloc` !~ /^ok$/ || $?) { $extra_defs = $xdef; last; } } unless (defined $extra_defs) { warn <" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Term-ReadLine-Gnu", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "perl" : "5.008001" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Term-ReadLine-Gnu" }, "homepage" : "http://sourceforge.net/projects/perl-trg/", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "https://sourceforge.net/p/perl-trg/code/HEAD/tree/" } }, "version" : "1.35" } Term-ReadLine-Gnu-1.35/META.yml0000604060175006010010000000142713006645262014640 0ustar hirooNone--- abstract: 'Perl extension for the GNU Readline/History Library' author: - 'Hiroo HAYASHI ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Term-ReadLine-Gnu no_index: directory: - t - inc requires: perl: '5.008001' resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Term-ReadLine-Gnu homepage: http://sourceforge.net/projects/perl-trg/ license: http://dev.perl.org/licenses/ repository: https://sourceforge.net/p/perl-trg/code/HEAD/tree/ version: '1.35' Term-ReadLine-Gnu-1.35/ppport.h0000644060175006010010000057561612726552763015123 0ustar hirooNone#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.31 Automatically created by Devel::PPPort running under perl 5.022002. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.31 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.20. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagically add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL caller_cx() NEED_caller_cx NEED_caller_cx_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL mg_findext() NEED_mg_findext NEED_mg_findext_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL sv_unmagicext() NEED_sv_unmagicext NEED_sv_unmagicext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report here: L Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2013, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.31; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( ASCII_TO_NEED||5.007001|n AvFILLp|5.004050||p AvFILL||| BhkDISABLE||5.021008| BhkENABLE||5.021008| BhkENTRY_set||5.021008| BhkENTRY||| BhkFLAGS||| CALL_BLOCK_HOOKS||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002|5.004050|p Copy||| CvPADLIST||5.008001| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.010001||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvAV||| GvCV||| GvHV||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||5.011000| HEf_SVKEY|5.003070||p HeHASH||5.003070| HeKEY||5.003070| HeKLEN||5.003070| HePV||5.004000| HeSVKEY_force||5.003070| HeSVKEY_set||5.004000| HeSVKEY||5.003070| HeUTF8|5.010001|5.008000|p HeVAL||5.003070| HvENAMELEN||5.015004| HvENAMEUTF8||5.015004| HvENAME||5.013007| HvNAMELEN_get|5.009003||p HvNAMELEN||5.015004| HvNAMEUTF8||5.015004| HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LINKLIST||5.013006| LVRET||| MARK||| MULTICALL||5.021008| MUTABLE_PTR|5.010001||p MUTABLE_SV|5.010001||p MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002|5.004050|p Move||| NATIVE_TO_NEED||5.007001|n NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| OP_CLASS||5.013007| OP_DESC||5.007003| OP_NAME||5.007003| OP_TYPE_IS_OR_WAS||5.019010| OP_TYPE_IS||5.019007| ORIGMARK||| OpHAS_SIBLING||5.021007| OpSIBLING_set||5.021007| OpSIBLING||5.021007| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.021008||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.003070||p PERL_INT_MAX|5.003070||p PERL_INT_MIN|5.003070||p PERL_LONG_MAX|5.003070||p PERL_LONG_MIN|5.003070||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.021008||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.021008||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.021008||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.021008||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.003070||p PERL_QUAD_MIN|5.003070||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.003070||p PERL_SHORT_MIN|5.003070||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.021008| PERL_UCHAR_MAX|5.003070||p PERL_UCHAR_MIN|5.003070||p PERL_UINT_MAX|5.003070||p PERL_UINT_MIN|5.003070||p PERL_ULONG_MAX|5.003070||p PERL_ULONG_MIN|5.003070||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.003070||p PERL_UQUAD_MIN|5.003070||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.003070||p PERL_USHORT_MIN|5.003070||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.021008||p PL_bufptr|5.021008||p PL_check||5.006000| PL_compiling|5.004050||p PL_comppad_name||5.017004| PL_comppad||5.008001| PL_copline|5.021008||p PL_curcop|5.004050||p PL_curpad||5.005000| PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.021008||p PL_expect|5.021008||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.021008||p PL_in_my|5.021008||p PL_keyword_plugin||5.011002| PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.021008||p PL_lex_stuff|5.021008||p PL_linestr|5.021008||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_opfreehook||5.011000|n PL_parser|5.009005||p PL_peepp||5.007003|n PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rpeepp||5.013005|n PL_rsfp_filters|5.021008||p PL_rsfp|5.021008||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.021008||p POP_MULTICALL||5.021008| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.021008| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PadARRAY||5.021008| PadMAX||5.021008| PadlistARRAY||5.021008| PadlistMAX||5.021008| PadlistNAMESARRAY||5.021008| PadlistNAMESMAX||5.021008| PadlistNAMES||5.021008| PadlistREFCNT||5.017004| PadnameIsOUR||| PadnameIsSTATE||| PadnameLEN||5.021008| PadnameOURSTASH||| PadnameOUTER||| PadnamePV||5.021008| PadnameREFCNT_dec||5.021008| PadnameREFCNT||5.021008| PadnameSV||5.021008| PadnameTYPE||| PadnameUTF8||5.021007| PadnamelistARRAY||5.021008| PadnamelistMAX||5.021008| PadnamelistREFCNT_dec||5.021008| PadnamelistREFCNT||5.021008| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_restore_errno||| PerlIO_save_errno||| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p READ_XDIGIT||5.017006| RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_INVLIST||5.019002| SVt_IV||| SVt_NULL||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVFM||| SVt_PVGV||| SVt_PVHV||| SVt_PVIO||| SVt_PVIV||| SVt_PVLV||| SVt_PVMG||| SVt_PVNV||| SVt_PV||| SVt_REGEXP||5.011000| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_ro||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_nomg||5.013002| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg_nolen|5.013007||p SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec_NN||5.017007| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTHINKFIRST||| SvTRUE_nomg||5.013006| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.021008||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p WIDEST_UTYPE|5.015004||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_APIVERSION_BOOTCHECK||5.021008| XS_EXTERNAL||5.021008| XS_INTERNAL||5.021008| XS_VERSION_BOOTCHECK||5.021008| XS_VERSION||| XSprePUSH|5.006000||p XS||| XopDISABLE||5.021008| XopENABLE||5.021008| XopENTRYCUSTOM||5.021008| XopENTRY_set||5.021008| XopENTRY||5.021008| XopFLAGS||5.013007| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _add_range_to_invlist||| _append_range_to_invlist||| _core_swash_init||| _get_encoding||| _get_regclass_nonbitmap_data||| _get_swash_invlist||| _invlist_array_init|||n _invlist_contains_cp|||n _invlist_contents||| _invlist_dump||| _invlist_intersection_maybe_complement_2nd||| _invlist_intersection||| _invlist_invert||| _invlist_len|||n _invlist_populate_swatch|||n _invlist_search|||n _invlist_subtract||| _invlist_union_maybe_complement_2nd||| _invlist_union||| _is_cur_LC_category_utf8||| _is_in_locale_category||5.021001| _is_uni_FOO||5.017008| _is_uni_perl_idcont||5.017008| _is_uni_perl_idstart||5.017007| _is_utf8_FOO||5.017008| _is_utf8_char_slow||5.021001|n _is_utf8_idcont||5.021001| _is_utf8_idstart||5.021001| _is_utf8_mark||5.017008| _is_utf8_perl_idcont||5.017008| _is_utf8_perl_idstart||5.017007| _is_utf8_xidcont||5.021001| _is_utf8_xidstart||5.021001| _load_PL_utf8_foldclosures||| _make_exactf_invlist||| _new_invlist_C_array||| _new_invlist||| _pMY_CXT|5.007003||p _setup_canned_invlist||| _swash_inversion_hash||| _swash_to_invlist||| _to_fold_latin1||| _to_uni_fold_flags||5.014000| _to_upper_title_latin1||| _to_utf8_fold_flags||5.019009| _to_utf8_lower_flags||5.019009| _to_utf8_title_flags||5.019009| _to_utf8_upper_flags||5.019009| _warn_problematic_locale|||n aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.021008||p aTHXR|5.021008||p aTHX_|5.006000||p aTHX|5.006000||p aassign_common_vars||| add_above_Latin1_folds||| add_cp_to_invlist||| add_data|||n add_multi_match||| add_utf16_textfilter||| adjust_size_and_find_bucket|||n advance_one_SB||| advance_one_WB||| alloc_maybe_populate_EXACT||| alloccopstash||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_deref_call||5.013007| amagic_i_ncmp||| amagic_is_enabled||| amagic_ncmp||| anonymise_cv_maybe||| any_dup||| ao||| append_utf8_from_native_byte||5.019004|n apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| assert_uft8_cache_coherent||| assignment_type||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend_guts||| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_tindex||5.017009| av_top_index||5.017009| av_undef||| av_unshift||| ax|||n backup_one_SB||| backup_one_WB||| bad_type_gv||| bad_type_pv||| bind_match||| block_end||5.004000| block_gimme||5.004000| block_start||5.004000| blockhook_register||5.013003| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_cmp_utf8||5.013007| bytes_from_utf8||5.007001| bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p caller_cx|5.013005|5.006000|p calloc||5.007002|n cando||| cast_i32||5.006000|n cast_iv||5.006000|n cast_ulong||5.006000|n cast_uv||5.006000|n check_locale_boundary_crossing||| check_type_and_open||| check_uni||| check_utf8_print||| checkcomma||| ckWARN|5.006000||p ck_entersub_args_core||| ck_entersub_args_list||5.013006| ck_entersub_args_proto_or_list||5.013006| ck_entersub_args_proto||5.013006| ck_warner_d||5.011001|v ck_warner||5.011001|v ckwarn_common||| ckwarn_d||5.009003| ckwarn||5.009003| clear_placeholders||| clear_special_blocks||| clone_params_del|||n clone_params_new|||n closest_cop||| cntrl_to_mnemonic|||n compute_EXACTish|||n construct_ahocorasick_from_trie||| cop_fetch_label||5.015001| cop_free||| cop_hints_2hv||5.013007| cop_hints_fetch_pvn||5.013007| cop_hints_fetch_pvs||5.013007| cop_hints_fetch_pv||5.013007| cop_hints_fetch_sv||5.013007| cop_store_label||5.015001| cophh_2hv||5.013007| cophh_copy||5.013007| cophh_delete_pvn||5.013007| cophh_delete_pvs||5.013007| cophh_delete_pv||5.013007| cophh_delete_sv||5.013007| cophh_fetch_pvn||5.013007| cophh_fetch_pvs||5.013007| cophh_fetch_pv||5.013007| cophh_fetch_sv||5.013007| cophh_free||5.013007| cophh_new_empty||5.021008| cophh_store_pvn||5.013007| cophh_store_pvs||5.013007| cophh_store_pv||5.013007| cophh_store_sv||5.013007| core_prototype||| coresub_op||| could_it_be_a_POSIX_class|||n cr_textfilter||| create_eval_scope||| croak_memory_wrap||5.019003|n croak_no_mem|||n croak_no_modify||5.013003|n croak_nocontext|||vn croak_popstack|||n croak_sv||5.013001| croak_xs_usage||5.010001|n croak|||v csighandler||5.009003|n current_re_engine||| curse||| custom_op_desc||5.007003| custom_op_get_field||| custom_op_name||5.007003| custom_op_register||5.013007| custom_op_xop||5.013007| cv_ckproto_len_flags||| cv_clone_into||| cv_clone||| cv_const_sv_or_av|||n cv_const_sv||5.003070|n cv_dump||| cv_forget_slab||| cv_get_call_checker||5.013006| cv_name||5.021005| cv_set_call_checker_flags||5.021004| cv_set_call_checker||5.013006| cv_undef_flags||| cv_undef||| cvgv_from_hek||| cvgv_set||| cvstash_set||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.021008||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v defelem_target||| del_sv||| delete_eval_scope||| delimcpy||5.004000|n deprecate_commaless_var_list||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_sv||5.013001| die_unwind||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_close||| do_delete_local||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_ncmp||| do_oddball||| do_op_dump||5.006000| do_open6||| do_open9||5.006000| do_open_raw||| do_openn||5.007001| do_open||5.003070| do_pmop_dump||5.006000| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| drand48_init_r|||n drand48_r|||n dump_all_perl||| dump_all||5.006000| dump_c_backtrace||| dump_eval||5.006000| dump_exec_pos||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs_perl||| dump_packsubs||5.006000| dump_sub_perl||| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| filter_add||| filter_del||| filter_gets||| filter_read||| finalize_optree||| finalize_op||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_default_stash||| find_hash_subscript||| find_in_my_stash||| find_lexical_cv||| find_runcv_where||| find_runcv||5.008001| find_rundefsv2||| find_rundefsvoffset||5.009002| find_rundefsv||5.013002| find_script||| find_uninit_var||| first_symbol|||n fixup_errno_string||| foldEQ_latin1||5.013008|n foldEQ_locale||5.013002|n foldEQ_utf8_flags||5.013010| foldEQ_utf8||5.013002| foldEQ||5.013002|n fold_constants||| forbid_setid||| force_ident_maybe_lex||| force_ident||| force_list||| force_next||| force_strict_version||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form_short_octal_warning||| form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_c_backtrace||| free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_ANYOF_cp_list_for_ssc||| get_and_check_backslash_N_name||| get_aux_mg||| get_av|5.006000||p get_c_backtrace_dump||| get_c_backtrace||| get_context||5.006000|n get_cvn_flags|5.009005||p get_cvs|5.011000||p get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_invlist_iter_addr|||n get_invlist_offset_addr|||n get_invlist_previous_index_addr|||n get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| gp_dup||| gp_free||| gp_ref||| grok_atoUV|||n grok_bin|5.007003||p grok_bslash_N||| grok_bslash_c||| grok_bslash_o||| grok_bslash_x||| grok_hex|5.007003||p grok_infnan||5.021004| grok_number_flags||5.021002| grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_add_by_type||5.011000| gv_autoload4||5.004000| gv_autoload_pvn||5.015004| gv_autoload_pv||5.015004| gv_autoload_sv||5.015004| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.003070| gv_efullname4||5.006001| gv_efullname||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmeth_internal||| gv_fetchmeth_pv_autoload||5.015004| gv_fetchmeth_pvn_autoload||5.015004| gv_fetchmeth_pvn||5.015004| gv_fetchmeth_pv||5.015004| gv_fetchmeth_sv_autoload||5.015004| gv_fetchmeth_sv||5.015004| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_pv_flags||5.015004| gv_fetchmethod_pvn_flags||5.015004| gv_fetchmethod_sv_flags||5.015004| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv|5.009002||p gv_fullname3||5.003070| gv_fullname4||5.006001| gv_fullname||| gv_handler||5.007001| gv_init_pvn||5.015004| gv_init_pv||5.015004| gv_init_svtype||| gv_init_sv||5.015004| gv_init||| gv_is_in_main||| gv_magicalize_isa||| gv_magicalize||| gv_name_set||5.009004| gv_override||| gv_setref||| gv_stashpvn_internal||| gv_stashpvn|5.003070||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsvpvn_cached||| gv_stashsv||| gv_try_downgrade||| handle_regex_sets||| he_dup||| hek_dup||| hfree_next_entry||| hfreeentries||| hsplit||| hv_assert||| hv_auxinit_internal|||n hv_auxinit||| hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||5.009004| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.003070| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_ename_add||| hv_ename_delete||| hv_exists_ent||5.003070| hv_exists||| hv_fetch_ent||5.003070| hv_fetchs|5.009003||p hv_fetch||| hv_fill||5.013002| hv_free_ent_ret||| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.003070| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.003070| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||| hv_placeholders_set||5.009003| hv_rand_set||5.018000| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.003070| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef_flags||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_constants||| init_dbargs||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| inplace_aassign||| instr|||n intro_my||5.004000| intuit_method||| intuit_more||| invert||| invlist_array|||n invlist_clone||| invlist_extend||| invlist_highest|||n invlist_is_iterating|||n invlist_iterfinish|||n invlist_iterinit|||n invlist_iternext|||n invlist_max|||n invlist_previous_index|||n invlist_set_len||| invlist_set_previous_index|||n invlist_trim|||n invoke_exception_hook||| io_close||| isALNUMC|5.006000||p isALNUM_lazy||5.021001| isALPHANUMERIC||5.017008| isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isFOO_lc||| isFOO_utf8_lc||| isGCB|||n isGRAPH|5.006000||p isGV_with_GP|5.009004||p isIDCONT||5.017008| isIDFIRST_lazy||5.021001| isIDFIRST||| isLOWER||| isOCTAL||5.013005| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSB||| isSPACE||| isUPPER||| isUTF8_CHAR||5.021001| isWB||| isWORDCHAR||5.013006| isXDIGIT|5.006000||p is_an_int||| is_ascii_string||5.011000| is_handle_constructor|||n is_invariant_string||5.021007|n is_lvalue_sub||5.007001| is_safe_syscall||5.019004| is_ssc_worth_it|||n is_uni_alnum_lc||5.006000| is_uni_alnumc_lc||5.017007| is_uni_alnumc||5.017007| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_blank_lc||5.017002| is_uni_blank||5.017002| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_alnumc||5.017007| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_blank||5.017002| is_utf8_char_buf||5.015008|n is_utf8_char||5.006000|n is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_perl_space||5.011001| is_utf8_perl_word||5.011001| is_utf8_posix_digit||5.011001| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003|n is_utf8_string_loc||5.008001|n is_utf8_string||5.006001|n is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| is_utf8_xidcont||5.013010| is_utf8_xidfirst||5.013010| isa_lookup||| isinfnansv||| isinfnan||5.021004|n items|||n ix|||n jmaybe||| join_exact||| keyword_plugin_standard||| keyword||| leave_common||| leave_scope||| lex_bufutf8||5.011002| lex_discard_to||5.011002| lex_grow_linestr||5.011002| lex_next_chunk||5.011002| lex_peek_unichar||5.011002| lex_read_space||5.011002| lex_read_to||5.011002| lex_read_unichar||5.011002| lex_start||5.009005| lex_stuff_pvn||5.011002| lex_stuff_pvs||5.013005| lex_stuff_pv||5.013006| lex_stuff_sv||5.011002| lex_unstuff||5.011002| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.010001||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.010001||p mXPUSHu|5.009002||p magic_clear_all_env||| magic_cleararylen_p||| magic_clearenv||| magic_clearhints||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_copycallchecker||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdebugvar||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_methcall1||| magic_methcall|||v magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdebugvar||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setlvref||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||5.021001| matcher_matches_sv||| maybe_multimagic_gv||| mayberelocate||| measure_struct||| memEQs|5.009005||p memEQ|5.004000||p memNEs|5.009005||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess_sv||5.013001| mess||5.006000|v mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_find_mglob||| mg_findext|5.013008||pn mg_find|||n mg_free_type||5.013006| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical|||n mg_set||| mg_size||5.005000| mini_mktime||5.007002|n minus_v||| missingterm||| mode_from_discipline||| modkids||| more_bodies||| more_sv||| moreswitches||| move_proto_attr||| mro_clean_isarev||| mro_gather_and_rename||| mro_get_from_name||5.010001| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.010001| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_package_moved||| mro_register||5.010001| mro_set_mro||5.010001| mro_set_private_data||5.010001| mul128||| mulexp10|||n multideref_stringify||| my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_bytes_to_utf8|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005|n my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_kid||| my_lstat_flags||| my_lstat||5.021008| my_memcmp|||n my_memset|||n my_pclose||5.003070| my_popen_list||5.007001| my_popen||5.003070| my_setenv||| my_setlocale||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat_flags||| my_stat||5.021008| my_strerror||5.021001| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB_x||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB_flags||5.015006| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||5.021006| newFORM||| newFOROP||5.013007| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen_flags||5.015004| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMETHOP_internal||| newMETHOP_named||5.021005| newMETHOP||5.021005| newMYSUB||5.017004| newNULLLIST||| newOP||| newPADNAMELIST||5.021007|n newPADNAMEouter||5.021007|n newPADNAMEpvn||5.021007|n newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSTUB||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVavdefelem||| newSVhek||5.009003| newSViv||| newSVnv||| newSVpadname||5.017004| newSVpv_share||5.013006| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.010001||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.010001||p newSVpvn|5.004050||p newSVpvs_flags|5.010001||p newSVpvs_share|5.009003||p newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newUNOP_AUX||5.021007| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.013007| newXS_deffile||| newXS_flags||5.009004| newXS_len_flags||| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr|||n no_bareword_allowed||| no_fh_allowed||| no_op||| noperl_die|||vn not_a_number||| not_incrementable||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n oopsAV||| oopsHV||| op_append_elem||5.013006| op_append_list||5.013006| op_clear||| op_contextualize||5.013006| op_convert_list||5.021006| op_dump||5.006000| op_free||| op_integerize||| op_linklist||5.013006| op_lvalue_flags||| op_lvalue||5.013007| op_null||5.007002| op_parent||5.021002|n op_prepend_elem||5.013006| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_relocate_sv||| op_scope||5.013007| op_sibling_splice||5.021002|n op_std_init||| op_unscope||| open_script||| openn_cleanup||| openn_setup||| opmethod_stash||| opslab_force_free||| opslab_free_nopad||| opslab_free||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package_version||| package||| packlist||5.008001| pad_add_anon||5.008001| pad_add_name_pvn||5.015001| pad_add_name_pvs||5.015001| pad_add_name_pv||5.015001| pad_add_name_sv||5.015001| pad_add_weakref||| pad_alloc_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||5.009003| pad_findlex||| pad_findmy_pvn||5.015001| pad_findmy_pvs||5.015001| pad_findmy_pv||5.015001| pad_findmy_sv||5.015001| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||5.008001| pad_push||| pad_reset||| pad_setsv||| pad_sv||| pad_swipe||| pad_tidy||5.008001| padlist_dup||| padlist_store||| padname_dup||| padname_free||| padnamelist_dup||| padnamelist_fetch||5.021007|n padnamelist_free||| padnamelist_store||5.021007| parse_arithexpr||5.013008| parse_barestmt||5.013007| parse_block||5.013007| parse_body||| parse_fullexpr||5.013008| parse_fullstmt||5.013005| parse_gv_stash_name||| parse_ident||| parse_label||5.013007| parse_listexpr||5.013008| parse_lparen_question_flags||| parse_stmtseq||5.013006| parse_subsignature||| parse_termexpr||5.013008| parse_unicode_opts||| parser_dup||| parser_free_nexttoke_ops||| parser_free||| path_is_searchable|||n peep||| pending_ident||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmop_dump||5.006000| pmruntime||| pmtrans||| pop_scope||| populate_ANYOF_from_invlist||| populate_isa|||v pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prescan_version||5.011004| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_hash|||n ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_charclass_bitmap_innards||| put_code_point||| put_range||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| quadmath_format_needed|||n quadmath_format_single|||n re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.019001| re_intuit_string||5.006000| re_op_compile||| realloc||5.007002|n reentrant_free||5.021008| reentrant_init||5.021008| reentrant_retry||5.021008|vn reentrant_size||5.021008| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch_pvn||| refcounted_he_fetch_pvs||| refcounted_he_fetch_pv||| refcounted_he_fetch_sv||| refcounted_he_free||| refcounted_he_inc||| refcounted_he_new_pvn||| refcounted_he_new_pvs||| refcounted_he_new_pv||| refcounted_he_new_sv||| refcounted_he_value||| refkids||| refto||| ref||5.021008| reg2Lanode||| reg_check_named_buff_matched|||n reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment|||n reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly|||n regdump_extflags||| regdump_intflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regnode_guts||| regpatws|||n regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reg||| repeatcpy|||n report_evil_fh||| report_redefined_cv||| report_uninit||| report_wrongway_fh||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr|||n rpeep||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rv2cv_op_cv||5.013006| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem_flags||5.011000| save_aelem||5.004050| save_aliased_sv||| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hdelete||5.011000| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||5.010001| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic_flags||| save_mortalizesv||5.007001| save_nogv||| save_op||5.005000| save_padsv_and_mortalize||5.010001| save_pptr||| save_pushi32ptr||5.010001| save_pushptri32ptr||| save_pushptrptr||5.010001| save_pushptr||5.010001| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_strlen||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpvs||5.013006| savesharedpv||5.007003| savesharedsvpv||5.013006| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| search_const||| seed||5.008001| sequence_num||| set_ANYOF_arg||| set_caret_X||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| set_padlist|||n setdefout||| share_hek_flags||| share_hek||5.004000| should_warn_nl|||n si_dup||| sighandler|||n simplify_sort||| skipspace_flags||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| ssc_add_range||| ssc_and||| ssc_anything||| ssc_clear_locale|||n ssc_cp_and||| ssc_finalize||| ssc_init||| ssc_intersection||| ssc_is_anything|||n ssc_is_cp_posixl_init|||n ssc_or||| ssc_union||| stack_grow||| start_glob||| start_subparse||5.004000| stdize_locale||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool_flags||5.013006| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv_flags||5.013001| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff|||n sv_bless||| sv_buf_to_ro||| sv_buf_to_rw||| sv_cat_decode||5.008001| sv_catpv_flags||5.013006| sv_catpv_mg|5.004050||p sv_catpv_nomg||5.013006| sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs_flags||5.013006| sv_catpvs_mg||5.013006| sv_catpvs_nomg||5.013006| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_flags||5.013006| sv_cmp_locale_flags||5.013006| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm_flags||5.013006| sv_collxfrm||| sv_copypv_flags||5.017002| sv_copypv_nomg||5.017002| sv_copypv||| sv_dec_nomg||5.013002| sv_dec||| sv_del_backref||| sv_derived_from_pvn||5.015004| sv_derived_from_pv||5.015004| sv_derived_from_sv||5.015004| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_display||| sv_does_pvn||5.015004| sv_does_pv||5.015004| sv_does_sv||5.015004| sv_does||5.009004| sv_dump||| sv_dup_common||| sv_dup_inc_multiple||| sv_dup_inc||| sv_dup||| sv_eq_flags||5.013006| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_get_backrefs||5.021008|n sv_gets||5.003070| sv_grow||| sv_i_ncmp||| sv_inc_nomg||5.013002| sv_inc||| sv_insert_flags||5.010001| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8_nomg||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.021008|5.004000|p sv_magicext_mglob||| sv_magicext||5.007003| sv_magic||| sv_mortalcopy_flags||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_only_taint_gmagic|||n sv_or_pv_pos_u2b||| sv_peek||5.005000| sv_pos_b2u_flags||5.019003| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_flags||5.011005| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_ref||| sv_release_COW||| sv_replace||| sv_report_used||| sv_resetpvn||| sv_reset||| sv_rvweaken||5.006000| sv_sethek||| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs_mg||5.013006| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pvs||5.021008| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagicext|5.013008||p sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn_flags||5.017002| sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p svtype||| swallow_bom||| swash_fetch||5.007002| swash_init||5.006000| swash_scan_list_line||| swatch_get||| sync_locale||5.021004| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tied_method|||v tmps_grow_p||| toFOLD_uni||5.007003| toFOLD_utf8||5.019001| toFOLD||5.019001| toLOWER_L1||5.019001| toLOWER_LC||5.004000| toLOWER_uni||5.007003| toLOWER_utf8||5.015007| toLOWER||| toTITLE_uni||5.007003| toTITLE_utf8||5.015007| toTITLE||5.019001| toUPPER_uni||5.007003| toUPPER_utf8||5.015007| toUPPER||| to_byte_substr||| to_lower_latin1|||n to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.015007| to_utf8_lower||5.015007| to_utf8_substr||| to_utf8_title||5.015007| to_utf8_upper||5.015007| tokenize_use||| tokeq||| tokereport||| too_few_arguments_pv||| too_many_arguments_pv||| translate_substr_offsets|||n try_amagic_bin||| try_amagic_un||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unreferenced_to_tmp_stack||| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.003070| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_textfilter||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000|n utf8_length||5.007001| utf8_mg_len_cache_update||| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr_buf||5.015009| utf8_to_uvchr||5.007001| utf8_to_uvuni_buf||5.015009| utf8_to_uvuni||5.007001| utf8n_to_uvchr||5.007001| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||5.007001| uvoffuni_to_utf8_flags||5.019004| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| valid_utf8_to_uvchr||5.015009| valid_utf8_to_uvuni||5.015009| validate_proto||| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warn_sv||5.013001| warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v was_lvalue_sub||| watch||| whichsig_pvn||5.015004| whichsig_pv||5.015004| whichsig_sv||5.015004| whichsig||| win32_croak_not_implemented|||n with_queued_errors||| wrap_op_checker||5.015008| write_to_stderr||| xs_boot_epilog||| xs_handshake|||vn xs_version_bootcheck||| yyerror_pvn||| yyerror_pv||| yyerror||| yylex||| yyparse||| yyunlex||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef LONGSIZE # define LONGSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef LONGSIZE # define LONGSIZE 4 #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef memEQs # define memEQs(s1, l, s2) \ (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) #endif #ifndef memNEs # define memNEs(s1, l, s2) !memEQs(s1, l, s2) #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifdef HAS_QUAD # ifdef U64TYPE # define WIDEST_UTYPE U64TYPE # else # define WIDEST_UTYPE Quad_t # endif #else # define WIDEST_UTYPE U32 #endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((WIDEST_UTYPE) (c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((WIDEST_UTYPE) (c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif /* Until we figure out how to support this in older perls... */ #if (PERL_BCDVERSION >= 0x5008000) #ifndef HeUTF8 # define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \ SvUTF8(HeKEY_sv(he)) : \ (U32)HeKUTF8(he)) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #elif (PERL_BCDVERSION > 0x5003000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # elif IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # else # error "cannot define IV/UV formats" # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_nomg_nolen # define SvPV_nomg_nolen(sv) ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, 0)) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif /* Hint: newSVpvn_share * The SVs created by this function only mimic the behaviour of * shared PVs without really being shared. Only use if you know * what you're doing. */ #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchsv # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt) #endif #ifndef get_cvn_flags # define get_cvn_flags(name, namelen, flags) get_cv(name, flags) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef newSVpvs_share # define newSVpvs_share(str) newSVpvn_share(str "", sizeof(str) - 1, 0) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef get_cvs # define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif /* Some random bits for sv_unmagicext. These should probably be pulled in for real and organized at some point */ #ifndef HEf_SVKEY # define HEf_SVKEY -2 #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) # define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) #else # define MUTABLE_PTR(p) ((void *) (p)) #endif #define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) /* end of random bits */ #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #if !defined(mg_findext) #if defined(NEED_mg_findext) static MAGIC * DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl); static #else extern MAGIC * DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl); #endif #define mg_findext DPPP_(my_mg_findext) #define Perl_mg_findext DPPP_(my_mg_findext) #if defined(NEED_mg_findext) || defined(NEED_mg_findext_GLOBAL) MAGIC * DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl) { if (sv) { MAGIC *mg; #ifdef AvPAD_NAMELIST assert(!(SvTYPE(sv) == SVt_PVAV && AvPAD_NAMELIST(sv))); #endif for (mg = SvMAGIC (sv); mg; mg = mg->mg_moremagic) { if (mg->mg_type == type && mg->mg_virtual == vtbl) return mg; } } return NULL; } #endif #endif #if !defined(sv_unmagicext) #if defined(NEED_sv_unmagicext) static int DPPP_(my_sv_unmagicext)(pTHX_ SV * const sv, const int type, MGVTBL * vtbl); static #else extern int DPPP_(my_sv_unmagicext)(pTHX_ SV * const sv, const int type, MGVTBL * vtbl); #endif #ifdef sv_unmagicext # undef sv_unmagicext #endif #define sv_unmagicext(a,b,c) DPPP_(my_sv_unmagicext)(aTHX_ a,b,c) #define Perl_sv_unmagicext DPPP_(my_sv_unmagicext) #if defined(NEED_sv_unmagicext) || defined(NEED_sv_unmagicext_GLOBAL) int DPPP_(my_sv_unmagicext)(pTHX_ SV *const sv, const int type, MGVTBL *vtbl) { MAGIC* mg; MAGIC** mgp; if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv)) return 0; mgp = &(SvMAGIC(sv)); for (mg = *mgp; mg; mg = *mgp) { const MGVTBL* const virt = mg->mg_virtual; if (mg->mg_type == type && virt == vtbl) { *mgp = mg->mg_moremagic; if (virt && virt->svt_free) virt->svt_free(aTHX_ sv, mg); if (mg->mg_ptr && mg->mg_type != PERL_MAGIC_regex_global) { if (mg->mg_len > 0) Safefree(mg->mg_ptr); else if (mg->mg_len == HEf_SVKEY) /* Questionable on older perls... */ SvREFCNT_dec(MUTABLE_SV(mg->mg_ptr)); else if (mg->mg_type == PERL_MAGIC_utf8) Safefree(mg->mg_ptr); } if (mg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(mg->mg_obj); Safefree(mg); } else mgp = &mg->mg_moremagic; } if (SvMAGIC(sv)) { if (SvMAGICAL(sv)) /* if we're under save_magic, wait for restore_magic; */ mg_magical(sv); /* else fix the flags now */ } else { SvMAGICAL_off(sv); SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; } return 0; } #endif #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #if (PERL_BCDVERSION >= 0x5006000) #ifndef caller_cx # if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) static I32 DPPP_dopoptosub_at(const PERL_CONTEXT *cxstk, I32 startingblock) { I32 i; for (i = startingblock; i >= 0; i--) { register const PERL_CONTEXT * const cx = &cxstk[i]; switch (CxTYPE(cx)) { default: continue; case CXt_EVAL: case CXt_SUB: case CXt_FORMAT: return i; } } return i; } # endif # if defined(NEED_caller_cx) static const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp); static #else extern const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp); #endif #ifdef caller_cx # undef caller_cx #endif #define caller_cx(a,b) DPPP_(my_caller_cx)(aTHX_ a,b) #define Perl_caller_cx DPPP_(my_caller_cx) #if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp) { register I32 cxix = DPPP_dopoptosub_at(cxstack, cxstack_ix); register const PERL_CONTEXT *cx; register const PERL_CONTEXT *ccstack = cxstack; const PERL_SI *top_si = PL_curstackinfo; for (;;) { /* we may be in a higher stacklevel, so dig down deeper */ while (cxix < 0 && top_si->si_type != PERLSI_MAIN) { top_si = top_si->si_prev; ccstack = top_si->si_cxstack; cxix = DPPP_dopoptosub_at(ccstack, top_si->si_cxix); } if (cxix < 0) return NULL; /* caller() should not report the automatic calls to &DB::sub */ if (PL_DBsub && GvCV(PL_DBsub) && cxix >= 0 && ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) count++; if (!count--) break; cxix = DPPP_dopoptosub_at(ccstack, cxix - 1); } cx = &ccstack[cxix]; if (dbcxp) *dbcxp = cx; if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) { const I32 dbcxix = DPPP_dopoptosub_at(ccstack, cxix - 1); /* We expect that ccstack[dbcxix] is CXt_SUB, anyway, the field below is defined for any cx. */ /* caller() should not report the automatic calls to &DB::sub */ if (PL_DBsub && GvCV(PL_DBsub) && dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub)) cx = &ccstack[dbcxix]; } return cx; } # endif #endif /* caller_cx */ #endif /* 5.6.0 */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%" UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%" UVxf "}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ Term-ReadLine-Gnu-1.35/README0000644060175006010010000000530212443220610014235 0ustar hirooNone -*- Indented-text -*- $Id: README 477 2014-12-14 05:35:36Z hayashi $ Term::ReadLine::Gnu --- GNU Readline Library Wrapper Module Copyright (c) 1996 Hiroo Hayashi. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Description: Term::ReadLine::Gnu (TRG) is an implementation of the interface to the GNU Readline Library. This module gives you input line editing facility, input history management facility, word completion facility, etc. It uses the real GNU Readline Library and has the interface with the almost all variables and functions which are documented in the GNU Readline/History Library. So you can program your custom editing function, your custom completion function, and so on with Perl. TRG may be useful for a C programmer to prototype a program which uses the GNU Readline Library. TRG is upper compatible with Term::ReadLine included in Perl distribution. Term::ReadLine uses TRG automatically when TRG is available. You can enjoy full line editing feature with Perl debugger which use Term::ReadLine with no patch. Ilya Zakharevich distributes his implementation, Term::ReadLine::Perl, which bases on Jeffrey Friedl's readline.pl. His module works very well, and is easy to install because it is written by only Perl. I am trying to make my module compatible with his. He gives useful advises for me. Unfortunately readline.pl simulated old GNU Readline library before TRG was born. For example, it was not 8 bit clean and it warns to the variables in ~/.inputrc which it did not know yet. We Japanese usually use 8 bit characters, so this was bad feature for me. I could make a patch for these problems but I had interest with C interface facility and dynamic loading facility of Perl, so I thought it was a good chance for me to study them. Then I made this module instead of fixing his module. Prerequisites: You must have Perl 5.8 or later. If you have to use old Perl for some reason, use Term::ReadLine::Gnu 1.09. (I recommend you to use newer Perl.) You must have GNU Readline Library Version 2.1 or later. See INSTALL for more detail. A report said GNU Readline Library might not work with perl with sfio. Since I do not have sfio library, I am not sure. How to build/install: See INSTALL. Bugs: There may be many bugs in both programs and documents. Comments and bug reports are very welcome. Send me a E-Mail or open a ticket on the bug tracker at rt.cpan.org; http://rt.cpan.org/Dist/Display.html?Queue=Term-ReadLine-Gnu Author: Hiroo Hayashi Project Home Page http://sourceforge.net/projects/perl-trg/ Revision History: See Changes. Term-ReadLine-Gnu-1.35/t/0000755060175006010010000000000013006645261013631 5ustar hirooNoneTerm-ReadLine-Gnu-1.35/t/00checkver.t0000644060175006010010000000206212717114543015752 0ustar hirooNone# -*- perl -*- # 00check.t - check versions # # $Id: 00checkver.t 518 2016-05-18 16:33:37Z hayashi $ # # Copyright (c) 2008-2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. use strict; use warnings; use Test::More tests => 4; use vars qw($loaded); BEGIN { $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu } END { unless ($loaded) { ok(0, 'fail before loading'); diag "\nPlease report the output of \'perl Makefile.PL\'\n"; } } use Term::ReadLine; ok(1, 'load done'); $loaded = 1; print "# I'm testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION\n"; my $t = new Term::ReadLine 'ReadLineTest'; isa_ok($t, 'Term::ReadLine'); my $a = $t->Attribs; isa_ok($a, 'Term::ReadLine', 'Attribs'); print "# OS: $^O\n"; print "# Perl version: $]\n"; printf "# GNU Readline Library version: $a->{library_version}, 0x%X\n", $a->{readline_version}; print "# \$TERM=$ENV{TERM}\n"; ok(1, 'library_version and readline_version'); exit 0; Term-ReadLine-Gnu-1.35/t/callback.t0000644060175006010010000000630412717257643015570 0ustar hirooNone# -*- perl -*- # callback.t - Test script for Term::ReadLine:GNU callback function # # $Id: callback.t 521 2016-05-19 06:39:31Z hayashi $ # # Copyright (c) 1999-2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. use strict; use warnings; use Test::More tests => 8; # redefine Test::Mode::note due to it requires Perl 5.10.1. no warnings 'redefine'; sub note { my $msg = join('', @_); $msg =~ s{\n(?!\z)}{\n# }sg; print "# $msg" . ($msg =~ /\n$/ ? '' : "\n"); } use warnings 'redefine'; BEGIN { $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu } # 'define @ARGV' is deprecated my $verbose = scalar @ARGV && ($ARGV[0] eq 'verbose'); use Term::ReadLine; ok(1, 'load done'); ######################################################################## # test new method my $term = new Term::ReadLine 'ReadLineTest'; isa_ok($term, 'Term::ReadLine'); my $attribs = $term->Attribs; isa_ok($attribs, 'Term::ReadLine', 'Attribs'); my ($version) = $attribs->{library_version} =~ /(\d+\.\d+)/; ######################################################################## # check Tk is installed and X Window is available { if (eval "use Tk; 1" && $ENV{DISPLAY} && $ENV{DISPLAY} ne '') { ok(1, 'use Tk'); } else { diag 'skipped since Tk is not available.'; ok(1, 'skipped since Tk is not available') for 1..5; exit 0; } } ######################################################################## # setup IO stream my ($IN, $OUT); if ($verbose) { # wait for Perl Tk script from tty $IN = $attribs->{instream}; $OUT = $attribs->{outstream}; } else { # non-interactive test # to surpress warning on GRL 4.2a (and above?). $attribs->{prep_term_function} = sub {} if ($version > 4.1); $attribs->{instream} = $IN = \*DATA; open(NULL, '>/dev/null') or die "cannot open \`/dev/null\': $!\n"; $attribs->{outstream} = $OUT = \*NULL; } ######################################################################## my $mw; $mw = eval { new MainWindow; }; isa_ok($mw, 'MainWindow') or die "Cannot continue...\n"; # create file event handler $mw->fileevent($IN, 'readable', $attribs->{callback_read_char}); ok(1, 'callback_read_char'); $term->callback_handler_install("> ", sub { my $line = shift; quit() unless defined $line; note $line unless $verbose; eval $line; print $OUT "$@\n" if $@; }); # skip not to overwrite command prompt in the verbose mode ok(1, 'callback_handler_install') unless $verbose; # create Window Manager Delete Window ClientMessage event handler $mw->protocol('WM_DELETE_WINDOW' => \&quit); &MainLoop; sub quit { note 'quitting...'; # delayed. See above. ok(1, 'callback_handler_install') if $verbose; # delete event handler $mw->fileevent($IN, 'readable', ''); $term->callback_handler_remove(); $mw->destroy; ok(1, 'callback_handler_remove and destroy'); unless ($verbose) { # Be quiet during CPAN Testers testing. diag "Try \`$^X -Mblib t/callback.t verbose\', if you will.\n" if (!$ENV{AUTOMATED_TESTING}); } exit 0; } __END__ $b=$mw->Button(-text=>'hello',-command=>sub{print $OUT 'hello'}) $b->pack; Term-ReadLine-Gnu-1.35/t/comptest/0000755060175006010010000000000013006645261015467 5ustar hirooNoneTerm-ReadLine-Gnu-1.35/t/comptest/01230000644060175006010010000000000012273446720015771 0ustar hirooNoneTerm-ReadLine-Gnu-1.35/t/comptest/0123450000644060175006010010000000000012273446720016142 0ustar hirooNoneTerm-ReadLine-Gnu-1.35/t/comptest/0234560000644060175006010010000000000012273446720016147 0ustar hirooNoneTerm-ReadLine-Gnu-1.35/t/comptest/a_b0000644060175006010010000000000012273446720016125 0ustar hirooNoneTerm-ReadLine-Gnu-1.35/t/comptest/README0000644060175006010010000000014512273446720016353 0ustar hirooNoneThis directory is for filename completion test. The size of most of files in this directory is zero. Term-ReadLine-Gnu-1.35/t/history.t0000644060175006010010000003262512721620341015522 0ustar hirooNone# -*- perl -*- # history.t --- Term::ReadLine:GNU History Library Test Script # # $Id: history.t 524 2016-05-26 16:14:26Z hayashi $ # # Copyright (c) 1998-2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl t/history.t' use strict; use warnings; use Test::More tests => 88; # redefine Test::Mode::note due to it requires Perl 5.10.1. no warnings 'redefine'; sub note { my $msg = join('', @_); $msg =~ s{\n(?!\z)}{\n# }sg; print "# $msg" . ($msg =~ /\n$/ ? '' : "\n"); } use warnings 'redefine'; BEGIN { $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu $ENV{LC_ALL} = 'C'; } sub show_indices; # for debugging use Term::ReadLine; ok(1, 'load done'); note "Testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION"; ######################################################################## # test new method my $t = new Term::ReadLine 'ReadLineTest'; isa_ok($t, 'Term::ReadLine'); my $OUT = $t->OUT || \*STDOUT; ######################################################################## # test ReadLine method ok($t->ReadLine eq 'Term::ReadLine::Gnu', '$t->ReadLine'); ######################################################################## # test Attribs method use vars qw($attribs); $attribs = $t->Attribs; isa_ok($attribs, 'Term::ReadLine', 'Attribs'); my ($version) = $attribs->{library_version} =~ /(\d+\.\d+)/; ######################################################################## note "2.3.1 Initializing History and State Management"; # test using_history # This is verbose since 'new' has already initialized the GNU history library. $t->using_history; # history_get_history_state, history_set_history_state { ok($attribs->{history_length} == 0, 'history_get/set_history_state'); my $state = $t->history_get_history_state(); isa_ok($state, 'HISTORY_STATEPtr'); $attribs->{history_length} = 10; ok($attribs->{history_length} == 10, 'history_get/set_history_state'); $t->history_set_history_state($state); ok($attribs->{history_length} == 0, 'history_get/set_history_state'); } # check the values of initialized variables ok($attribs->{history_base} == 1, 'history_base'); ok($attribs->{history_length} == 0, 'history_length'); ok($attribs->{max_input_history} == 0, 'max_input_history'); ok($attribs->{history_max_entries} == 0, 'history_max_entries'); ok($attribs->{history_write_timestamps} == 0, 'history_write_timestamps'); ok($attribs->{history_expansion_char} eq '!', 'history_expansion_char'); ok($attribs->{history_subst_char} eq '^', 'history_subst_char'); ok($attribs->{history_comment_char} eq "\0", 'history_comment_char'); ok($attribs->{history_word_delimiters} eq " \t\n;&()|<>", 'history_word_delimiters'); ok($attribs->{history_no_expand_chars} eq " \t\n\r=", 'history_no_expand_chars'); ok(!defined $attribs->{history_search_delimiter_chars}, 'history_search_delimiter_chars'); ok($attribs->{history_quotes_inhibit_expansion} == 0, 'history_quotes_inhibit_expansion'); ok(!defined $attribs->{history_inhibit_expansion_function}, 'history_inhibit_expansion_function'); ######################################################################## note "2.3.2 History List Management"; my @list_set; # default value of `history_base' is 1 @list_set = qw(one two two three); show_indices; # test SetHistory(), GetHistory() $t->SetHistory(@list_set); is_deeply(\@list_set, [$t->GetHistory], 'SetHistory, GetHistory'); show_indices; # test add_history(), add_history_time!!! $t->add_history('four'); push(@list_set, 'four'); is_deeply(\@list_set, [$t->GetHistory], 'add_history'); show_indices; # test remove_history() $t->remove_history(2); splice(@list_set, 2, 1); is_deeply(\@list_set, [$t->GetHistory], 'remove_history'); show_indices; # test replace_history_entry() $t->replace_history_entry(3, 'daarn'); splice(@list_set, 3, 1, 'daarn'); is_deeply(\@list_set, [$t->GetHistory], 'replace_history_entry'); show_indices; # clear_history() is tested below. # stifle_history ok($t->history_is_stifled == 0, 'history_is_stifled'); $t->stifle_history(3); ok($t->history_is_stifled == 1 && $attribs->{history_length} == 3 && $attribs->{max_input_history} == 3, 'history_is_stifled'); #print "@{[$t->GetHistory]}\n"; show_indices; # history_is_stifled() $t->add_history('five'); ok($t->history_is_stifled == 1 && $attribs->{history_length} == 3, 'history_is_stifled'); show_indices; # unstifle_history() $t->unstifle_history; ok($t->history_is_stifled == 0 && $attribs->{history_length} == 3, 'unstifle_history'); #print "@{[$t->GetHistory]}\n"; show_indices; # history_is_stifled() $t->add_history('six'); ok($t->history_is_stifled == 0 && $attribs->{history_length} == 4, 'history_is_stifled'); show_indices; # clear_history() $t->clear_history; ok($attribs->{history_length} == 0, 'clear_history'); show_indices; ######################################################################## note "2.3.3 Information About the History List"; $attribs->{history_base} = 0; show_indices; @list_set = qw(zero one two three four); $t->stifle_history(4); show_indices; $t->SetHistory(@list_set); show_indices; # history_list() # history_list() routine emulates history_list() function in # GNU Readline Library. splice(@list_set, 0, 1); is_deeply(\@list_set, [$t->history_list], 'history_list'); show_indices; # at first where_history() returns 0 ok($t->where_history == 0, 'where_history'); # current_history() # history_base + 0 = 1 ok($t->current_history eq 'one', 'current_history'); # history_get()!!!, history_get_time()!!! # history_total_bytes() ok($t->history_total_bytes == 15, 'history_total_bytes'); ######################################################################## note "2.3.4 Moving Around the History List"; # history_set_pos() $t->history_set_pos(2); ok($t->where_history == 2, 'history_set_pos'); # history_base + 2 = 3 ok($t->current_history eq 'three'); show_indices; $t->history_set_pos(10000); # should be ingored ok($t->where_history == 2); # previous_history() ok($t->previous_history eq 'two', 'previous_history'); ok($t->where_history == 1); show_indices; ok($t->previous_history eq 'one'); show_indices; ok(! defined $t->previous_history); show_indices; # next_history() ok($t->next_history eq 'two', 'next_history'); show_indices; ok($t->next_history eq 'three'); show_indices; ok($t->next_history eq 'four'); show_indices; ok(! defined $t->next_history); ok($t->where_history == 4); show_indices; ######################################################################## note "2.3.5 Searching the History List"; @list_set = ('red yellow', 'green red', 'yellow blue', 'green blue'); $t->SetHistory(@list_set); $t->history_set_pos(1); #show_indices; # history_search() ok($t->history_search('red', -1) == 6 && $t->where_history == 1, 'history_search'); ok($t->history_search('blue', -1) == -1 && $t->where_history == 1); ok($t->history_search('yellow', -1) == 4 && $t->where_history == 0); ok($t->history_search('red', 1) == 0 && $t->where_history == 0); ok($t->history_search('blue', 1) == 7 && $t->where_history == 2); ok($t->history_search('red', 1) == -1 && $t->where_history == 2); ok($t->history_search('red') == 6 && $t->where_history == 1); # history_search_prefix() ok($t->history_search_prefix('red', -1) == 0 && $t->where_history == 0, 'history_search_prefix'); ok($t->history_search_prefix('green', 1) == 0 && $t->where_history == 1); ok($t->history_search_prefix('red', 1) == -1 && $t->where_history == 1); ok($t->history_search_prefix('red') == 0 && $t->where_history == 0); # history_search_pos() $t->history_set_pos(3); ok($t->history_search_pos('red', -1, 1) == 1, 'history_search_pos'); ok($t->history_search_pos('red', -1, 3) == 1); ok($t->history_search_pos('black', -1, 3) == -1); ok($t->history_search_pos('yellow', -1) == 2); ok($t->history_search_pos('green') == 3); ok($t->history_search_pos('yellow', 1, 1) == 2); ok($t->history_search_pos('yellow', 1) == -1); ok($t->history_search_pos('red', 1, 2) == -1); ######################################################################## note "2.3.6 Managing the History File"; $t->stifle_history(undef); my $hfile = '.history_test'; my @list_write = $t->GetHistory(); $t->WriteHistory($hfile) || warn "error at write_history: $!\n"; $t->SetHistory(); # clear history list ok(! $t->GetHistory, 'SetHistory'); $t->ReadHistory($hfile) || warn "error at read_history: $!\n"; is_deeply(\@list_write, [$t->GetHistory], 'ReadHistory'); @list_write = qw(0 1 2 3 4); $t->SetHistory(@list_write); # write_history() ! $t->write_history($hfile) || warn "error at write_history: $!\n"; $t->SetHistory(); # clear history list # read_history() ! $t->read_history($hfile) || warn "error at read_history: $!\n"; is_deeply(\@list_write, [$t->GetHistory], 'read_history'); # read_history() with range ! $t->read_history($hfile, 1, 3) || warn "error at read_history: $!\n"; is_deeply([0,1,2,3,4,1,2], [$t->GetHistory], 'read_history with range'); #print "@{[$t->GetHistory]}\n"; ! $t->read_history($hfile, 2, -1) || warn "error at read_history: $!\n"; is_deeply([0,1,2,3,4,1,2,2,3,4], [$t->GetHistory]); #print "@{[$t->GetHistory]}\n"; # append_history() ! $t->append_history(5, $hfile) || warn "error at append_history: $!\n"; $t->SetHistory(); # clear history list ! $t->read_history($hfile) || warn "error at read_history: $!\n"; is_deeply([0,1,2,3,4,1,2,2,3,4], [$t->GetHistory], 'append_history'); #print "@{[$t->GetHistory]}\n"; # history_truncate_file() $t->history_truncate_file($hfile, 6); # always returns 0 $t->SetHistory(); # clear history list ! $t->read_history($hfile) || warn "error at read_history: $!\n"; is_deeply([4,1,2,2,3,4], [$t->GetHistory], 'history_truncate_file'); #print "@{[$t->GetHistory]}\n"; ######################################################################## note "2.3.7 History Expansion"; my ($string, $ret, $exp, @exp); @list_set = ('red yellow', 'blue red', 'yellow blue', 'green blue'); $t->SetHistory(@list_set); $t->history_set_pos(2); # history_expand() #print "${\($t->history_expand('!!'))}"; # !! : last entry of the history list ok($t->history_expand('!!') eq 'green blue', 'history_expand'); ok($t->history_expand('!yel') eq 'yellow blue'); ($ret, $string) = $t->history_expand('!red'); ok($ret == 1 && $string eq 'red yellow'); # get_history_event() my ($text, $cindex); # 1 2 # 012345678901234567890123 $string = '!-2 !?red? "!blu" white'; # !-2: 2 line before ($text, $cindex) = $t->get_history_event($string, 0); ok($cindex == 3 && $text eq 'yellow blue', 'get_history_event'); #print "$cindex,$text\n"; # non-event designator ($text, $cindex) = $t->get_history_event($string, 3); ok($cindex == 3 && ! defined $text); #print "$cindex,$text\n"; # The following 2 test may fail with readline-4.3 with some locale # setting. It comes from bug of the Readline Library. I sent a patch # to the maintainer. `LANG=C make test' should work. # !?red?: line including `red' ($text, $cindex) = $t->get_history_event($string, 4); ok($cindex == 10 && $text eq 'blue red'); #print "$cindex,$text\n"; # "!?blu": line including `blu' ($text, $cindex) = $t->get_history_event($string, 12, '"'); ok($cindex == 16 && $text eq 'blue red'); #print "$cindex,$text\n"; # history_tokenize(), history_arg_extract() $string = ' foo "double quoted"& \'single quoted\' (paren)'; # for history_tokenize() @exp = ('foo', '"double quoted"', '&', '\'single quoted\'', '(', 'paren', ')'); # for history_arg_extract() $exp = "@exp"; is_deeply([$t->history_tokenize($string)], \@exp, 'history_tokenize'); ok($t->history_arg_extract($string, 0, '$') eq $exp, 'history_arg_extract'); ok($t->history_arg_extract($string, 0) eq $exp); ok($t->history_arg_extract($string) eq $exp); $_ = $string; ok($t->history_arg_extract eq $exp); ######################################################################## note "2.4 History Variables"; # history_base, history_length, max_input_history are tested above # history_expansion_char!!!, history_subst_char!!!, history_comment_char!!!, # history_word_delimiters!!!, history_no_expand_chars!!! # history_inhibit_expansion_function @list_set = ('red yellow', 'blue red', 'yellow blue', 'green blue'); $t->SetHistory(@list_set); $t->history_set_pos(2); # equivalent with 'history_no_expand_chars = "...!..."' $attribs->{history_inhibit_expansion_function} = sub { my ($string, $index) = @_; substr($string, $index + 1, 1) eq '!'; # inhibit expanding '!!' }; ok($t->history_expand('!!') eq '!!', 'history_inhibit_expansion_function'); ok($t->history_expand(' !r') eq ' red yellow'); # strange behavior was fixed on version 6.0 if ($version < 6.0) { ok($t->history_expand('!! !y') eq 'green blue yellow blue'); } else { ok($t->history_expand('!! !y') eq '!! yellow blue'); } #done_testing(); end_of_test: exit 0; ######################################################################## # subroutines # debugging support sub show_indices { return; printf("where_history: %d ", $t->where_history); # printf("current_history(): %s ", $t->current_history); printf("history_base: %d, ", $attribs->{history_base}); printf("history_length: %d, ", $attribs->{history_length}); # printf("max_input_history: %d ", $attribs->{max_input_history}); # printf("history_total_bytes: %d ", $t->history_total_bytes); print "\n"; } Term-ReadLine-Gnu-1.35/t/inputrc0000644060175006010010000000023012273446720015237 0ustar hirooNone# readline init file for t/readline.t # `a' and `b' should be bind to about, and 'c' not. "a": abort $if ReadLineTest "b": abort $else "c": abort $endifTerm-ReadLine-Gnu-1.35/t/readline.t0000644060175006010010000011077313006641755015616 0ustar hirooNone# -*- perl -*- # readline.t - Test script for Term::ReadLine:GNU # # $Id: readline.t 555 2016-11-03 14:04:27Z hayashi $ # # Copyright (c) 1996-2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl t/readline.t' use strict; use warnings; use Test::More tests => 147; use Data::Dumper; # redefine Test::Mode::note due to it requires Perl 5.10.1. no warnings 'redefine'; sub note { my $msg = join('', @_); $msg =~ s{\n(?!\z)}{\n# }sg; print "# $msg" . ($msg =~ /\n$/ ? '' : "\n"); } use warnings 'redefine'; BEGIN { $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu $ENV{LC_ALL} = 'C'; # LC_ALL is stronger than LANG } # 'define @ARGV' is deprecated my $verbose = scalar @ARGV && ($ARGV[0] eq 'verbose'); use Term::ReadLine; BEGIN { import Term::ReadLine::Gnu qw(:keymap_type RL_STATE_INITIALIZED); } ok(1, 'load done'); note "Testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION"; ######################################################################## # test new method # stop reading ~/.inputrc not to change the default key-bindings. $ENV{'INPUTRC'} = '/dev/null'; # These tty setting affects GNU Readline key-bindings. # Set the standard bindings before rl_initialize() being called. # comment out since check_default_keybind_and_fix() takes care. # system('stty erase ^?') == 0 or warn "stty erase failed: $?"; # system('stty kill ^u') == 0 or warn "stty kill failed: $?"; # system('stty lnext ^v') == 0 or warn "stty lnext failed: $?"; # system('stty werase ^w') == 0 or warn "stty werase failed: $?"; my $t = new Term::ReadLine 'ReadLineTest'; isa_ok($t, 'Term::ReadLine'); my $OUT; if ($verbose) { $OUT = $t->OUT; } else { open(NULL, '>/dev/null') or die "cannot open \`/dev/null\': $!\n"; $OUT = \*NULL; $t->Attribs->{outstream} = \*NULL; } ######################################################################## # test ReadLine method ok($t->ReadLine eq 'Term::ReadLine::Gnu', '$t->ReadLine'); ######################################################################## # test Features method ok(%{ $t->Features }, 'Features method'); #isa_ok($t->Features, 'Term::ReadLine', 'Features'); ######################################################################## # test Attribs method my $a = $t->Attribs; isa_ok($a, 'Term::ReadLine', 'Attribs'); ######################################################################## note "2.3 Readline Variables"; my ($maj, $min) = $a->{library_version} =~ /(\d+)\.(\d+)/; my $version = $a->{readline_version}; SKIP: { # rl_readline_version returns 0x0600. The bug is fixed GNU Readline 6.1-p2 skip "GNU Readline Library 6.1 may return wrong value.", 1 if ($a->{library_version} eq '6.1'); ok($version == 0x100 * $maj + $min, 'readline_version'); } # Version 2.0 and before are NOT supported. ok($version > 0x0200, 'readline_version'); # check the values of initialized variables ok($a->{line_buffer} eq '', 'line_buffer'); ok($a->{point} == 0, 'point'); ok($a->{end} == 0, 'end'); ok($a->{mark} == 0, 'mark'); ok($a->{done} == 0, 'done'); ok($a->{num_chars_to_read} == 0, 'num_chars_to_read'); ok($a->{pending_input} == 0, 'pending_input'); ok($a->{dispatching} == 0, 'dispatching'); ok($a->{erase_empty_line} == 0, 'erase_empty_line'); ok(! defined($a->{prompt}), 'prompt'); ok($a->{display_prompt} eq "", 'display_prompt'); ok($a->{already_prompted} == 0, 'already_prompted'); # library_version and readline_version are tested above. ok($a->{gnu_readline_p} == 1, 'gnu_readline_p'); if ($version < 0x0402) { # defined but left assgined as NULL ok(! defined($a->{terminal_name}), 'terminal_name'); } else { ok($a->{terminal_name} eq $ENV{TERM}, 'terminal_name'); } ok($a->{readline_name} eq 'ReadLineTest', 'readline_name'); # rl_instream and rl_outstream are tested below. ok($a->{prefer_env_winsize} == 0, 'prefer_envwin_size'); ok(! defined($a->{last_func}), 'last_func'); ok(! defined($a->{startup_hook}), 'startup_hook'); ok(! defined($a->{pre_input_hook}), 'pre_input_hook'); ok(! defined($a->{event_hook}), 'event_hook'); ok(! defined($a->{getc_function}), 'getc_function'); ok(! defined($a->{signal_event_hook}), 'signal_event_hook'); # not tested!!! ok(! defined($a->{input_available_hook}), 'input_available_hook'); ok(! defined($a->{redisplay_function}), 'redisplay_function'); ok(! defined($a->{prep_term_function}), 'prep_term_function'); # not tested!!! ok(! defined($a->{deprep_term_function}), 'deprep_term_function'); # not tested!!! # not defined here yet ok(! defined($a->{executing_keymap}), 'executing_keymap'); # anonymous keymap ok(defined($a->{binding_keymap}), 'binding_keymap'); ok(! defined($a->{executing_macro}), 'executing_macro'); ok($a->{executing_key} == 0, 'executing_key'); if ($version < 0x0603) { ok(! defined($a->{executing_keyseq}), 'executing_keyseq'); } else { ok(defined($a->{executing_keyseq}), 'executing_keyseq'); } ok($a->{key_sequence_length} == 0, 'key_sequence_length'); ok(($a->{readline_state} == RL_STATE_INITIALIZED), 'readline_state'); ok($a->{explicit_arg} == 0, 'explicit_arg'); ok($a->{numeric_arg} == 1, 'numeric_arg'); ok($a->{editing_mode} == 1, 'editing_mode'); ######################################################################## note "2.4 Readline Convenience Functions"; ######################################################################## # define some custom functions sub reverse_line { # reverse a whole line my($count, $key) = @_; # ignored in this sample function $t->modifying(0, $a->{end}); # save undo information $a->{line_buffer} = reverse $a->{line_buffer}; } # From the GNU Readline Library Manual # Invert the case of the COUNT following characters. sub invert_case_line { my($count, $key) = @_; my $start = $a->{point}; return 0 if ($start >= $a->{end}); # Find the end of the range to modify. my $end = $start + $count; # Force it to be within range. if ($end > $a->{end}) { $end = $a->{end}; } elsif ($end < 0) { $end = 0; } return 0 if $start == $end; if ($start > $end) { my $temp = $start; $start = $end; $end = $temp; } # Tell readline that we are modifying the line, so it will save # undo information. $t->modifying($start, $end); # I'm happy with Perl :-) substr($a->{line_buffer}, $start, $end-$start) =~ tr/a-zA-Z/A-Za-z/; # Move point to on top of the last character changed. $a->{point} = $count < 0 ? $start : $end - 1; return 0; } ######################################################################## note "2.4.1 Naming a Function"; my ($func, $type); # test add_defun ok(! defined($t->named_function('reverse-line')) && ! defined($t->named_function('invert-case-line')) && defined($t->named_function('operate-and-get-next')) && defined($t->named_function('display-readline-version')) && defined($t->named_function('change-ornaments')), 'add_defun: before'); ($func, $type) = $t->function_of_keyseq("\ct"); ok($type == ISFUNC && $t->get_function_name($func) eq 'transpose-chars', 'add_defun, function_of_keyseq'); $t->add_defun('reverse-line', \&reverse_line, ord "\ct"); $t->add_defun('invert-case-line', \&invert_case_line); ok(defined($t->named_function('reverse-line')) && defined($t->named_function('invert-case-line')) && defined($t->named_function('operate-and-get-next')) && defined($t->named_function('display-readline-version')) && defined($t->named_function('change-ornaments')), 'add_defun: after'); ($func, $type) = $t->function_of_keyseq("\ct"); ok($type == ISFUNC && $t->get_function_name($func) eq 'reverse-line', 'add_defun, function_of_keyseq'); ######################################################################## note "2.4.2 Selecting a Keymap"; # test rl_make_bare_keymap, rl_copy_keymap, rl_make_keymap, rl_discard_keymap, rl_free_keymap my $baremap = $t->make_bare_keymap; $t->bind_key(ord "a", 'abort', $baremap); my $copymap = $t->copy_keymap($baremap); $t->bind_key(ord "b", 'abort', $baremap); my $normmap = $t->make_keymap; ok(($t->get_function_name(($t->function_of_keyseq('a', $baremap))[0]) eq 'abort') && ($t->get_function_name(($t->function_of_keyseq('b', $baremap))[0]) eq 'abort') && ($t->get_function_name(($t->function_of_keyseq('a', $copymap))[0]) eq 'abort') && ! defined($t->function_of_keyseq('b', $copymap)) && ($t->get_function_name(($t->function_of_keyseq('a', $normmap))[0]) eq 'self-insert'), 'make_bare_keymap, copy_keymap, make_keymap, bind_key'); $t->discard_keymap($baremap); $t->discard_keymap($copymap); $t->discard_keymap($normmap); ok(1, 'discard_keymap'); $t->free_keymap($baremap); $t->free_keymap($copymap); $t->free_keymap($normmap); ok(1, 'free_keymap'); # test rl_get_keymap, rl_set_keymap, rl_get_keymap_by_name, rl_get_keymap_name ok($t->get_keymap_name($t->get_keymap) eq 'emacs', 'get_keymap_name, get_keymap'); $t->set_keymap('vi'); ok($t->get_keymap_name($t->get_keymap) eq 'vi', 'set_keymap'); # equivalent to $t->set_keymap('emacs'); $t->set_keymap($t->get_keymap_by_name('emacs')); ok($t->get_keymap_name($t->get_keymap) eq 'emacs', 'set_keymap, get_keymap_by_name'); ######################################################################## note "2.4.3 Binding Keys"; #print $t->get_keymap_name($a->{executing_keymap}), "\n"; #print $t->get_keymap_name($a->{binding_keymap}), "\n"; # test rl_bind_key[_in_map], rl_bind_key_if_unbound[_in_map]!!!, # rl_unbind_key[_in_map] (below), rl_unbind_function_in_map (below), rl_unbind_command_in_map (below), # rl_bind_keyseq[_in_map]!!!, rl_set_key, rl_bind_keyseq_if_unbound[_in_map]!!!, # rl_generic_bind, rl_parse_and_bind # define subroutine to use again later my ($helpmap, $mymacro); sub bind_my_function { $t->bind_key(ord "\ct", 'reverse-line'); $t->bind_key(ord "\cv", 'display-readline-version', 'emacs-ctlx'); $t->parse_and_bind('"\C-xv": display-readline-version'); $t->bind_key(ord "c", 'invert-case-line', 'emacs-meta'); if ($version >= 0x0402) { # rl_set_key in introduced by GRL 4.2 $t->set_key("\eo", 'change-ornaments'); } else { $t->bind_key(ord "o", 'change-ornaments', 'emacs-meta'); } $t->bind_key(ord "^", 'history-expand-line', 'emacs-meta'); # make an original map $helpmap = $t->make_bare_keymap(); $t->bind_key(ord "f", 'dump-functions', $helpmap); $t->generic_bind(ISKMAP, "\e?", $helpmap); $t->bind_key(ord "v", 'dump-variables', $helpmap); # 'dump-macros' is documented but not defined by GNU Readline 2.1 $t->generic_bind(ISFUNC, "\e?m", 'dump-macros') if $version > 0x0201; # bind a macro $mymacro = "\ca[insert text from the beginning of line]"; $t->generic_bind(ISMACR, "\e?i", $mymacro); } bind_my_function; # do bind { my ($fn, $ty); # check keymap binding ($fn, $ty) = $t->function_of_keyseq("\cX"); ok($t->get_keymap_name($fn) eq 'emacs-ctlx' && $ty == ISKMAP, 'keymap binding'); # check macro binding ($fn, $ty) = $t->function_of_keyseq("\e?i"); ok($fn eq $mymacro && $ty == ISMACR, 'macro binding'); } # check some key binding used by following test sub is_boundp { my ($seq, $fname) = @_; my ($fn, $type) = $t->function_of_keyseq($seq); if ($fn) { return ($t->get_function_name($fn) eq $fname && $type == ISFUNC); } else { warn ("No function is bound for sequence \`", toprint($seq), "\'. \`$fname\' is expected,"); return 0; } } # check function binding ok(is_boundp("\cT", 'reverse-line') && is_boundp("\cX\cV", 'display-readline-version') && is_boundp("\cXv", 'display-readline-version') && is_boundp("\ec", 'invert-case-line') && is_boundp("\eo", 'change-ornaments') && is_boundp("\e^", 'history-expand-line') && is_boundp("\e?f", 'dump-functions') && is_boundp("\e?v", 'dump-variables') && ($version <= 0x0201 or is_boundp("\e?m", 'dump-macros')), 'function binding'); # test rl_read_init_file ok($t->read_init_file('t/inputrc') == 0, 'read_init_file'); ok(is_boundp("a", 'abort') && is_boundp("b", 'abort') && is_boundp("c", 'self-insert'), 'read_init_file'); # resume $t->bind_key(ord "a", 'self-insert'); $t->bind_key(ord "b", 'self-insert'); ok(is_boundp("a", 'self-insert') && is_boundp("b", 'self-insert'), 'bind_key'); # test rl_unbind_key (rl_unbind_key_in_map), # rl_unbind_command (rl_unbind_command_in_map), # rl_unbind_function (rl_unbind_function_in_map) $t->unbind_key(ord "\ct"); # reverse-line $t->unbind_key(ord "f", $helpmap); # dump-function $t->unbind_key(ord "v", 'emacs-ctlx'); # display-readline-version if ($version > 0x0201) { $t->unbind_command_in_map('display-readline-version', 'emacs-ctlx'); $t->unbind_function_in_map($t->named_function('dump-variables'), $helpmap); } else { $t->unbind_key(ord "\cV", 'emacs-ctlx'); $t->unbind_key(ord "v", $helpmap); } my @keyseqs = ($t->invoking_keyseqs('reverse-line'), $t->invoking_keyseqs('dump-functions'), $t->invoking_keyseqs('display-readline-version'), $t->invoking_keyseqs('dump-variables')); ok(scalar @keyseqs == 0, "unbind_key\t[@keyseqs]"); SKIP: { skip "GNU Readline Library is older than 4.2.", 1 unless ($version >= 0x0402); $t->add_funmap_entry('foo_bar', 'reverse-line'); # This does not work. We need something like `equal' in Lisp. # ok($t->named_function('reverse-line') == $t->named_function('foo_bar')); ok(defined $t->named_function('foo_bar'), 'add_funmap_entry'); } ######################################################################## note "2.4.4 Associating Function Names and Bindings"; bind_my_function; # do bind # rl_named_function, get_function_name, rl_function_of_keyseq, # rl_invoking_keyseqs[_in_map] # rl_function_dumper!!!, rl_list_funmap_names!!!, rl_funmap_names!!! # rl_add_funmap_entry (above) # test rl_invoking_keyseqs @keyseqs = $t->invoking_keyseqs('abort', 'emacs-ctlx'); ok("\\C-g" eq "@keyseqs", 'invoking_keyseqs'); ######################################################################## note "2.4.5 Allowing Undoing"; # rl_begin_undo_group!!!, rl_end_undo_group!!!, rl_add_undo!!!, # rl_free_undo_list!!!, rl_do_undo!!!, rl_modifying ######################################################################## note "2.4.6 Redisplay"; # rl_redisplay!!!, rl_forced_update_display (below), rl_on_new_line!!!, # rl_on_new_line_with_prompt!!!, rl_clear_visible_line()!!!, # rl_reset_line_state!!!, rl_crlf!!!, # rl_show_char!!!, # rl_message, rl_clear_message, rl_save_prompt, rl_restore_prompt: # see Gnu/XS.pm:change_ornaments() # rl_expand_prompt!!!, rl_set_prompt!!! ######################################################################## note "2.4.7 Modifying Text"; # rl_insert_text!!!, rl_delete_text!!!, rl_copy_text!!!, rl_kill_text!!!, # rl_push_macro_input!!! ######################################################################## note "2.4.8 Character Input"; # rl_read_key!!!, rl_getc, rl_stuff_char!!!, rl_execute_next!!!, # rl_clear_pending_input!!!, rl_set_keyboard_input_timeout!!! ######################################################################## note "2.4.9 Terminal Management"; # rl_prep_terminal!!!, rl_deprep_terminal!!!, # rl_tty_set_default_bindings!!!, rl_tty_unset_default_bindings!!!, # rl_tty_set_echoing!!!, rl_reset_terminal!!! ######################################################################## note "2.4.10 Utility Functions"; # rl_save_state, rl_restore_state, -rl_free-, rl_replace_line!!!, # -rl_extend_line_buffer-, # rl_initialize, rl_ding!!!, rl_alphabetic!!!, # rl_display_match_list (below) SKIP: { skip "GNU Readline Library is older than 4.3.", 4 unless ($version >= 0x0403); ok($a->{point} == 0, 'save_state, restore_state'); my $state = $t->save_state(); isa_ok($state, 'readline_state_tPtr'); $a->{point} = 10; ok($a->{point} == 10, 'save_state, restore_state'); $t->restore_state($state); ok($a->{point} == 0, 'save_state, restore_state'); } ######################################################################## note "2.4.11 Miscellaneous Functions"; # rl_macro_bind!!!, rl_macro_dumpter!!!, # rl_variable_bind!!!, rl_variable_value!!!, rl_variable_dumper!!! # rl_set_paren_blink_timeout!!!, rl_get_termcap!!!, rl_clear_history!!! ######################################################################## note "2.4.12 Alternate Interface"; # tested in callback.t # rl_callback_handler_install, rl_callback_read_char, # rl_callback_sigcleanup!!!, rl_callback_handler_remove, ######################################################################## note "2.5 Readline Signal Handling"; ok($a->{catch_signals} == 1, 'catch_signals'); ok($a->{catch_sigwinch} == 1, 'catch_sigwinch'); ok($a->{persistent_signal_handlers} == 0, 'persistent_signal_handlers'); ok($a->{change_environment} == 1, 'change_environment'); # rl_pending_signal()!!!, rl_cleanup_after_signal!!!, rl_free_line_state!!!, # rl_reset_after_signal!!!, rl_echo_signal_char!!!, rl_resize_terminal!!!, # rl_set_screen_size, rl_get_screen_size SKIP: { skip "GNU Readline Library is older than 4.2.", 1 unless ($version >= 0x0402); my ($rowsav, $colsav) = $t->get_screen_size; $t->set_screen_size(60, 132); my ($row, $col) = $t->get_screen_size; # col=131 on a terminal which does not support auto-wrap function ok($row == 60 && ($col == 132 || $col == 131), 'set/get_screen_size'); $t->set_screen_size($rowsav, $colsav); } # rl_reset_screen_size!!!, rl_set_signals!!!, rl_clear_signals!!! ######################################################################## note "2.6 Custom Completers"; note "2.6.1 How Completing Works"; # rl_complete, rl_completion_entry_function (below) note "2.6.2 Completion Functions"; # rl_complete_internal!!!, rl_complete, rl_possible_completions, rl_insert_completions, # rl_completion_mode!!!, rl_completion_matches, # rl_filename_completion_function, rl_username_completion_function, # list_completion_function note "2.6.3 Completion Variables"; ok(! defined $a->{completion_entry_function}, 'completion_entry_function'); ok(! defined $a->{attempted_completion_function}, 'attempted_completion_function'); ok(! defined $a->{filename_quoting_function}, 'filename_quoting_function'); ok(! defined $a->{filename_dequoting_function}, 'filename_dequoting_function'); ok(! defined $a->{char_is_quoted_p}, 'char_is_quoted_p'); ok(! defined $a->{ignore_some_completions_function}, 'ignore_some_completions_function'); ok(! defined $a->{directory_completions_hook}, 'directory_completions_hook'); ok(! defined $a->{directory_rewrite_hook}, 'directory_rewrite_hook'); ok(! defined $a->{filename_stat_hook}, 'filename_stat_hook'); ok(! defined $a->{filename_rewrite_hook}, 'filename_rewrite_hook'); ok(! defined $a->{completions_display_matches_hook}, 'completions_display_matches_hook'); ok($a->{basic_word_break_characters} eq " \t\n\"\\'`\@\$><=;|&{(", 'basic_word_break_characters'); ok($a->{basic_quote_characters} eq "\"'", 'basic_quote_characters'); ok($a->{completer_word_break_characters} eq " \t\n\"\\'`\@\$><=;|&{(", 'completer_word_break_characters'); ok(! defined $a->{completion_word_break_hook}, 'completion_word_break_hook'); ok(! defined $a->{completer_quote_characters}, 'completer_quote_characters'); ok(! defined $a->{filename_quote_characters}, 'filename_quote_characters'); ok(! defined $a->{special_prefixes}, 'special_prefixes'); ok($a->{completion_query_items} == 100, 'completion_query_items'); ok($a->{completion_append_character} eq " ", 'completion_append_character'); ok($a->{completion_suppress_append} == 0, 'completion_suppress_append'); ok($a->{completion_quote_character} eq "\0", 'completion_quote_character'); ok($a->{completion_suppress_quote} == 0, 'completion_suppress_quote'); ok($a->{completion_found_quote} == 0, 'completion_found_quote'); ok($a->{completion_mark_symlink_dirs} == 0, 'completion_mark_symlink_dirs'); ok($a->{ignore_completion_duplicates} == 1, 'ignore_completion_duplicates'); ok($a->{filename_completion_desired} == 0, 'filename_completion_desired'); ok($a->{filename_quoting_desired} == 1, 'filename_quoting_desired'); ok($a->{attempted_completion_over} == 0, 'attempted_completion_over'); ok($a->{sort_completion_matches} == 1, 'sort_completion_matches'); ok($a->{completion_type} == 0, 'completion_type'); ok($a->{completion_invoking_key} eq "\0", 'completion_invoking_key'); ok($a->{inhibit_completion} == 0, 'inhibit_completion'); ######################################################################## $t->parse_and_bind('set bell-style none'); # make readline quiet #$t->parse_and_bind('set enable-bracketed-paste on'); #$t->parse_and_bind('set blink-matching-paren on'); #$t->parse_and_bind('set colored-completion-prefix off'); my ($INSTR, $line); # simulate key input by using a variable 'rl_getc_function' $a->{getc_function} = sub { unless (length $INSTR) { print $OUT "Error: getc_function: insufficient string, \`\$INSTR\'."; undef $a->{getc_function}; return 0; } my $c = substr $INSTR, 0, 1; # the first char of $INSTR $INSTR = substr $INSTR, 1; # rest of $INSTR return ord $c; }; # This is required after GNU Readline Library 6.3. $a->{input_available_hook} = sub { return 1; }; # convert control charactors to printable charactors (ex. "\cx" -> '\C-x') sub toprint { join('', map{$_ eq "\e" ? '\M-': ord($_)<32 ? '\C-'.lc(chr(ord($_)+64)) : $_} (split('', $_[0]))); } sub check_default_keybind_and_fix { my ($seq, $fname) = @_; if (is_boundp($seq, $fname)) { ok(1, " $fname was bound to " . toprint($seq)); } else { # Try to fix the binding. But tty setting seems have precedence. $t->set_key($seq, $fname); if (is_boundp($seq, $fname)) { # The default keybinding for $fname was changed. Fixed. ok(1, " $fname is now bound to " . toprint($seq)); } else { ok(0, " $fname cannot be bound to " . toprint($seq)); } } } note "check_default_keybind_and_fix"; check_default_keybind_and_fix("\cM", 'accept-line'); check_default_keybind_and_fix("\cF", 'forward-char'); check_default_keybind_and_fix("\cB", 'backward-char'); check_default_keybind_and_fix("\ef", 'forward-word'); check_default_keybind_and_fix("\eb", 'backward-word'); check_default_keybind_and_fix("\cE", 'end-of-line'); check_default_keybind_and_fix("\cA", 'beginning-of-line'); check_default_keybind_and_fix("\cH", 'backward-delete-char'); check_default_keybind_and_fix("\cD", 'delete-char'); check_default_keybind_and_fix("\cI", 'complete'); $INSTR = "abcdefgh\cM"; $line = $t->readline("self insert> "); ok($line eq 'abcdefgh', "self insert\t[$line]"); $INSTR = "\cAe\cFf\cBg\cEh\cH ij kl\eb\ebm\cDn\cM"; $line = $t->readline("cursor move> ", 'abcd'); # default string SKIP: { # skip on CPAN Testers test. skip "This 'cursor move' test fails on an active tester's environment, but we could not solve the issue.", 1 if $ENV{AUTOMATED_TESTING} || defined $ENV{PERL_CPAN_REPORTER_CONFIG}; ok($line eq 'eagfbcd mnj kl', "cursor move\t[$line]"); } # test reverse_line, display_readline_version, invert_case_line $INSTR = "\cXvabcdefgh XYZ\e6\cB\e4\ec\cT\cM"; $line = $t->readline("custom commands> "); ok($line eq 'ZYx HGfedcba', "custom commands\t[$line]"); # test undo of reverse_line $INSTR = "abcdefgh\cTi\c_\c_\cM"; $line = $t->readline("test undo> "); ok($line eq 'abcdefgh', "undo\t[$line]"); # test macro, change_ornaments $INSTR = "1234\e?i\eoB\cM\cM"; $line = $t->readline("keyboard macro> "); ok($line eq "[insert text from the beginning of line]1234", "macro\t[$line]"); $INSTR = "\cM"; $line = $t->readline("bold face prompt> "); ok($line eq '', "ornaments\t[$line]"); # test operate_and_get_next $INSTR = "one\cMtwo\cMthree\cM\cP\cP\cP\cO\cO\cO\cM"; $line = $t->readline("> "); # one $line = $t->readline("> "); # two $line = $t->readline("> "); # three $line = $t->readline("> "); ok($line eq 'one', "operate_and_get_next 1\t[$line]"); $line = $t->readline("> "); ok($line eq 'two', "operate_and_get_next 2\t[$line]"); $line = $t->readline("> "); ok($line eq 'three', "operate_and_get_next 3\t[$line]"); $line = $t->readline("> "); ok($line eq 'one', "operate_and_get_next 4\t[$line]"); ######################################################################## note "test history expansion"; $t->ornaments(0); # ornaments off #print $OUT "\n# history expansion test\n# quit by EOF (\\C-d)\n"; $a->{do_expand} = 1; $t->MinLine(4); sub prompt { # equivalent with "$nline = $t->where_history + 1" my $nline = $a->{history_base} + $a->{history_length}; "$nline> "; } $INSTR = "!1\cM"; $line = $t->readline(prompt); ok($line eq 'abcdefgh', "history 1\t[$line]"); $INSTR = "123\cM"; # too short $line = $t->readline(prompt); $INSTR = "!!\cM"; $line = $t->readline(prompt); ok($line eq 'abcdefgh', "history 2\t[$line]"); $INSTR = "1234\cM"; $line = $t->readline(prompt); $INSTR = "!!\cM"; $line = $t->readline(prompt); ok($line eq '1234', "history 3\t[$line]"); ######################################################################## note "test custom completion function"; $t->parse_and_bind('set bell-style none'); # make readline quiet $INSTR = "t/comp\cI\e*\cM"; $line = $t->readline("insert completion>"); # "a_b" < "README" on some kind of locale since strcoll() is used in # the GNU Readline Library. # Not all perl support setlocale. My perl supports locale and I tried # use POSIX qw(locale_h); setlocale(LC_COLLATE, 'C'); # But it seems that it does not affect strcoll() linked to GNU # Readline Library. ok($line eq 't/comptest/0123 t/comptest/012345 t/comptest/023456 t/comptest/README t/comptest/a_b ' || $line eq 't/comptest/0123 t/comptest/012345 t/comptest/023456 t/comptest/a_b t/comptest/README ' || $line eq 't/comptest/.svn t/comptest/0123 t/comptest/012345 t/comptest/023456 t/comptest/README t/comptest/a_b ' || $line eq 't/comptest/.svn t/comptest/0123 t/comptest/012345 t/comptest/023456 t/comptest/a_b t/comptest/README ', "insert completion\t[$line]"); $INSTR = "t/comp\cIR\cI\cM"; $line = $t->readline("filename completion (default)>"); ok($line eq 't/comptest/README ', "default completion\t[$line]"); $a->{completion_entry_function} = $a->{'username_completion_function'}; my $user = getlogin || 'root'; $INSTR = "${user}\cI\cM"; $line = $t->readline("username completion>"); if ($line eq "${user} ") { ok(1, 'username completion'); } elsif ($line eq ${user}) { ok(1, 'username completion'); diag "It seems that there is no user whose name is '${user}' or there is a user whose name starts with '${user}'"; } else { ok(0, "username completion\t[$line]"); # something wrong... } $a->{completion_word} = [qw(a list of words for completion and another word)]; $a->{completion_entry_function} = $a->{'list_completion_function'}; print $OUT "given list is: a list of words for completion and another word\n"; $INSTR = "a\cI\cIn\cI\cIo\cI\cM"; $line = $t->readline("list completion>"); ok($line eq 'another ', "list completion\t[$line]"); $a->{completion_entry_function} = $a->{'filename_completion_function'}; $INSTR = "t/comp\cI\cI\cI0\cI\cI1\cI\cI\cM"; $line = $t->readline("filename completion>"); ok($line eq 't/comptest/0123', "filename completion\t[$line]"); undef $a->{completion_entry_function}; # attempted_completion_function $a->{attempted_completion_function} = sub { undef; }; $a->{completion_entry_function} = sub {}; $INSTR = "t/comp\cI\cM"; $line = $t->readline("null completion 1>"); ok($line eq 't/comp', "null completion 1\t[$line]"); $a->{attempted_completion_function} = sub { (undef, undef); }; undef $a->{completion_entry_function}; $INSTR = "t/comp\cI\cM"; $line = $t->readline("null completion 2>"); ok($line eq 't/comptest/', "null completion 2\t[$line]"); sub sample_completion { my ($text, $line, $start, $end) = @_; # If first word then username completion, else filename completion if (substr($line, 0, $start) =~ /^\s*$/) { return $t->completion_matches($text, $a->{'list_completion_function'}); } else { return (); } } $a->{attempted_completion_function} = \&sample_completion; print $OUT "given list is: a list of words for completion and another word\n"; $INSTR = "li\cIt/comp\cI\cI\cI0\cI\cI2\cI\cM"; $line = $t->readline("list & filename completion>"); ok($line eq 'list t/comptest/023456 ', "list & file completion\t[$line]"); undef $a->{attempted_completion_function}; # ignore_some_completions_function $a->{ignore_some_completions_function} = sub { return (grep m|/$| || ! m|^(.*/)?[0-9]*$|, @_); }; $INSTR = "t/co\cIRE\cI\cM"; $line = $t->readline("ignore_some_completion>"); ok($line eq 't/comptest/README ', "ingore_some_completion\t[$line]"); undef $a->{ignore_some_completions_function}; # char_is_quoted, filename_quoting_function, filename_dequoting_function sub char_is_quoted ($$) { # borrowed from bash-2.03:subst.c my ($string, $eindex) = @_; my ($i, $pass_next); for ($i = $pass_next = 0; $i <= $eindex; $i++) { my $c = substr($string, $i, 1); if ($pass_next) { $pass_next = 0; return 1 if ($i >= $eindex); # XXX was if (i >= eindex - 1) } elsif ($c eq '\'') { $i = index($string, '\'', ++$i); return 1 if ($i == -1 || $i >= $eindex); # } elsif ($c eq '"') { # ignore double quote } elsif ($c eq '\\') { $pass_next = 1; } } return 0; } $a->{char_is_quoted_p} = \&char_is_quoted; $a->{filename_quoting_function} = sub { my ($text, $match_type, $quote_pointer) = @_; my $qc = $a->{filename_quote_characters}; return $text if $quote_pointer; $text =~ s/[\Q${qc}\E]/\\$&/; return $text; }; $a->{filename_dequoting_function} = sub { my ($text, $quote_char) = @_; $quote_char = chr $quote_char; $text =~ s/\\//g; return $text; }; $a->{completer_quote_characters} = '\''; $a->{filename_quote_characters} = ' _\'\\'; $INSTR = "t/comp\cIa\cI 't/comp\cIa\cI\cM"; $line = $t->readline("filename_quoting_function>"); ok($line eq 't/comptest/a\\_b \'t/comptest/a_b\' ', "filename_quoting_function\t[$line]"); $INSTR = "\'t/comp\cIa\\_\cI\cM"; $line = $t->readline("filename_dequoting_function>"); ok($line eq '\'t/comptest/a_b\' ', "filename_dequoting_function\t[$line]"); undef $a->{char_is_quoted_p}; undef $a->{filename_quoting_function}; undef $a->{filename_dequoting_function}; # directory_completion_hook $a->{directory_completion_hook} = sub { if ($_[0] eq 'comp/') { # simple alias function $_[0] = 't/comptest/'; return 1; } else { return 0; } }; $INSTR = "comp/\cI\cM"; $line = $t->readline("directory_completion_hook>"); ok($line eq 't/comptest/', "directory_completion_hook\t[$line]"); undef $a->{directory_completion_hook}; # filename_list my @m = $t->filename_list('t/comptest/01'); ok($#m == 1, "filename_list\t[" . join(':', @m) . ']'); $t->parse_and_bind('set bell-style audible'); # resume to default style ######################################################################## note "test rl_startup_hook, rl_pre_input_hook"; $a->{startup_hook} = sub { $a->{point} = 10; }; $INSTR = "insert\cM"; $line = $t->readline("rl_startup_hook test>", "cursor is, <- here"); ok($line eq 'cursor is,insert <- here', "startup_hook\t[$line]"); $a->{startup_hook} = undef; $a->{pre_input_hook} = sub { $a->{point} = 10; }; $INSTR = "insert\cM"; $line = $t->readline("rl_pre_input_hook test>", "cursor is, <- here"); SKIP: { skip "GNU Readline Library is older than 4.0.", 1 unless ($version >= 0x0400); ok($line eq 'cursor is,insert <- here', "pre_input_hook\t[$line]"); } $a->{pre_input_hook} = undef; ######################################################################### note "test redisplay_function"; $a->{redisplay_function} = $a->{shadow_redisplay}; $INSTR = "\cX\cVThis is a password.\cM"; $line = $t->readline("password> "); ok($line eq 'This is a password.', "redisplay_function\t[$line]"); undef $a->{redisplay_function}; ok(1, 'redisplay_function'); ######################################################################### note "test rl_display_match_list"; SKIP: { skip "GNU Readline Library is older than 4.0.", 1 unless ($version >= 0x0400); # my @match_list = @{$a->{completion_word}}; my @match_list = qw(possible_completion one two three four five six); $t->display_match_list(\@match_list); $t->parse_and_bind('set print-completions-horizontally on'); $t->display_match_list(\@match_list); $t->parse_and_bind('set print-completions-horizontally off'); @match_list = qw(foo/ foo/bar1 foo/bar2 foo/bar3); $t->display_match_list(\@match_list); @match_list = qw(foo/bar foo/bar1 foo/bar2 foo/bar3); $t->display_match_list(\@match_list); ok(1, 'display_match_list'); } ######################################################################### note "test rl_completion_display_matches_hook"; SKIP: { skip "GNU Readline Library is older than 4.0.", 1 unless ($version >= 0x0400); # See 'eg/perlsh' for better example $a->{completion_display_matches_hook} = sub { my($matches, $num_matches, $max_length) = @_; map { $_ = uc $_; }(@{$matches}); $t->display_match_list($matches); $t->forced_update_display; }; $t->parse_and_bind('set bell-style none'); # make readline quiet $INSTR = "Gnu.\cI\cI\cM"; $t->readline("completion_display_matches_hook>"); undef $a->{completion_display_matches_hook}; ok(1, 'completion_display_matches_hook'); $t->parse_and_bind('set bell-style audible'); # resume to default style } ######################################################################## note "test ornaments"; $INSTR = "\cM\cM\cM\cM\cM\cM\cM"; print $OUT "# ornaments test\n"; print $OUT "# Note: Some function may not work on your terminal.\n"; # Kterm seems to have a bug with 'ue' (End underlining) does not work\n"; $t->ornaments(1); # equivalent to 'us,ue,md,me' print $OUT "\n" unless defined $t->readline("default ornaments (underline)>"); # cf. man termcap(5) $t->ornaments('so,me,,'); print $OUT "\n" unless defined $t->readline("standout>"); $t->ornaments('us,me,,'); print $OUT "\n" unless defined $t->readline("underlining>"); $t->ornaments('mb,me,,'); print $OUT "\n" unless defined $t->readline("blinking>"); $t->ornaments('md,me,,'); print $OUT "\n" unless defined $t->readline("bold>"); $t->ornaments('mr,me,,'); print $OUT "\n" unless defined $t->readline("reverse>"); # It seems that on some systems a visible bell cannot be redirected # to /dev/null and confuses ExtUtils::Command:MM::test_harness(). $t->ornaments('vb,,,') if $verbose; print $OUT "\n" unless defined $t->readline("visible bell>"); $t->ornaments(0); print $OUT "# end of ornaments test\n"; ok(1, 'ornaments'); ######################################################################## note "end of non-interactive test"; unless ($verbose) { # Be quiet during CPAN Testers testing. diag "Try \`$^X -Mblib t/readline.t verbose\', if you will.\n" if (!$ENV{AUTOMATED_TESTING}); exit 0; } undef $a->{getc_function}; undef $a->{input_available_hook}; ######################################################################## note "interactive testn"; ######################################################################## # test redisplay_function $a->{redisplay_function} = $a->{shadow_redisplay}; $line = $t->readline("password> "); print "<$line>\n"; undef $a->{redisplay_function}; ######################################################################## # test rl_getc_function and rl_getc() sub uppercase { # my $FILE = $a->{instream}; # return ord uc chr $t->getc($FILE); return ord uc chr $t->getc($a->{instream}); } $a->{getc_function} = \&uppercase; print $OUT "\n" unless defined $t->readline("convert to uppercase>"); undef $a->{getc_function}; undef $a->{input_available_hook}; ######################################################################## # test event_hook my $timer = 20; # 20 x 0.1 = 2.0 sec timer $a->{event_hook} = sub { if ($timer-- < 0) { $a->{done} = 1; undef $a->{event_hook}; } }; $line = $t->readline("input in 2 seconds> "); undef $a->{event_hook}; print "<$line>\n"; ######################################################################## my %TYPE = (0 => 'Function', 1 => 'Keymap', 2 => 'Macro'); print $OUT "\n# Try the following commands.\n"; foreach ("\co", "\ct", "\cx", "\cx\cv", "\cxv", "\ec", "\e^", "\e?f", "\e?v", "\e?m", "\e?i", "\eo") { my ($p, $type) = $t->function_of_keyseq($_); printf $OUT "%-9s: ", toprint($_); (print "\n", next) unless defined $type; printf $OUT "%-8s : ", $TYPE{$type}; if ($type == ISFUNC) { print $OUT ($t->get_function_name($p)); } elsif ($type == ISKMAP) { print $OUT ($t->get_keymap_name($p)); } elsif ($type == ISMACR) { print $OUT (toprint($p)); } else { print $OUT "Error: Illegal type value"; } print $OUT "\n"; } print $OUT "\n# history expansion test\n# quit by EOF (\\C-d)\n"; $a->{do_expand} = 1; while (defined($line = $t->readline(prompt))) { print $OUT "<<$line>>\n"; } print $OUT "\n"; Term-ReadLine-Gnu-1.35/t/utf8.txt0000644060175006010010000000013212722602641015253 0ustar hirooNone🐪 🐪🐪 🐪🐪🐪 🐪🐪🐪🐪 🐪🐪🐪🐪🐪 🐪🐪🐪🐪🐪🐪 Term-ReadLine-Gnu-1.35/t/utf8_binary.t0000644060175006010010000001051612726150745016261 0ustar hirooNone# -*- perl -*- # utf8_binary.t --- Term::ReadLine::Gnu UTF-8 binary string test script # # $Id: utf8_binary.t 545 2016-06-09 02:18:11Z hayashi $ # # Copyright (c) 2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # The GNU Readline Library start supporting multibyte characters since # version 4.3, and is still improving the support. You should use the # latest GNU Readline Library for UTF-8 support. # If you just want to read strings including mutibyte charactors # (e.g. UTF-8), you may simply treat them as binary strings as shown # this test. # But if you want to process UTF-8 strings in your perl script (see # reverse test below), take a look at t/utf8_text.t. use strict; use warnings; use constant NTEST => 12; use Test::More tests => NTEST; use Data::Dumper; # redefine Test::Mode::note due to it requires Perl 5.10.1. { no warnings 'redefine'; sub note { my $msg = join('', @_); $msg =~ s{\n(?!\z)}{\n# }sg; print "# $msg" . ($msg =~ /\n$/ ? '' : "\n"); } } BEGIN { # $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu } use Term::ReadLine; ok(1, 'load done'); note "I'm testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION"; my $verbose = scalar @ARGV && ($ARGV[0] eq 'verbose'); # skip when PERL_UNICODE is set # https://rt.cpan.org/Public/Bug/Display.html?id=114185 if (${^UNICODE} != 0) { diag "PERL_UNICODE is defined or -C option is specified. Skipped..."; ok(1, 'skip') for 1..(NTEST-1); exit 0; } ok(1, 'PERL_UNICODE is not defined'); my ($in, $line, @layers); open ($in, "<", "t/utf8.txt") or die "cannot open utf8.txt: $!"; if (0) { # This may cause a fail. $line = <$in>; chomp($line); note $line; note Dumper($line, "🐪"); ok($line eq "🐪", 'pre-read'); } my $expected = $] >= 5.010 ? ['unix', 'perlio'] : ['stdio']; @layers = PerlIO::get_layers($in); note 'i: ', join(':', @layers); is_deeply(\@layers, $expected, "input layers before 'new'"); @layers = PerlIO::get_layers(\*STDOUT); note 'o: ', join(':', @layers); is_deeply(\@layers, $expected, "output layers before 'new'"); my $t; if ($verbose) { #$t = new Term::ReadLine 'ReadLineTest', \*STDIN, \*STDOUT; $t = new Term::ReadLine 'ReadLineTest'; } else { $t = new Term::ReadLine 'ReadLineTest', $in, \*STDOUT; } print "\n"; # rl_initialize() outputs some escape characters in Term-ReadLine-Gnu less than 6.3, isa_ok($t, 'Term::ReadLine'); $expected = $] >= 5.010 ? ['unix', 'perlio', 'stdio'] : ['stdio']; @layers = PerlIO::get_layers($t->IN); note 'i: ', join(':', @layers); is_deeply(\@layers, $expected, "input layers after 'new'"); @layers = PerlIO::get_layers($t->OUT); note 'o: ', join(':', @layers); is_deeply(\@layers, $expected, "output layers after 'new'"); # force the GNU Readline 8 bit through if ($t->ReadLine eq 'Term::ReadLine::Gnu') { $t->parse_and_bind('set input-meta on'); $t->parse_and_bind('set convert-meta off'); $t->parse_and_bind('set output-meta on'); } my $a = $t->Attribs; # verbose mode if ($verbose) { $a->{do_expand} = 1; while ($line = $t->readline("🐪🐪> ")) { print {$t->OUT} $line, "\n"; print {$t->OUT} Dumper($line), "\n"; } exit 0; } # UTF8 string input $line = $t->readline("🐪🐪> "); note $line; note Dumper($line, "🐪"); ok($line eq "🐪", 'UTF-8 binary string read'); ok(!utf8::is_utf8($line), 'not UTF-8 text string: function'); # output stream print {$t->OUT} "# output stream test: 🐪 🐪🐪 🐪🐪🐪\n"; # UTF8 string variable access $a->{readline_name} = '🐪 🐪🐪 🐪🐪🐪'; $line = $a->{readline_name}; note $line; note Dumper($line); ok($line eq '🐪 🐪🐪 🐪🐪🐪', 'UTF-8 binary string variable'); ok(!utf8::is_utf8($line), 'not UTF-8 text string: variable'); # UTF-8 binary string does not work. ok(reverse $line ne '🐪🐪🐪 🐪🐪 🐪', 'This does not work.'); if (0) { # This may cause a fail. $line = <$in>; chomp($line); note $line; note Dumper($line, "🐪🐪"); ok($line eq "🐪🐪"); $line = $t->readline("🐪🐪🐪> "); note $line; note Dumper($line, "🐪🐪🐪"); ok($line eq "🐪🐪🐪"); @layers = PerlIO::get_layers($in); note 'i: ', join(':', @layers); @layers = PerlIO::get_layers(\*STDOUT); note 'o: ', join(':', @layers); } exit 0; Term-ReadLine-Gnu-1.35/t/utf8_text.t0000644060175006010010000001176212727271036015763 0ustar hirooNone# -*- perl -*- # utf8_text.t --- Term::ReadLine::Gnu UTF-8 text string test script # # $Id: utf8_text.t 551 2016-06-12 14:30:54Z hayashi $ # # Copyright (c) 2016 Hiroo Hayashi. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # The GNU Readline Library start supporting multibyte characters since # version 4.3, and is still improving the support. You should use the # latest GNU Readline Library for UTF-8 support. use strict; use warnings; # convert into UTF-8 text strings # use ':encoding(UTF-8)', not ':utf8' nor ':encoding(utf8)' # http://perldoc.perl.org/PerlIO.html # http://perldoc.perl.org/Encode.html, 'UTF-8 vs. utf8 vs. UTF8' use utf8; use open ':std', ':encoding(UTF-8)'; # This must follow UTF-8 setting. # See 'CAVEATS and NOTES' in http://perldoc.perl.org/Test/More.html for details. use constant NTEST => 13; use Test::More tests => NTEST; use Data::Dumper; # redefine Test::Mode::note due to it requires Perl 5.10.1. { no warnings 'redefine'; sub note { my $msg = join('', @_); $msg =~ s{\n(?!\z)}{\n# }sg; print "# $msg" . ($msg =~ /\n$/ ? '' : "\n"); } } BEGIN { # $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu $ENV{LC_ALL} = 'en_US.UTF-8'; } use Term::ReadLine; ok(1, 'load done'); note "I'm testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION"; my $verbose = scalar @ARGV && ($ARGV[0] eq 'verbose'); # check locale setting because the following tests depend on locale feature. use Config; if (!$Config{d_setlocale}) { diag "d_setlocale is not defined. Skipped..."; ok(1, 'skip') for 1..(NTEST-1); exit 0; } ok(1, '$Config{d_setlocale}'); # http://perldoc.perl.org/perllocale.html use POSIX qw(locale_h); use locale; my $old_locale = setlocale(LC_ALL, 'en_US.UTF-8'); if (!defined $old_locale) { diag "The locale 'en_US.UTF-8' is not supported. Skipped..."; ok(1, 'skip') for 1..(NTEST-2); exit 0; } ok(1, 'setlocale'); my ($in, $line, @layers); open ($in, "<", "t/utf8.txt") or die "cannot open utf8.txt: $!"; if (0) { # This may cause a fail. $line = <$in>; chomp($line); note $line; note Dumper($line, "🐪"); ok($line eq "🐪", 'pre-read'); } my $expected = $] >= 5.010 ? ['unix', 'perlio', 'encoding(utf-8-strict)', 'utf8'] : ['stdio', 'encoding(utf-8-strict)', 'utf8']; my $expected_x; if (${^UNICODE} == 0) { $expected_x = $expected; } else { $expected_x = $] >= 5.010 ? ['unix', 'perlio', 'utf8', 'encoding(utf-8-strict)', 'utf8'] : ['stdio', 'utf8', 'encoding(utf-8-strict)', 'utf8']; } @layers = PerlIO::get_layers($in); note 'i: ', join(':', @layers); is_deeply(\@layers, $expected, "input layers before 'new'"); @layers = PerlIO::get_layers(\*STDOUT); note 'o: ', join(':', @layers); is_deeply(\@layers, $expected_x, "output layers before 'new'"); my $t; if ($verbose) { #$t = new Term::ReadLine 'ReadLineTest', \*STDIN, \*STDOUT; #$Term::ReadLine::Gnu::utf8_mode = 1; $t = new Term::ReadLine 'ReadLineTest'; $t->enableUTF8; } else { $t = new Term::ReadLine 'ReadLineTest', $in, \*STDOUT; } print "\n"; # rl_initialize() outputs some escape characters in Term-ReadLine-Gnu less than 6.3, isa_ok($t, 'Term::ReadLine'); @layers = PerlIO::get_layers($t->IN); note 'i: ', join(':', @layers); is_deeply(\@layers, $expected, "input layers after 'new'"); @layers = PerlIO::get_layers($t->OUT); note 'o: ', join(':', @layers); is_deeply(\@layers, $expected_x, "output layers after 'new'"); # force the GNU Readline 8 bit through if ($t->ReadLine eq 'Term::ReadLine::Gnu') { $t->parse_and_bind('set input-meta on'); $t->parse_and_bind('set convert-meta off'); $t->parse_and_bind('set output-meta on'); } my $a = $t->Attribs; # verbose mode if ($verbose) { $a->{do_expand} = 1; while ($line = $t->readline("🐪🐪> ")) { print {$t->OUT} $line, "\n"; print {$t->OUT} Dumper($line), "\n"; } exit 0; } # UTF8 string input $line = $t->readline("🐪🐪> "); note $line; note Dumper($line, "🐪"); ok($line eq "🐪", 'UTF-8 text string read'); ok(utf8::is_utf8($line), 'UTF-8 text string: function'); # output stream print {$t->OUT} "# output stream test: 🐪 🐪🐪 🐪🐪🐪\n"; # UTF8 string variable access $a->{readline_name} = '🐪 🐪🐪 🐪🐪🐪'; $line = $a->{readline_name}; note $line; note Dumper($line); ok($line eq '🐪 🐪🐪 🐪🐪🐪', 'UTF-8 binary string variable'); ok(utf8::is_utf8($line), 'UTF-8 text string: variable'); # UTF-8 text string works well. ok(reverse $line eq '🐪🐪🐪 🐪🐪 🐪', 'This does work.'); if (0) { # This may cause a fail. $line = <$in>; chomp($line); note $line; note Dumper($line, "🐪🐪"); ok($line eq "🐪🐪"); $line = $t->readline("🐪🐪🐪> "); note $line; note Dumper($line, "🐪🐪🐪"); ok($line eq "🐪🐪🐪"); @layers = PerlIO::get_layers($in); note 'i: ', join(':', @layers); @layers = PerlIO::get_layers(\*STDOUT); note 'o: ', join(':', @layers); } exit 0; Term-ReadLine-Gnu-1.35/typemap0000644060175006010010000000144212725554205014775 0ustar hirooNone# typemap for Term::ReadLine::Gnu # # $Id: typemap 541 2016-06-07 14:22:03Z hayashi $ const char * T_PV CONST char * T_PV Keymap T_PTROBJ Function * T_PTROBJ rl_command_func_t * T_PTROBJ readline_state_t * T_PTROBJ HIST_ENTRY * T_HIST_ENTRY HISTORY_STATE * T_PTROBJ t_utf8 T_XSTR t_utf8_free T_XSTR_FREE ######################################################################## INPUT ######################################################################## OUTPUT T_XSTR if ($var) { sv_setpv($arg, $var); if (utf8_mode) sv_utf8_decode($arg); } T_XSTR_FREE if ($var) { sv_setpv($arg, $var); if (utf8_mode) sv_utf8_decode($arg); xfree($var); } T_HIST_ENTRY if ($var && $var->line) { sv_setpv($arg, $var->line); if (utf8_mode) sv_utf8_decode($arg); }