From 72c4db8aa20c22baa4243a0d27b3bb3f32f3ef64 Mon Sep 17 00:00:00 2001 From: Ales Hvezda Date: Tue, 14 Aug 2007 07:46:06 -0400 Subject: [PATCH] Moved 3 rc promotion keywords from gschem into libgeda (fix for bug#1748143) All the promotion keywords were moved from gschem into libgeda to fix: [ 1748143 ] gschlas causes duplicate prompted attributes The primary cause of this bug was that the promotion variables within TOPLEVEL were not being setup by gschlas and so duplicate refdes attributes were showing up in the schematic. The three rc keywords that were moved are: (attribute-promotion ... ) (promote-invisible ... ) (keep-invisible ... ) --- gattrib/include/struct.h | 9 --- gattrib/src/g_rc.c | 11 ---- gnetlist/src/g_rc.c | 64 --------------------- gschem/include/i_vars.h | 3 - gschem/include/prototype.h | 3 - gschem/lib/system-gschemrc.in | 34 ----------- gschem/src/g_rc.c | 130 +----------------------------------------- gschem/src/g_register.c | 3 - gschem/src/i_vars.c | 6 -- gsymcheck/src/g_rc.c | 67 ---------------------- libgeda/include/defines.h | 10 ++++ libgeda/include/i_vars.h | 5 ++ libgeda/include/prototype.h | 7 +++ libgeda/include/struct.h | 6 ++ libgeda/lib/system-gafrc | 45 +++++++++++++++ libgeda/src/g_rc.c | 115 +++++++++++++++++++++++++++++++++++++ libgeda/src/g_register.c | 3 + libgeda/src/i_vars.c | 8 +++ utils/gschlas/g_rc.c | 62 -------------------- 19 files changed, 200 insertions(+), 391 deletions(-) diff --git a/gattrib/include/struct.h b/gattrib/include/struct.h index b2455050d..2d2af10ef 100644 --- a/gattrib/include/struct.h +++ b/gattrib/include/struct.h @@ -42,15 +42,6 @@ /* ----------------------------------------------------------------- * - * This struct used in dealing with guile's read-in of the rc files. - * ----------------------------------------------------------------- */ -typedef struct { - int m_val; - char *m_str; -} vstbl_entry; - - -/* ----------------------------------------------------------------- * * The sheet data hierarchy built by the prog should look like this: * SHEET_DATA->(STRING_LIST *master_XXX_list) // list of comps/nets/pins (row labels) * ->(STRING_LIST *master_XXX_attrib_list) // list of attached names (column labels) diff --git a/gattrib/src/g_rc.c b/gattrib/src/g_rc.c index 2355d79b4..d2bd87a3a 100644 --- a/gattrib/src/g_rc.c +++ b/gattrib/src/g_rc.c @@ -49,17 +49,6 @@ #include #endif -#define RETURN_G_RC_MODE(rc, var, size) \ - return g_rc_mode_general(mode, \ - (rc), \ - &(var), \ - mode_table, \ - size) - -/* a random int, used only as a place holder */ -int default_dummy; - - /*------------------------------------------------------------------ * *------------------------------------------------------------------*/ diff --git a/gnetlist/src/g_rc.c b/gnetlist/src/g_rc.c index 471ca61c8..ba41c67bd 100644 --- a/gnetlist/src/g_rc.c +++ b/gnetlist/src/g_rc.c @@ -46,70 +46,6 @@ #include #endif -typedef struct { - int m_val; - char *m_str; -} vstbl_entry; - -static int -vstbl_lookup_str(const vstbl_entry * table, int size, const char *str) -{ - int i; - - for (i = 0; i < size; i++) { - if (strcmp(table[i].m_str, str) == 0) { - break; - } - } - return i; -} - -static int vstbl_get_val(const vstbl_entry * table, int index) -{ - return table[index].m_val; -} - - -static SCM -g_rc_mode_general(SCM scmmode, - const char *rc_name, - int *mode_var, - const vstbl_entry *table, - int table_size) -{ - SCM ret; - int index; - char *mode; - - SCM_ASSERT (scm_is_string (scmmode), scmmode, - SCM_ARG1, rc_name); - - mode = SCM_STRING_CHARS (scmmode); - - index = vstbl_lookup_str(table, table_size, mode); - - /* no match? */ - if(index == table_size) { - fprintf(stderr, - "Invalid mode [%s] passed to %s\n", - mode, - rc_name); - ret = SCM_BOOL_F; - } else { - *mode_var = vstbl_get_val(table, index); - ret = SCM_BOOL_T; - } - - return ret; -} - -#define RETURN_G_RC_MODE(rc, var, size) \ - return g_rc_mode_general(mode, \ - (rc), \ - &(var), \ - mode_table, \ - size) - SCM g_rc_gnetlist_version(SCM version) { SCM_ASSERT (scm_is_string (version), version, diff --git a/gschem/include/i_vars.h b/gschem/include/i_vars.h index 71711cbbe..1c6283140 100644 --- a/gschem/include/i_vars.h +++ b/gschem/include/i_vars.h @@ -65,9 +65,6 @@ extern int default_enforce_hierarchy; extern int default_text_origin_marker; extern int default_fast_mousepan; extern int default_raise_dialog_boxes; -extern int default_attribute_promotion; -extern int default_promote_invisible; -extern int default_keep_invisible; extern int default_continue_component_place; extern int default_undo_levels; extern int default_undo_control; diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h index a40d63ac4..073575631 100644 --- a/gschem/include/prototype.h +++ b/gschem/include/prototype.h @@ -245,9 +245,6 @@ SCM g_rc_enforce_hierarchy(SCM mode); SCM g_rc_text_origin_marker(SCM mode); SCM g_rc_fast_mousepan(SCM mode); SCM g_rc_raise_dialog_boxes_on_expose(SCM mode); -SCM g_rc_attribute_promotion(SCM mode); -SCM g_rc_promote_invisible(SCM mode); -SCM g_rc_keep_invisible(SCM mode); SCM g_rc_continue_component_place(SCM mode); SCM g_rc_undo_levels(SCM levels); SCM g_rc_undo_control(SCM mode); diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in index 6985b3618..b16ce75f2 100644 --- a/gschem/lib/system-gschemrc.in +++ b/gschem/lib/system-gschemrc.in @@ -312,40 +312,6 @@ ;(embed-components "enabled") (embed-components "disabled") -; attribute-promotion string -; -; This keyword controls if attribute promotion occurs when you instanciate a -; component. Attribute promotion basically means that any floating attribute -; (unattached) which is inside a symbol gets "promoted" or attached to the -; newly inserted component. This only occurs when the component is -; instanciated. -; -(attribute-promotion "enabled") -;(attribute-promotion "disabled") - -; promote-invisible string -; -; If attribute-promotion is enabled, then this controls if invisible floating -; attributes are promoted (attached to the outside of the component) if the -; text string is invisible. There are cases where it is undesirable, so the -; default is disabled. -; -;(promote-invisible "enabled") -(promote-invisible "disabled") - -; keep-invisible string -; -; If both attribute-promotion and promote-invisible are enabled, then this -; controls if invisible floating attributes are kept around in memory and -; NOT deleted. Having this enabled will keeps component slotting working. -; If attribute-promotion and promote-invisible are enabled and this -; keyword is disabled, then component slotting will NOT work (and maybe -; other functions which depend on hidden attributes, since those attributes -; are deleted from memory). -; -;(keep-invisible "disabled") -(keep-invisible "enabled") - ; logging string ; ; Determines if the logging mechanism is enabled or disabled diff --git a/gschem/src/g_rc.c b/gschem/src/g_rc.c index 9c30e8967..b8a570613 100644 --- a/gschem/src/g_rc.c +++ b/gschem/src/g_rc.c @@ -45,21 +45,8 @@ #include #endif -#define RETURN_G_RC_MODE(rc, var, size) \ - return g_rc_mode_general(mode, \ - (rc), \ - &(var), \ - mode_table, \ - size) - /*! a random int, used only as a place holder */ -int default_dummy; - -/*! \brief */ -typedef struct { - int m_val; - char *m_str; -} vstbl_entry; +static int default_dummy; /*! \todo Finish function documentation!!! * \brief @@ -282,70 +269,6 @@ DEFINE_G_RC_COLOR(g_rc_freestyle_color, * \par Function Description * */ -static int vstbl_lookup_str(const vstbl_entry *table, - int size, const char *str) -{ - int i; - - for(i = 0; i < size; i++) { - if(strcmp(table[i].m_str, str) == 0) { - break; - } - } - return i; -} - -/*! \todo Finish function documentation!!! - * \brief - * \par Function Description - * - */ -static int vstbl_get_val(const vstbl_entry *table, int index) -{ - return table[index].m_val; -} - -/*! \todo Finish function documentation!!! - * \brief - * \par Function Description - * - */ -static SCM g_rc_mode_general(SCM scmmode, - const char *rc_name, - int *mode_var, - const vstbl_entry *table, - int table_size) -{ - SCM ret; - int index; - char *mode; - - SCM_ASSERT (scm_is_string (scmmode), scmmode, - SCM_ARG1, rc_name); - - mode = SCM_STRING_CHARS (scmmode); - - index = vstbl_lookup_str(table, table_size, mode); - /* no match? */ - if(index == table_size) { - fprintf(stderr, - _("Invalid mode [%s] passed to %s\n"), - mode, - rc_name); - ret = SCM_BOOL_F; - } else { - *mode_var = vstbl_get_val(table, index); - ret = SCM_BOOL_T; - } - - return ret; -} - -/*! \todo Finish function documentation!!! - * \brief - * \par Function Description - * - */ SCM g_rc_net_endpoint_mode(SCM mode) { static const vstbl_entry mode_table[] = { @@ -1097,57 +1020,6 @@ SCM g_rc_raise_dialog_boxes_on_expose(SCM mode) * \par Function Description * */ -SCM g_rc_attribute_promotion(SCM mode) -{ - static const vstbl_entry mode_table[] = { - {TRUE , "enabled" }, - {FALSE, "disabled"}, - }; - - RETURN_G_RC_MODE("attribute-promotion", - default_attribute_promotion, - 2); -} - -/*! \todo Finish function documentation!!! - * \brief - * \par Function Description - * - */ -SCM g_rc_promote_invisible(SCM mode) -{ - static const vstbl_entry mode_table[] = { - {TRUE , "enabled" }, - {FALSE, "disabled"}, - }; - - RETURN_G_RC_MODE("promote-invisible", - default_promote_invisible, - 2); -} - -/*! \todo Finish function documentation!!! - * \brief - * \par Function Description - * - */ -SCM g_rc_keep_invisible(SCM mode) -{ - static const vstbl_entry mode_table[] = { - {TRUE , "enabled" }, - {FALSE, "disabled"}, - }; - - RETURN_G_RC_MODE("keep-invisible", - default_keep_invisible, - 2); -} - -/*! \todo Finish function documentation!!! - * \brief - * \par Function Description - * - */ SCM g_rc_continue_component_place(SCM mode) { static const vstbl_entry mode_table[] = { diff --git a/gschem/src/g_register.c b/gschem/src/g_register.c index b694dfe5d..05fb1cdf5 100644 --- a/gschem/src/g_register.c +++ b/gschem/src/g_register.c @@ -122,9 +122,6 @@ static struct gsubr_t gschem_funcs[] = { { "text-origin-marker", 1, 0, 0, g_rc_text_origin_marker }, { "fast-mousepan", 1, 0, 0, g_rc_fast_mousepan }, { "raise-dialog-boxes-on-expose", 1, 0, 0, g_rc_raise_dialog_boxes_on_expose }, - { "attribute-promotion", 1, 0, 0, g_rc_attribute_promotion }, - { "promote-invisible", 1, 0, 0, g_rc_promote_invisible }, - { "keep-invisible", 1, 0, 0, g_rc_keep_invisible }, { "continue-component-place", 1, 0, 0, g_rc_continue_component_place }, { "undo-levels", 1, 0, 0, g_rc_undo_levels }, { "undo-control", 1, 0, 0, g_rc_undo_control }, diff --git a/gschem/src/i_vars.c b/gschem/src/i_vars.c index b75ea8eae..c4c181a9c 100644 --- a/gschem/src/i_vars.c +++ b/gschem/src/i_vars.c @@ -93,9 +93,6 @@ int default_enforce_hierarchy = TRUE; int default_text_origin_marker = TRUE; int default_fast_mousepan = TRUE; int default_raise_dialog_boxes = FALSE; -int default_attribute_promotion = TRUE; -int default_promote_invisible = FALSE; -int default_keep_invisible = FALSE; int default_continue_component_place = TRUE; int default_undo_levels = 20; int default_undo_control = TRUE; @@ -220,9 +217,6 @@ void i_vars_set(TOPLEVEL *w_current) w_current->text_origin_marker = default_text_origin_marker; w_current->fast_mousepan = default_fast_mousepan; w_current->raise_dialog_boxes = default_raise_dialog_boxes; - w_current->attribute_promotion = default_attribute_promotion; - w_current->promote_invisible = default_promote_invisible; - w_current->keep_invisible = default_keep_invisible; w_current->continue_component_place = default_continue_component_place; w_current->undo_levels = default_undo_levels; w_current->undo_control = default_undo_control; diff --git a/gsymcheck/src/g_rc.c b/gsymcheck/src/g_rc.c index 0ffc6010f..7c38b2d25 100644 --- a/gsymcheck/src/g_rc.c +++ b/gsymcheck/src/g_rc.c @@ -43,73 +43,6 @@ #include "../include/i_vars.h" #include "../include/prototype.h" -#if 0 /* not used yet... */ -typedef struct { - int m_val; - char *m_str; -} vstbl_entry; - -static int -vstbl_lookup_str(const vstbl_entry * table, int size, const char *str) -{ - int i; - - for (i = 0; i < size; i++) { - if (strcmp(table[i].m_str, str) == 0) { - break; - } - } - return i; -} - -static int vstbl_get_val(const vstbl_entry * table, int index) -{ - return table[index].m_val; -} -#endif - - -#if 0 /* not used yet... */ -static SCM -g_rc_mode_general(SCM mode, - const char *rc_name, - int *mode_var, - const vstbl_entry *table, - int table_size) -{ - SCM ret; - int index; - char *mode; - - SCM_ASSERT (scm_is_string (scmmode), scmmode, - SCM_ARG1, rc_name); - - mode = SCM_STRING_CHARS (scmmode); - - index = vstbl_lookup_str(table, table_size, mode); - /* no match? */ - if(index == table_size) { - fprintf(stderr, - "Invalid mode [%s] passed to %s\n", - mode, - rc_name); - ret = SCM_BOOL_F; - } else { - *mode_var = vstbl_get_val(table, index); - ret = SCM_BOOL_T; - } - - return ret; -} - -#define RETURN_G_RC_MODE(rc, var, size) \ - return g_rc_mode_general(mode, \ - (rc), \ - &(var), \ - mode_table, \ - size) -#endif - SCM g_rc_gsymcheck_version(SCM version) { SCM_ASSERT (scm_is_string (version), version, diff --git a/libgeda/include/defines.h b/libgeda/include/defines.h index e521bc4fb..fe8007f92 100644 --- a/libgeda/include/defines.h +++ b/libgeda/include/defines.h @@ -384,3 +384,13 @@ s_log_message (const gchar *format, #ifndef S_IRWXG # define S_IRWXG 0 #endif + + +/* Used by the rc loading mechanism */ +#define RETURN_G_RC_MODE(rc, var, size) \ + return g_rc_mode_general(mode, \ + (rc), \ + &(var), \ + mode_table, \ + size) + diff --git a/libgeda/include/i_vars.h b/libgeda/include/i_vars.h index c4e92c331..043eba578 100644 --- a/libgeda/include/i_vars.h +++ b/libgeda/include/i_vars.h @@ -13,3 +13,8 @@ extern char *default_postscript_prolog; extern char *default_always_promote_attributes; extern char *default_print_command; + +extern int default_attribute_promotion; +extern int default_promote_invisible; +extern int default_keep_invisible; + diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h index 121bf5ca4..8ecd5531d 100644 --- a/libgeda/include/prototype.h +++ b/libgeda/include/prototype.h @@ -32,6 +32,10 @@ int f_print_initialize_glyph_table(void); int g_read_file(const gchar *filename); /* g_rc.c */ +int vstbl_lookup_str(const vstbl_entry *table, int size, const char *str); +int vstbl_get_val(const vstbl_entry *table, int index); +SCM g_rc_mode_general(SCM scmmode, const char *rc_name, int *mode_var, + const vstbl_entry *table, int table_size); gint g_rc_parse_general(TOPLEVEL *w_current, const gchar *fname, const gchar *ok_msg, const gchar *err_msg); @@ -59,6 +63,9 @@ SCM g_rc_scheme_directory(SCM path); SCM g_rc_bus_ripper_symname(SCM scmsymname); SCM g_rc_postscript_prolog(SCM scmsymname); SCM g_rc_map_font_character_to_file(SCM character_param, SCM file_param); +SCM g_rc_attribute_promotion(SCM mode); +SCM g_rc_promote_invisible(SCM mode); +SCM g_rc_keep_invisible(SCM mode); SCM g_rc_always_promote_attributes(SCM scmsymname); /* g_register.c */ diff --git a/libgeda/include/struct.h b/libgeda/include/struct.h index 86bb926ae..cbedca38d 100644 --- a/libgeda/include/struct.h +++ b/libgeda/include/struct.h @@ -971,4 +971,10 @@ struct st_page_smob { PAGE *page; }; +/* used by the rc loading mechanisms */ +typedef struct { + int m_val; + char *m_str; +} vstbl_entry; + #endif diff --git a/libgeda/lib/system-gafrc b/libgeda/lib/system-gafrc index 9a655a22c..24467b861 100644 --- a/libgeda/lib/system-gafrc +++ b/libgeda/lib/system-gafrc @@ -45,6 +45,51 @@ ; before the main script. (postscript-prolog (build-path geda-data-path "prolog.ps")) +; +; Start of attribute promotion keywords +; + +; attribute-promotion string +; +; This keyword controls if attribute promotion occurs when you instanciate a +; component. Attribute promotion basically means that any floating attribute +; (unattached) which is inside a symbol gets "promoted" or attached to the +; newly inserted component. This only occurs when the component is +; instanciated. +; +(attribute-promotion "enabled") +;(attribute-promotion "disabled") + +; promote-invisible string +; +; If attribute-promotion is enabled, then this controls if invisible floating +; attributes are promoted (attached to the outside of the component) if the +; text string is invisible. There are cases where it is undesirable, so the +; default is disabled. +; +;(promote-invisible "enabled") +(promote-invisible "disabled") + +; keep-invisible string +; +; If both attribute-promotion and promote-invisible are enabled, then this +; controls if invisible floating attributes are kept around in memory and +; NOT deleted. Having this enabled will keeps component slotting working. +; If attribute-promotion and promote-invisible are enabled and this +; keyword is disabled, then component slotting will NOT work (and maybe +; other functions which depend on hidden attributes, since those attributes +; are deleted from memory). +; +;(keep-invisible "disabled") +(keep-invisible "enabled") + +; always-promote-attributes +; ; Set the list of attributes that are always promoted regardless of ; their visibility. +; (always-promote-attributes "footprint device value model-name") + +; +; End of attribute promotion keywords +; diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c index 9aea0d139..c8ace1d87 100644 --- a/libgeda/src/g_rc.c +++ b/libgeda/src/g_rc.c @@ -52,6 +52,70 @@ #include #endif +/*! \todo Finish function documentation!!! + * \brief + * \par Function Description + * + */ +int vstbl_lookup_str(const vstbl_entry *table, + int size, const char *str) +{ + int i; + + for(i = 0; i < size; i++) { + if(strcmp(table[i].m_str, str) == 0) { + break; + } + } + return i; +} + +/*! \todo Finish function documentation!!! + * \brief + * \par Function Description + * + */ +int vstbl_get_val(const vstbl_entry *table, int index) +{ + return table[index].m_val; +} + +/*! \todo Finish function documentation!!! + * \brief + * \par Function Description + * + */ +SCM g_rc_mode_general(SCM scmmode, + const char *rc_name, + int *mode_var, + const vstbl_entry *table, + int table_size) +{ + SCM ret; + int index; + char *mode; + + SCM_ASSERT (scm_is_string (scmmode), scmmode, + SCM_ARG1, rc_name); + + mode = SCM_STRING_CHARS (scmmode); + + index = vstbl_lookup_str(table, table_size, mode); + /* no match? */ + if(index == table_size) { + fprintf(stderr, + "Invalid mode [%s] passed to %s\n", + mode, + rc_name); + ret = SCM_BOOL_F; + } else { + *mode_var = vstbl_get_val(table, index); + ret = SCM_BOOL_T; + } + + return ret; +} + extern GHashTable *font_char_to_file; /*! \brief Reads the gafrc file. @@ -1001,6 +1065,57 @@ SCM g_rc_map_font_character_to_file(SCM scmcharstr, SCM scmfilename) return SCM_BOOL_T; } +/*! \todo Finish function documentation!!! + * \brief + * \par Function Description + * + */ +SCM g_rc_attribute_promotion(SCM mode) +{ + static const vstbl_entry mode_table[] = { + {TRUE , "enabled" }, + {FALSE, "disabled"}, + }; + + RETURN_G_RC_MODE("attribute-promotion", + default_attribute_promotion, + 2); +} + +/*! \todo Finish function documentation!!! + * \brief + * \par Function Description + * + */ +SCM g_rc_promote_invisible(SCM mode) +{ + static const vstbl_entry mode_table[] = { + {TRUE , "enabled" }, + {FALSE, "disabled"}, + }; + + RETURN_G_RC_MODE("promote-invisible", + default_promote_invisible, + 2); +} + +/*! \todo Finish function documentation!!! + * \brief + * \par Function Description + * + */ +SCM g_rc_keep_invisible(SCM mode) +{ + static const vstbl_entry mode_table[] = { + {TRUE , "enabled" }, + {FALSE, "disabled"}, + }; + + RETURN_G_RC_MODE("keep-invisible", + default_keep_invisible, + 2); +} + /*! \todo Finish function description!!! * \brief * \par Function Description diff --git a/libgeda/src/g_register.c b/libgeda/src/g_register.c index 9d9443f7f..52d0622a5 100644 --- a/libgeda/src/g_register.c +++ b/libgeda/src/g_register.c @@ -78,6 +78,9 @@ static struct gsubr_t libgeda_funcs[] = { { "bus-ripper-symname", 1, 0, 0, g_rc_bus_ripper_symname }, { "postscript-prolog", 1, 0, 0, g_rc_postscript_prolog }, { "map-font-character-to-file", 2, 0, 0, g_rc_map_font_character_to_file }, + { "attribute-promotion", 1, 0, 0, g_rc_attribute_promotion }, + { "promote-invisible", 1, 0, 0, g_rc_promote_invisible }, + { "keep-invisible", 1, 0, 0, g_rc_keep_invisible }, { "always-promote-attributes",1, 0, 0, g_rc_always_promote_attributes }, { NULL, 0, 0, 0, NULL } }; diff --git a/libgeda/src/i_vars.c b/libgeda/src/i_vars.c index 8f56ffb75..839fc400e 100644 --- a/libgeda/src/i_vars.c +++ b/libgeda/src/i_vars.c @@ -72,6 +72,10 @@ char *default_postscript_prolog = NULL; char *default_always_promote_attributes = NULL; char *default_print_command = NULL; +int default_attribute_promotion = TRUE; +int default_promote_invisible = FALSE; +int default_keep_invisible = FALSE; + /*! \brief Initialize variables in TOPLEVEL object * \par Function Description * This function will initialize variables to default values. @@ -84,6 +88,10 @@ void i_vars_libgeda_set(TOPLEVEL *w_current) w_current->init_right = default_init_right; w_current->init_bottom = default_init_bottom; + w_current->attribute_promotion = default_attribute_promotion; + w_current->promote_invisible = default_promote_invisible; + w_current->keep_invisible = default_keep_invisible; + /* you cannot free the default* strings here since new windows */ /* need them */ INIT_STR(w_current, series_name , DEFAULT_SERIES_NAME ); diff --git a/utils/gschlas/g_rc.c b/utils/gschlas/g_rc.c index a11a10a79..fb0f301cc 100644 --- a/utils/gschlas/g_rc.c +++ b/utils/gschlas/g_rc.c @@ -46,68 +46,6 @@ #include #endif -typedef struct { - int m_val; - char *m_str; -} vstbl_entry; - -static int -vstbl_lookup_str(const vstbl_entry * table, int size, const char *str) -{ - int i; - - for (i = 0; i < size; i++) { - if (strcmp(table[i].m_str, str) == 0) { - break; - } - } - return i; -} - -static int vstbl_get_val(const vstbl_entry * table, int index) -{ - return table[index].m_val; -} - - -static SCM -g_rc_mode_general(SCM scmmode, - const char *rc_name, - int *mode_var, - const vstbl_entry *table, - int table_size) -{ - int index; - char *mode; - - SCM_ASSERT (scm_is_string (scmmode), scmmode, - SCM_ARG1, rc_name); - - mode = SCM_STRING_CHARS (scmmode); - - index = vstbl_lookup_str(table, table_size, mode); - - /* no match? */ - if(index == table_size) { - fprintf(stderr, - "Invalid mode [%s] passed to %s\n", - mode, - rc_name); - return SCM_BOOL_F; - } - - *mode_var = vstbl_get_val(table, index); - - return SCM_BOOL_T; -} - -#define RETURN_G_RC_MODE(rc, var, size) \ - return g_rc_mode_general(mode, \ - (rc), \ - &(var), \ - mode_table, \ - size) - SCM g_rc_gschlas_version(SCM version) { -- 2.11.4.GIT