octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Access to string with raw texinfo help string


From: David Bateman
Subject: Access to string with raw texinfo help string
Date: Sun, 14 Jan 2007 22:46:19 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

For the translation project in octave-forge there is a need to write a
language specific help function that uses the translated help if it is
available. However, it also needs the original help string to allow the
MD5 sum of the help string to be compared against the one that was used
in the translation. Finally, for translations of the help of optional
packages it also needs to know if the symbol is found at all.

I'd therefore like to propose the attached patch that basically is the
same logic as the existing help function, but outputs the raw help text
as a string. With this we'll be able to package the pt_BR language
translations of octave and get the system to work as it should...

Regards
David
*** ./src/help.h.orig23 2007-01-14 22:33:01.164558801 +0100
--- ./src/help.h        2007-01-14 22:28:55.192827133 +0100
***************
*** 39,44 ****
--- 39,46 ----
  
  extern void additional_help_message (std::ostream&);
  
+ extern std::string raw_help (const std::string&, bool &);
+ 
  // Name of the info file specified on command line.
  // (--info-file file)
  extern std::string Vinfo_file;
*** ./src/help.cc.orig23        2007-01-14 22:32:49.939118692 +0100
--- ./src/help.cc       2007-01-14 22:36:17.055788334 +0100
***************
*** 1108,1113 ****
--- 1108,1191 ----
    return retval;
  }
  
+ static bool
+ raw_help_from_list (const help_list *list, const std::string& nm, 
+                   std::string &h, bool& symbol_found)
+ {
+   bool retval = false;
+ 
+   const char *name;
+ 
+   while ((name = list->name) != 0)
+     {
+       if (strcmp (name, nm.c_str ()) == 0)
+       {
+         symbol_found = true;
+ 
+         h = list->help;
+ 
+         if (h.length () > 0)
+           retval = true;
+         break;
+       }
+       list++;
+     }
+ 
+   return retval;;
+ }
+ 
+ static bool
+ raw_help_from_symbol_table (const std::string& nm, std::string &h, 
+                           bool& symbol_found)
+ {
+   bool retval = false;
+ 
+   symbol_record *sym_rec = lookup_by_name (nm, 0);
+ 
+   if (sym_rec && sym_rec->is_defined ())
+     {
+       symbol_found = true;
+ 
+       h = sym_rec->help ();
+ 
+       if (h.length () > 0)
+       retval = true;
+     }
+ 
+   return retval;
+ }
+ 
+ static bool
+ raw_help_from_file (const std::string& nm, std::string &h, 
+                   bool& symbol_found)
+ {
+   bool retval = false;
+ 
+   std::string file;
+ 
+   h = get_help_from_file (nm, symbol_found, file);
+ 
+   if (h.length () > 0)
+     retval = true;
+ 
+   return retval;
+ }
+ 
+ std::string
+ raw_help (const std::string &nm, bool &symbol_found)
+ {
+   help_list *op_help_list = operator_help ();
+   help_list *kw_help_list = keyword_help ();
+   std::string h;
+ 
+   (raw_help_from_list (op_help_list, nm, h, symbol_found) ||
+    raw_help_from_list (kw_help_list, nm, h, symbol_found) ||
+    raw_help_from_symbol_table (nm, h, symbol_found) ||
+    raw_help_from_file (nm, h, symbol_found));
+ 
+   return h;
+ }
+ 
  static void
  do_type (std::ostream& os, const std::string& name, bool pr_type_info,
         bool quiet, bool pr_orig_txt)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]