Mercurial > forge
view admin/change_va_arg.pm @ 12718:1af86934c14e octave-forge
Make compatible with Octaves new exception-based error handling.
Retain compatibility with Octaves old error handling based on
error_state.
* src/error_helpers.[h,cc]: Added.
* src/Makefile.in: Integrate error-helpers.[h,cc].
* src/config.h.in: Added.
* configure.ac, src/config.h.in: Test presence of 'error_state' and
presence of 'verror (octave_execution_exception&, const char *,
va_list)'.
* src/__pq_connect__.cc, src/command.cc, src/command.h,
src/converters.cc, src/converters_arr_comp.cc, src/pq_connection.cc,
src/pq_conninfo.cc, src/pq_exec.cc, src/pq_lo.cc,
src/pq_update_types.cc: If necessary, include error-helpers.h, replace
error() with c_verror(), set and check a different error indicator
than error_state, use CHECK_ERROR or SET_ERR, explicitely check for
errors instead of relying on Octave checking error_state when
returning to the prompt.
author | i7tiol |
---|---|
date | Sat, 27 Feb 2016 11:11:04 +0000 |
parents | d856e0d1e410 |
children |
line wrap: on
line source
#!/usr/bin/perl -w -n ## defines function change_line that transforms old-style variable argument ## lists (...) into new-style varargin. va_arg() etc are also transformed. BEGIN{ $va_arg_re = qr!^(\s*function\s*\w*.*?\(.*?)\.\.\.(\s*\).*)$!; } ## Does necessary changes inplace on $_[0]. sub change_line { if ($_[0] !~ /^\s*\#/) { # Don't do obvious comment lines # Transform ... in function decalaration $_[0] =~ s{$va_arg_re}{$1varargin$2}og; # list(all_va_args) becomes varargin $_[0] =~ s!list\s*\(\s*all_va_args\s*\)!varargin!og; # all_va_args becomes varargin{:} $_[0] =~ s!all_va_args!varargin{:}!og; # va_start() can be delicate, so add a # warning. # declare a va_arg_cnt counter $_[0] =~ s!(.*\b)va_start\b(\s*\(\s*\)|)(.*)!$1va_arg_cnt = 1$3\nwarn ("va_start should be transformed\\n");\n!g; # Use that counter to substitute va_arg by # nth (varargin, va_arg_cnt++) $_[0] =~ s!(.*\b)va_arg\b(\s*\(\s*\)|)(.*)!$1nth (varargin, va_arg_cnt++)$3!g; } } ## Does it look like an underlined func that is not a function call? sub comment_line { 0 ? "## Hmmm ... is that a function call?\n" : ""; } 1;