Mercurial > forge
changeset 6665:296c2bd7d204 octave-forge
Bump version
author | hauberg |
---|---|
date | Tue, 09 Feb 2010 05:24:36 +0000 |
parents | cf971fd1220f |
children | 475a0870b649 |
files | language/pt_BR/DESCRIPTION language/pt_BR/src/help.icc |
diffstat | 2 files changed, 246 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/language/pt_BR/DESCRIPTION Tue Feb 09 05:23:54 2010 +0000 +++ b/language/pt_BR/DESCRIPTION Tue Feb 09 05:24:36 2010 +0000 @@ -1,6 +1,6 @@ -Name: pt_BR -Version: 1.0.8 -Date: 2009-05-08 +Name: pt_br +Version: 1.0.9 +Date: 2010-02-08 Author: Jorge Barros de Abreu <ficmatin01 at skipthis solar dot com dot br> Maintainer: Jorge Barros de Abreu <ficmatin01 at skipthis solar dot com dot br> Title: Brazilian Portuguese
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/language/pt_BR/src/help.icc Tue Feb 09 05:24:36 2010 +0000 @@ -0,0 +1,243 @@ +/* + +Copyright (C) 2007 David Bateman + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#include <cstdlib> +#include <cstring> +#include <algorithm> +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> + +#include <octave/config.h> +#include <octave/defun-dld.h> +#include <octave/cmd-edit.h> +#include <octave/load-path.h> +#include <octave/oct-env.h> +#include <octave/file-ops.h> +#include <octave/pager.h> +#include <octave/parse.h> +#include <octave/procstream.h> +#include <octave/help.h> + +#include "oct-md5.h" + +static bool +local_looks_like_texinfo (const std::string& msg, size_t& p1) +{ + p1 = msg.find ('\n'); + + std::string t = msg.substr (0, p1); + + if (p1 == std::string::npos) + p1 = 0; + + size_t p2 = t.find ("-*- texinfo -*-"); + + return (p2 != std::string::npos); +} + +static void +local_display_help_text (std::ostream& os, const std::string& msg) +{ + // Look for "-*- texinfo -*-" in first line of help message. If it + // is present, use makeinfo to format the rest of the message before + // sending it to the output stream. Otherwise, just print the + // message. + + size_t pos; + + if (local_looks_like_texinfo (msg, pos)) + { + os.flush (); + + std::string tmp_file_name = file_ops::tempnam ("", ""); + + int cols = command_editor::terminal_cols (); + + if (cols > 16) + cols--; + + if (cols > 64) + cols -= 7; + + if (cols > 80) + cols = 72; + + std::ostringstream buf; + + std::string mkinfo = feval ("makeinfo_program", octave_value_list(), + 1)(0).string_value(); + + // Use double quotes to quote the sed patterns for Windows. + + buf << "sed -e \"s/^[#%][#%]* *//\" -e \"s/^ *@/@/\" | " + << "\"" << mkinfo << "\"" + << " --fill-column " << cols + << " --no-warn" + << " --no-validate" + << " --no-headers" + << " --force" + << " --output \"" << tmp_file_name << "\""; + + oprocstream filter (buf.str ()); + + if (filter && filter.is_open ()) + { + filter << MAKEINFO_MACROS; + + filter << msg.substr (pos+1) << std::endl; + + int status = filter.close (); + + std::ifstream tmp_file (tmp_file_name.c_str ()); + + if (WIFEXITED (status) && WEXITSTATUS (status) == 0) + { + int c; + while ((c = tmp_file.get ()) != EOF) + os << (char) c; + + tmp_file.close (); + } + else + { + warning ("%s: %s", HELP_STRING, TEXINFO_ERROR_1); + warning ("%s: %s", HELP_STRING, TEXINFO_ERROR_2); + warning ("%s:\n\n%s\n\n", HELP_STRING, msg.c_str ()); + } + + file_ops::unlink (tmp_file_name); + } + else + os << msg; + } + else + os << msg; +} + +static std::string +local_help_from_file (const std::string& nm, std::string &md5) +{ + std::string h; + + std::string file = octave_env::make_absolute + (load_path::find_file (nm + LANG_EXT), octave_env::getcwd ()); + + if (! file.empty ()) + { + char ch; + std::ifstream fs (file.c_str(), std::ios::in); + std::string first_line; + + // Get first line to extract MD5 sum + while (fs.get(ch) && ch != '\n') + first_line += ch; + + // Extract MD5 + size_t pos = 0; + md5 = std::string(); + while (pos != std::string::npos) + { + pos = first_line.find_first_of ("\"", pos); + if (pos == std::string::npos) + break; + + if (pos > 3 && first_line.substr(pos - 4, 4) == "md5=") + { + pos++; + size_t end_pos = first_line.find_first_of ("\"", pos); + md5 = first_line.substr(pos, end_pos - pos); + break; + } + } + + while (fs.get(ch)) + h += ch; + } + + return h; +} + +DEFUN_DLD (HELP_NAME, args, nargout, + "-*- texinfo -*-\n" +HELP_TEXT +"@seealso{help, doc}\n\ +@end deftypefn") +{ + octave_value_list retval; + int nargin = args.length (); + + octave_value_list additional_help = + feval ("suppress_verbose_help_message", octave_value_list (), 1); + + for (int i = 0; i < nargin; i++) + { + std::string arg = args(i).string_value(); + + if (error_state) + break; + + bool symbol_found = false; + std::string horig = raw_help (arg, symbol_found); + + if (symbol_found) + { + std::string h_md5; + std::string h = local_help_from_file (arg, h_md5); + + if (! h.empty()) + { + // Due to the way the base strings are created horig must + // terminate in a '\n'. + if (horig.substr(horig.length()-1,1) != "\n") + horig += '\n'; + + if (oct_md5 (horig) != h_md5) + octave_stdout << MD5_MISMATCH << "\n\n"; + + local_display_help_text (octave_stdout, h); + octave_stdout << "\n"; + } + else if (! horig.empty()) + { + local_display_help_text (octave_stdout, horig); + octave_stdout << "\n"; + } + else + octave_stdout << "\n" << HELP_STRING << ": `" << arg + << "' " << NOT_DOCUMENTED << "\n"; + } + else + octave_stdout << "\n" << HELP_STRING << ": `" << arg + << "' " << NOT_FOUND << "\n"; + } + + if (! additional_help(0).bool_value()) + octave_stdout << ADDITIONAL_HELP; + + return retval; +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/