Re: r16208 - gnucash/branches/csv-import/src/import-export/csv - Added a bunch of comments to gnc-csv-import.c.

2007-06-23 Thread Josh Sled
Benjamin Sperisen [EMAIL PROTECTED] writes:
 Log:
 Added a bunch of comments to gnc-csv-import.c.

 Modified:
 gnucash/branches/csv-import/src/import-export/csv/gnc-csv-import.c

 +/* This struct contains all of the data relevant to the preview dialog
 + * that lets the user configure an import. */

You should take a quick look at the doxygen syntax
http://www.stack.nl/~dimitri/doxygen/docblocks.html.  In short, if you make
these javadoc-style comments /** ... **/, then they'll show up in the
generated documentation, basically for free.  There are some other tags and
rules that are useful for annotating parts of the documentation strings like
variables and identifiers.

(Note that in terms of doxygen, we use the 'javadoc' (not Qt) form, and '@'
(not '\').)

  typedef struct
  {
[...]
 +  GtkDialog* dialog; /* The dialog */

This comment doesn't add anything, and doesn't need to be there.


 +  GtkTreeView* treeview; /* The treeview containing the data */
 +  GtkTreeView* ctreeview; /* The treeview containing the column types */
 +  GtkCheckButton* sep_buttons[SEP_NUM_OF_TYPES]; /* Checkbuttons for common 
 separators */
 +  GtkCheckButton* custom_cbutton; /* The checkbutton for a custom separator 
 */
 +  GtkEntry* custom_entry; /* The entry for custom separators */
 +  gboolean approved; /* This is FALSE until the user clicks OK. */
  } GncCsvPreview;

For these, for doxygen, you'll want to say /** This is FALSE [...] */, I think.


 +/* Event handler for when one of the separator checkbuttons is clicked. */
  static void sep_button_clicked(GtkCheckButton* widget, GncCsvPreview* 
 preview)
  {
 +  /* The stock separator charactors */
char* sep_chars[] = { , \t, ,, :, ;, -};

Why not just call the variable stock_sep_chars, and dispense with the
comment?

 +  /* A list of all the separators that have been checked. */
GSList* separators = NULL;

Similarly, if the variable is 'checked_separators'...


 +  /* Go through each of the separator buttons. */
for(i = 0; i  SEP_NUM_OF_TYPES; i++)
{
 +/* If this button is checked, add the corresponding character to
 + * the separators list. */
  
 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(preview-sep_buttons[i])))
separators = g_slist_append(separators, sep_chars[i]);
}
 +  /* If the custom button is checked ... */

 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(preview-custom_cbutton)))
{
 +/* ... get the separator string from the custom entry ... */
  char* custom_sep = (char*)gtk_entry_get_text(preview-custom_entry);
 -if(custom_sep[0] != '\0')
 +if(custom_sep[0] != '\0') /* ... and if it isn't blank add it to the 
 separators list. */

All of these comments describe exactly what the code already says.  They are
no longer signal.


 -static void encoding_selected(GOCharmapSel* selector, const char* enc,
 +/* Event handler for a new encoding being selected. */
 +static void encoding_selected(GOCharmapSel* selector, const char* encoding,
GncCsvPreview* preview)
  {
 +  /* This gets called twice everytime a new encoding is selected. The
 +   * second call actually passes the correct data; thus, we only do
 +   * something the second time this is called. */
static gboolean second_call = FALSE;
 +  /* If this is the second time the function is called ... */
if(second_call)

Ick.  This stateful behavior should be avoided if at all possible.  Is there
a way to instead be conditional on the correctness of the data?  Or
eliminate the double-call?

-- 
...jsled
http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo [EMAIL PROTECTED]


pgpOwjHIRQazx.pgp
Description: PGP signature
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


ofx import problems

2007-06-23 Thread David Reiser
ofx imports of files from ameritrade are giving me serious heartburn  
at the moment. Christian managed to stomp on one bug related to a  
simplified file, but the full length files are crashing at least two  
other ways. While I'm thrashing away at narrowing down the large  
files to something simpler that still crashes, does the following gdb  
info suggest something specific to anyone?

LibOFX INFO: sanitize_proprietary_tags() (end tag or new tag)  
removed: AT.ORDERSTATUSF/AT.ORDERSTATUS
(Above message occured on Line 4294967295, Column 4294967295)
terminate called after throwing an instance of 'std::out_of_range'
   what():  basic_string::copy

Program received signal SIGABRT, Aborted.
0x9004822c in kill ()
(gdb) backtrace
#0  0x9004822c in kill ()
#1  0x9012e7b4 in abort ()
#2  0x9eae8078 in __gnu_cxx::__verbose_terminate_handler ()
#3  0x9eae5c08 in __gxx_personality_v0 ()
#4  0x9eae5c6c in std::terminate ()
#5  0x9eae5eac in __cxa_throw ()
#6  0x9ea9f0ac in std::__throw_out_of_range ()
#7  0x9eacc97c in std::string::_M_check ()
#8  0x9eaccc88 in std::string::copy ()
#9  0x03ff5d48 in sanitize_proprietary_tags ()
#10 0x03ff7974 in ofx_proc_file ()
#11 0x03ff4988 in libofx_proc_file ()
#12 0x02fe0d54 in gnc_file_ofx_import () at gnc-ofx-import.c:682
#13 0x02fe1250 in gnc_plugin_ofx_cmd_import (action=0x2ffc948,  
data=0x5c20cf0) at gnc-plugin-ofx.c:145
#14 0x02b0d37c in g_closure_invoke ()

Dave
--
David Reiser
[EMAIL PROTECTED]

___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


another backtrace from different ofx import problem

2007-06-23 Thread David Reiser
A little more interesting info in a backtrace from a different crash?

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x
0x02f97798 in split_find_match (trans_info=0x810c390,  
split=0x68922b8, display_threshold=0, fuzzy_amount_difference=2) at  
import-backend.c:697
697   if(strlen(xaccSplitGetMemo 
(gnc_import_TransInfo_get_fsplit (trans_info)))!=0)
(gdb) backtrace
#0  0x02f97798 in split_find_match (trans_info=0x810c390,  
split=0x68922b8, display_threshold=0, fuzzy_amount_difference=2) at  
import-backend.c:697
#1  0x02f97b4c in gnc_import_find_split_matches  
(trans_info=0x810c390, process_threshold=0,  
fuzzy_amount_difference=2, match_date_hardlimit=42) at import- 
backend.c:831
#2  0x02f9836c in gnc_import_TransInfo_init_matches  
(trans_info=0x810c390, settings=0x7b63cf0) at import-backend.c:1074
#3  0x02f9eb90 in gnc_gen_trans_list_add_trans (gui=0x7b7f570,  
trans=0x7cd0d60) at import-main-matcher.c:732
#4  0x02fe06f8 in ofx_proc_transaction_cb (data={account_id =  
ameritrade 874315721, '\0' repeats 36 times, account_ptr =  
0x30e9a14, account_id_valid = 1, transactiontype = OFX_OTHER,  
transactiontype_valid = 1, invtransactiontype = OFX_INCOME,  
invtransactiontype_valid = 1, units = 0, units_valid = 0, unitprice =  
0, unitprice_valid = 0, amount = 0, amount_valid = 1, fi_id =  
2850333185, '\0' repeats 245 times, fi_id_valid = 1, unique_id =  
9ZZZFD104, '\0' repeats 23 times, unique_id_valid = 1,  
unique_id_type = CUSIP\000\000\000\000\000, unique_id_type_valid =  
1, security_data_ptr = 0x0, security_data_valid = 0, date_posted = 0,  
date_posted_valid = 0, date_initiated = 1180668335,  
date_initiated_valid = 1, date_funds_available = 0,  
date_funds_available_valid = 0, fi_id_corrected = '\0' repeats 255  
times, fi_id_corrected_valid = 0, fi_id_correction_action = DELETE,  
fi_id_correction_action_valid = 0, server_transaction_id = '\0'  
repeats 36 times, server_transaction_id_valid = 0, check_number =  
'\0' repeats 12 times, check_number_valid = 0, reference_number =  
'\0' repeats 32 times, reference_number_valid = 0,  
standard_industrial_code = 0, standard_industrial_code_valid = 0,  
payee_id = '\0' repeats 36 times, payee_id_valid = 0, name = '\0'  
repeats 32 times, name_valid = 0, memo = MONEY MARKET INTEREST,  
'\0' repeats 369 times, memo_valid = 1, commission = 0,  
commission_valid = 0, fees = 0, fees_valid = 0, oldunits = 0,  
oldunits_valid = 0, newunits = 0, newunits_valid = 0},  
transaction_user_data=0x0) at gnc-ofx-import.c:520
#5  0x03ff4f60 in LibofxContext::transactionCallback ()
#6  0x03ffd77c in OfxTransactionContainer::gen_event ()
#7  0x03ff955c in OfxMainContainer::gen_event ()
#8  0x04016cc0 in OFXApplication::endElement ()
#9  0x0406a814 in OpenSP::GenericEventHandler::endElement  
(this=0xbfffcba8, event=0x30d00b0) at GenericEventHandler.cxx:155

Dave
--
David Reiser
[EMAIL PROTECTED]
gnucash r16208
Mac OS X 10.4.9
fink's bizarre gnome dependency mix
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel