Index: trunk/src/conf.c =================================================================== --- trunk/src/conf.c (revision 1915) +++ trunk/src/conf.c (revision 1916) @@ -379,27 +379,15 @@ return res; } -/* merge main subtree of a patch */ -int conf_merge_patch_recurse(lht_node_t *sect, int default_prio, conf_policy_t default_policy, const char *path_prefix) -{ - lht_dom_iterator_t it; - lht_node_t *n, *h; - char path[256], *pathe; - char name[256], *namee; - int nl, ppl = strlen(path_prefix), res = 0; - conf_native_t *target; +int conf_merge_patch_recurse(lht_node_t *sect, int default_prio, conf_policy_t default_policy, const char *path_prefix); - memcpy(path, path_prefix, ppl); - path[ppl] = '/'; - pathe = path + ppl + 1; +void d1() {} - for(n = lht_dom_first(&it, sect); n != NULL; n = lht_dom_next(&it)) { - nl = strlen(n->name); - memcpy(pathe, n->name, nl); - namee = pathe+nl; - *namee = '\0'; - target = conf_get_field(path); - +int conf_merge_patch_item(const char *path, lht_node_t *n, int default_prio, conf_policy_t default_policy) +{ + conf_native_t *target = conf_get_field(path); + int res = 0; +if (strstr(path, "unit") != NULL) d1(); switch(n->type) { case LHT_TEXT: if (target == NULL) { @@ -426,6 +414,29 @@ hid_cfg_error(n, "Attempt to initialize a scalar with a list - this node should be a text node\n"); break; } + return res; +} + + +/* merge main subtree of a patch */ +int conf_merge_patch_recurse(lht_node_t *sect, int default_prio, conf_policy_t default_policy, const char *path_prefix) +{ + lht_dom_iterator_t it; + lht_node_t *n, *h; + char path[256], *pathe; + char name[256], *namee; + int nl, ppl = strlen(path_prefix), res = 0; + + memcpy(path, path_prefix, ppl); + path[ppl] = '/'; + pathe = path + ppl + 1; + + for(n = lht_dom_first(&it, sect); n != NULL; n = lht_dom_next(&it)) { + nl = strlen(n->name); + memcpy(pathe, n->name, nl); + namee = pathe+nl; + *namee = '\0'; + res |= conf_merge_patch_item(path, n, default_prio, default_policy); } return res; } @@ -458,14 +469,20 @@ { int n, ret = 0; for(n = 0; n < CFR_max; n++) { - lht_node_t *r; + lht_node_t *r, *r2; if (conf_root[n] == NULL) continue; for(r = conf_root[n]->root->data.list.first; r != NULL; r = r->next) { - if (path != NULL) - r = lht_tree_path_(r->doc, r, path, 1, 0, NULL); - if ((r != NULL) && (conf_merge_patch(r, conf_default_prio[n]) != 0)) - ret = -1; + if (path != NULL) { + conf_policy_t gpolicy = POL_OVERWRITE; + r2 = lht_tree_path_(r->doc, r, path, 1, 0, NULL); + get_hash_policy(&gpolicy, r, "policy"); + if ((r2 == NULL) || (conf_merge_patch_item(path, r2, conf_default_prio[n], gpolicy) != 0)) + ret = -1; + } + else + if (conf_merge_patch(r, conf_default_prio[n]) != 0) + ret = -1; } } return ret; @@ -506,15 +523,24 @@ (*h)->notify_conf_changed(); } -void conf_update() +void conf_update(const char *path) { - /* clear all memory-bin data first */ - htsp_entry_t *e; - conf_fields_foreach(e) - conf_field_clear(e->value); + /* clear memory-bin data first */ + if (path == NULL) { + htsp_entry_t *e; + conf_fields_foreach(e) + conf_field_clear(e->value); + } + else { + conf_native_t *n; + n = conf_get_field(path); + if (n == NULL) + return; + conf_field_clear(n); + } /* merge all memory-lht data to memory-bin */ - conf_merge_all(NULL); + conf_merge_all(path); conf_core_postproc(); conf_notify_hids(); } Index: trunk/src/conf.h =================================================================== --- trunk/src/conf.h (revision 1915) +++ trunk/src/conf.h (revision 1916) @@ -132,7 +132,7 @@ void conf_load_all(void); /* Update the binary representation from the memory-lht representation */ -void conf_update(void); +void conf_update(const char *path); conf_native_t *conf_get_field(const char *path); void conf_reg_field_(void *value, int array_size, conf_native_type_t type, const char *path, const char *desc); @@ -218,18 +218,13 @@ char *__tmp__ = pcb_strdup_printf(fmt, new_val); \ conf_set(CFR_DESIGN, path, -1, __tmp__, POL_OVERWRITE); \ free(__tmp__); \ + conf_update(path); \ } while(0) -#define conf_SET_design(path, fmt, new_val) \ -do { \ - conf_set_design(path, fmt, new_val); \ - conf_update(); \ -} while(0) - #define conf_set_editor(field, val) \ do { \ conf_set(CFR_DESIGN, "editor/" #field, -1, val ? "1" : "0", POL_OVERWRITE); \ - conf_update(); \ + conf_update("editor/" #field); \ } while(0) #define conf_toggle_editor(field) \ Index: trunk/src/conf_act.c =================================================================== --- trunk/src/conf_act.c (revision 1915) +++ trunk/src/conf_act.c (revision 1916) @@ -87,7 +87,7 @@ Message("conf(set) failed.\n"); return 1; } - conf_update(); + conf_update(path); } else if (NSTRCMP(cmd, "toggle") == 0) { @@ -128,7 +128,7 @@ Message("Can not toggle '%s': failed to set new value\n", argv[1]); return 1; } - conf_update(); + conf_update(argv[1]); } else if (NSTRCMP(cmd, "toggle") == 0) { @@ -140,7 +140,7 @@ return 1; } conf_reset(role, ""); - conf_update(); + conf_update(argv[1]); } else { Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 1915) +++ trunk/src/gui_act.c (revision 1916) @@ -1062,7 +1062,7 @@ case LINE_TYPE: notify_crosshair_change(false); conf_set_design("design/line_thickness", "%$mS", ((LineTypePtr) ptr2)->Thickness); - conf_SET_design("design/keepaway", "%$mS", ((LineTypePtr) ptr2)->Clearance / 2); + conf_set_design("design/keepaway", "%$mS", ((LineTypePtr) ptr2)->Clearance / 2); layer = (LayerTypePtr) ptr1; if (conf_core.editor.mode != LINE_MODE) SetMode(LINE_MODE); @@ -1073,7 +1073,7 @@ case ARC_TYPE: notify_crosshair_change(false); conf_set_design("design/line_thickness", "%$mS", ((ArcTypePtr) ptr2)->Thickness); - conf_SET_design("design/keepaway", "%$mS", ((ArcTypePtr) ptr2)->Clearance / 2); + conf_set_design("design/keepaway", "%$mS", ((ArcTypePtr) ptr2)->Clearance / 2); layer = (LayerTypePtr) ptr1; if (conf_core.editor.mode != ARC_MODE) SetMode(ARC_MODE); @@ -1089,7 +1089,7 @@ notify_crosshair_change(false); conf_set_design("design/via_thickness", "%$mS", ((PinTypePtr) ptr2)->Thickness); conf_set_design("design/via_drilling_hole", "%$mS", ((PinTypePtr) ptr2)->DrillingHole); - conf_SET_design("design/keepaway", "%$mS", ((PinTypePtr) ptr2)->Clearance / 2); + conf_set_design("design/keepaway", "%$mS", ((PinTypePtr) ptr2)->Clearance / 2); if (conf_core.editor.mode != VIA_MODE) SetMode(VIA_MODE); notify_crosshair_change(true); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 1915) +++ trunk/src/main.c (revision 1916) @@ -495,7 +495,7 @@ /* plugins may have installed their new fields, reinterpret the config (memory lht -> memory bin) to get the new fields */ - conf_update(); + conf_update(NULL); if (main_action != NULL) { hid_parse_command(main_action); Index: trunk/src/set.c =================================================================== --- trunk/src/set.c (revision 1915) +++ trunk/src/set.c (revision 1916) @@ -79,7 +79,7 @@ void SetLineSize(Coord Size) { if (Size >= MIN_LINESIZE && Size <= MAX_LINESIZE) { - conf_SET_design("design/line_thickness", "%$mS", Size); + conf_set_design("design/line_thickness", "%$mS", Size); if (conf_core.editor.auto_drc) FitCrosshairIntoGrid(Crosshair.X, Crosshair.Y); } @@ -91,7 +91,7 @@ void SetViaSize(Coord Size, bool Force) { if (Force || (Size <= MAX_PINORVIASIZE && Size >= MIN_PINORVIASIZE && Size >= conf_core.design.via_drilling_hole + MIN_PINORVIACOPPER)) { - conf_SET_design("design/via_thickness", "%$mS", Size); + conf_set_design("design/via_thickness", "%$mS", Size); } } @@ -101,7 +101,7 @@ void SetViaDrillingHole(Coord Size, bool Force) { if (Force || (Size <= MAX_PINORVIASIZE && Size >= MIN_PINORVIAHOLE && Size <= conf_core.design.via_thickness - MIN_PINORVIACOPPER)) { - conf_SET_design("design/via_drilling_hole", "%$mS", Size); + conf_set_design("design/via_drilling_hole", "%$mS", Size); } } @@ -110,7 +110,7 @@ conf_set_design("design/line_thickness", "%$mS", rst->Thick); conf_set_design("design/via_thickness", "%$mS", rst->Diameter); conf_set_design("design/via_drilling_hole", "%$mS", rst->Hole); - conf_SET_design("design/keepaway", "%$mS", rst->Keepaway); + conf_set_design("design/keepaway", "%$mS", rst->Keepaway); } /* --------------------------------------------------------------------------- @@ -119,7 +119,7 @@ void SetKeepawayWidth(Coord Width) { if (Width <= MAX_LINESIZE) { - conf_SET_design("design/keepaway", "%$mS", Width); + conf_set_design("design/keepaway", "%$mS", Width); } } @@ -129,7 +129,7 @@ void SetTextScale(int Scale) { if (Scale <= MAX_TEXTSCALE && Scale >= MIN_TEXTSCALE) { - conf_SET_design("design/text_scale", "%d", Scale); + conf_set_design("design/text_scale", "%d", Scale); } } @@ -166,7 +166,7 @@ { if (Number >= 0 && Number < MAX_BUFFER) { conf_set_design("editor/buffer_number", "%d", Number); - conf_update(); + conf_update("editor/buffer_number"); /* do an update on the crosshair range */ SetCrosshairRangeToBuffer(); @@ -234,7 +234,7 @@ Crosshair.AttachedLine.Point1.Y = Crosshair.AttachedLine.Point2.Y = Crosshair.AttachedBox.Point1.Y; sprintf(sMode, "%d", Mode); conf_set(CFR_DESIGN, "editor/mode", -1, sMode, POL_OVERWRITE); - conf_update(); + conf_update("editor/mode"); AdjustAttachedObjects(); } else { @@ -252,7 +252,7 @@ sprintf(sMode, "%d", Mode); conf_set(CFR_DESIGN, "editor/mode", -1, sMode, POL_OVERWRITE); - conf_update(); + conf_update("editor/mode"); if (Mode == PASTEBUFFER_MODE) /* do an update on the crosshair range */ Index: trunk/src_plugins/export_gerber/gerber.c =================================================================== --- trunk/src_plugins/export_gerber/gerber.c (revision 1915) +++ trunk/src_plugins/export_gerber/gerber.c (revision 1916) @@ -599,7 +599,7 @@ maybe_close_f(f); f = NULL; hid_restore_layer_ons(save_ons); - conf_update(); /* resotre forced sets */ + conf_update(NULL); /* resotre forced sets */ } static void gerber_parse_arguments(int *argc, char ***argv) Index: trunk/src_plugins/export_png/png.c =================================================================== --- trunk/src_plugins/export_png/png.c (revision 1915) +++ trunk/src_plugins/export_png/png.c (revision 1916) @@ -520,7 +520,7 @@ hid_expose_callback(&png_hid, bounds, 0); memcpy(LayerStack, saved_layer_stack, sizeof(LayerStack)); - conf_update(); /* restore forced sets */ + conf_update(NULL); /* restore forced sets */ } static void blend(color_struct * dest, float a_amount, color_struct * a, color_struct * b) Index: trunk/src_plugins/export_ps/eps.c =================================================================== --- trunk/src_plugins/export_ps/eps.c (revision 1915) +++ trunk/src_plugins/export_ps/eps.c (revision 1916) @@ -303,7 +303,7 @@ fprintf(f, "%%%%EOF\n"); memcpy(LayerStack, saved_layer_stack, sizeof(LayerStack)); - conf_update(); /* restore forced sets */ + conf_update(NULL); /* restore forced sets */ } static void eps_do_export(HID_Attr_Val * options) Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 1915) +++ trunk/src_plugins/export_ps/ps.c (revision 1916) @@ -700,7 +700,7 @@ fprintf(the_file, "showpage\n"); memcpy(LayerStack, saved_layer_stack, sizeof(LayerStack)); - conf_update(); /* restore forced sets */ + conf_update(NULL); /* restore forced sets */ } static void ps_do_export(HID_Attr_Val * options) Index: trunk/src_plugins/fontmode/fontmode.c =================================================================== --- trunk/src_plugins/fontmode/fontmode.c (revision 1915) +++ trunk/src_plugins/fontmode/fontmode.c (revision 1916) @@ -87,7 +87,7 @@ conf_set_design("design/bloat", "%s", "1"); PCB->Bloat = 1; conf_set_design("design/shrink", "%s", "1"); PCB->Shrink = 1; conf_set_design("design/min_wid", "%s", "1"); PCB->minWid = 1; - conf_SET_design("design/min_slk", "%s", "1"); PCB->minSlk = 1; + conf_set_design("design/min_slk", "%s", "1"); PCB->minSlk = 1; MoveLayerToGroup(max_copper_layer + COMPONENT_LAYER, 0); MoveLayerToGroup(max_copper_layer + SOLDER_LAYER, 1); Index: trunk/src_plugins/hid_gtk/gtkhid-main.c =================================================================== --- trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 1915) +++ trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 1916) @@ -137,7 +137,7 @@ ghid_pcb_to_event_coords(center_x, center_y, &widget_x, &widget_y); conf_set_design("editor/view/flip_x", "%d", conf_core.editor.view.flip_x != flip_x); - conf_SET_design("editor/view/flip_y", "%d", conf_core.editor.view.flip_y != flip_y); + conf_set_design("editor/view/flip_y", "%d", conf_core.editor.view.flip_y != flip_y); /* Pan the board so the center location remains in the same place */ ghid_pan_view_abs(center_x, center_y, widget_x, widget_y); @@ -1624,7 +1624,7 @@ if (new_unit != NULL && new_unit->allow != NO_PRINT) { #warning TODO: decide what to do with this: some fields are just overwritten by hand conf_set(CFR_DESIGN, "editor/grid_unit", -1, argv[0], POL_OVERWRITE); - conf_update(); + conf_update("editor/grid_unit"); AttributePut(PCB, "PCB::grid::unit", argv[0]); } Index: trunk/src_plugins/hid_gtk/gui-config.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-config.c (revision 1915) +++ trunk/src_plugins/hid_gtk/gui-config.c (revision 1916) @@ -762,7 +762,7 @@ conf_set(CFR_PROJECT, "design/max_width", -1, s, POL_OVERWRITE); pcb_sprintf(s, "%$mS", (new_board_height)); conf_set(CFR_PROJECT, "design/max_height", -1, s, POL_OVERWRITE); - conf_update(); + conf_update("design/max_height"); #warning TODO: what? this could be removed once user can select where to save active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(use_board_size_default_button)); @@ -779,7 +779,7 @@ conf_set_design("design/min_slk", "%$mS", PCB->minSlk); conf_set_design("design/poly_isle_area", "%f", PCB->IsleArea); conf_set_design("design/min_drill", "%$mS", PCB->minDrill); - conf_SET_design("design/min_ring", "%$mS", PCB->minRing); + conf_set_design("design/min_ring", "%$mS", PCB->minRing); ghidgui->config_modified = TRUE; } @@ -1512,7 +1512,7 @@ printf("COLOR IDX: %d\n", ci->idx); conf_set(CFR_PROJECT, ci->cfg->hash_path, ci->idx, str, POL_OVERWRITE); - conf_update(); + conf_update(ci->cfg->hash_path); #warning TODO: check whether we need to free this // g_free(str); Index: trunk/src_plugins/hid_gtk/gui-top-window.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-top-window.c (revision 1915) +++ trunk/src_plugins/hid_gtk/gui-top-window.c (revision 1916) @@ -739,7 +739,7 @@ static void route_styles_edited_cb(GHidRouteStyleSelector * rss, gboolean save, gpointer data) { if (save) { - conf_SET_design(conf_core.design.routes, "%s", make_route_string(PCB->RouteStyle, NUM_STYLES)); + conf_set_design(conf_core.design.routes, "%s", make_route_string(PCB->RouteStyle, NUM_STYLES)); ghidgui->config_modified = TRUE; ghid_config_files_write(); } Index: trunk/src_plugins/hid_lesstif/dialogs.c =================================================================== --- trunk/src_plugins/hid_lesstif/dialogs.c (revision 1915) +++ trunk/src_plugins/hid_lesstif/dialogs.c (revision 1916) @@ -1069,7 +1069,7 @@ conf_set_design("design/min_wid", "%s", sz_drc_wid); conf_set_design("design/min_slk", "%s", sz_drc_slk); conf_set_design("design/min_drill", "%s", sz_drc_drill); - conf_SET_design("design/min_ring", "%s", sz_drc_ring); + conf_set_design("design/min_ring", "%s", sz_drc_ring); SetCrosshairRange(0, 0, PCB->MaxWidth, PCB->MaxHeight); lesstif_pan_fixup(); Index: trunk/src_plugins/hid_lesstif/styles.c =================================================================== --- trunk/src_plugins/hid_lesstif/styles.c (revision 1915) +++ trunk/src_plugins/hid_lesstif/styles.c (revision 1916) @@ -151,16 +151,16 @@ n = GetValueEx(s, NULL, NULL, NULL, unit->suffix, NULL); switch (i) { case SSthick: - conf_SET_design("design/line_thickness", "%s", s); + conf_set_design("design/line_thickness", "%s", s); break; case SSdiam: - conf_SET_design("design/via_thickness", "%s", s); + conf_set_design("design/via_thickness", "%s", s); break; case SShole: - conf_SET_design("design/via_drilling_hole", "%s", s);; + conf_set_design("design/via_drilling_hole", "%s", s);; break; case SSkeep: - conf_SET_design("design/keepaway", "%s", s);; + conf_set_design("design/keepaway", "%s", s);; break; } update_style_buttons(); Index: trunk/src_plugins/io_pcb/parse_l.c =================================================================== --- trunk/src_plugins/io_pcb/parse_l.c (revision 1915) +++ trunk/src_plugins/io_pcb/parse_l.c (revision 1916) @@ -2530,7 +2530,7 @@ /* load config nodes not disabled above, from optional attributes */ io_pcb_attrib_a2c(Ptr); - conf_update(); + conf_update(NULL); } return retval; } Index: trunk/src_plugins/renumber/renumber.c =================================================================== --- trunk/src_plugins/renumber/renumber.c (revision 1915) +++ trunk/src_plugins/renumber/renumber.c (revision 1916) @@ -297,7 +297,7 @@ fclose(out); /* restore the unique flag setting */ - conf_update(); + conf_update(NULL); if (changed) {