Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 21450) +++ trunk/src/buffer.c (revision 21451) @@ -361,16 +361,17 @@ /* DOC: freerotatebuffer */ fgw_error_t pcb_act_FreeRotateBuffer(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - const char *angle_s = NULL; + char *angle_s = NULL; double ang; - PCB_ACT_MAY_CONVARG(1, FGW_STR, FreeRotateBuffer, angle_s = argv[1].val.str); + PCB_ACT_MAY_CONVARG(1, FGW_STR, FreeRotateBuffer, angle_s = pcb_strdup(argv[1].val.str)); PCB_ACT_IRES(0); if (angle_s == NULL) - angle_s = pcb_gui->prompt_for("Enter Rotation (degrees, CCW):", "0"); + angle_s = pcb_hid_prompt_for("Enter Rotation (degrees, CCW):", "0", "Rotation angle"); if ((angle_s == NULL) || (*angle_s == '\0')) { + free(angle_s); PCB_ACT_IRES(-1); return 0; } @@ -377,8 +378,11 @@ PCB_ACT_IRES(0); ang = strtod(angle_s, 0); - if (ang == 0) + free(angle_s); + if (ang == 0) { + PCB_ACT_IRES(-1); return 0; + } if ((ang < -360000) || (ang > +360000)) { pcb_message(PCB_MSG_ERROR, "Angle too large\n"); @@ -399,24 +403,27 @@ "empty, subcircuits are also scaled\n"; fgw_error_t pcb_act_ScaleBuffer(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - const char *sx = NULL; + char *sx = NULL; double x, y, th; int recurse = 0; char *end; - PCB_ACT_MAY_CONVARG(1, FGW_STR, ScaleBuffer, sx = argv[1].val.str); + PCB_ACT_MAY_CONVARG(1, FGW_STR, ScaleBuffer, sx = pcb_strdup(argv[1].val.str)); if (sx == NULL) - sx = pcb_gui->prompt_for("Enter scaling factor (unitless multiplier):", "1.0"); + sx = pcb_hid_prompt_for("Enter scaling factor (unitless multiplier):", "1.0", "scaling factor"); if ((sx == NULL) || (*sx == '\0')) { + free(sx); PCB_ACT_IRES(-1); return 0; } x = strtod(sx, &end); if (*end != '\0') { + free(sx); PCB_ACT_IRES(-1); return 0; } + free(sx); y = th = x; PCB_ACT_MAY_CONVARG(2, FGW_DOUBLE, ScaleBuffer, y = argv[2].val.nat_double); Index: trunk/src/change.c =================================================================== --- trunk/src/change.c (revision 21450) +++ trunk/src/change.c (revision 21451) @@ -767,22 +767,23 @@ goto subc_name; } } - name = pcb_gui->prompt_for("Enter text:", PCB_EMPTY(((pcb_text_t *)obj)->TextString)); + name = pcb_hid_prompt_for("Enter text:", PCB_EMPTY(((pcb_text_t *)obj)->TextString), "Change text"); break; case PCB_OBJ_SUBC: subc_name:; - name = pcb_gui->prompt_for("Subcircuit refdes:", PCB_EMPTY(((pcb_subc_t *)obj)->refdes)); + name = pcb_hid_prompt_for("Subcircuit refdes:", PCB_EMPTY(((pcb_subc_t *)obj)->refdes), "Change refdes"); break; default: term_name:; if (parent_subc != NULL) { - name = pcb_gui->prompt_for("Enter terminal ID:", PCB_EMPTY(obj->term)); + name = pcb_hid_prompt_for("Enter terminal ID:", PCB_EMPTY(obj->term), "Change terminal ID"); if (name != NULL) { pcb_term_undoable_rename(PCB, obj, name); pcb_draw(); } + free(name); return obj; } break; @@ -798,6 +799,7 @@ pcb_undo_inc_serial(); } pcb_draw(); + free(name); return obj; } return NULL; Index: trunk/src/change_act.c =================================================================== --- trunk/src/change_act.c (revision 21450) +++ trunk/src/change_act.c (revision 21451) @@ -515,15 +515,16 @@ /* change the layout's name */ case F_Layout: - name = pcb_gui->prompt_for(_("Enter the layout name:"), PCB_EMPTY(PCB->Name)); + name = pcb_hid_prompt_for("Enter the layout name:", PCB_EMPTY(PCB->Name), "Layout name"); /* NB: ChangeLayoutName takes ownership of the passed memory */ if (name && pcb_board_change_name(name)) pcb_board_set_changed_flag(pcb_true); + free(name); break; /* change the name of the active layer */ case F_Layer: - name = pcb_gui->prompt_for(_("Enter the layer name:"), PCB_EMPTY(CURRENT->name)); + name = pcb_hid_prompt_for("Enter the layer name:", PCB_EMPTY(CURRENT->name), "Layer name"); /* NB: pcb_layer_rename_ takes ownership of the passed memory */ if (name && (pcb_layer_rename_(CURRENT, name) == 0)) pcb_board_set_changed_flag(pcb_true); Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 21450) +++ trunk/src/file_act.c (revision 21451) @@ -126,7 +126,7 @@ if (argument_name) name = pcb_strdup(argument_name); else - name = pcb_gui->prompt_for("Enter the layout name:", ""); + name = pcb_hid_prompt_for("Enter the layout name:", "", "Layout name"); if (!name) return 1; Index: trunk/src/hid_dlg.c =================================================================== --- trunk/src/hid_dlg.c (revision 21450) +++ trunk/src/hid_dlg.c (revision 21451) @@ -55,8 +55,8 @@ return FGW_ERR_NOT_FOUND; } -static const char pcb_acts_PromptFor[] = "PromptFor([message[,default]])"; -static const char pcb_acth_PromptFor[] = "Prompt for a response."; +static const char pcb_acts_PromptFor[] = "PromptFor([message[,default[,title]]])"; +static const char pcb_acth_PromptFor[] = "Prompt for a string. Returns the string (or NULL on cancel)"; /* DOC: promptfor.html */ static fgw_error_t pcb_act_PromptFor(fgw_arg_t *res, int argc, fgw_arg_t *argv) { Index: trunk/src/rats_patch.c =================================================================== --- trunk/src/rats_patch.c (revision 21450) +++ trunk/src/rats_patch.c (revision 21451) @@ -384,7 +384,7 @@ static fgw_error_t pcb_act_ReplaceFootprint(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - const char *fpname = NULL; + char *fpname = NULL; int found = 0, len; pcb_subc_t *news, *placed; @@ -405,9 +405,9 @@ } /* fetch the name of the new footprint */ - PCB_ACT_MAY_CONVARG(1, FGW_STR, ReplaceFootprint, fpname = argv[1].val.str); + PCB_ACT_MAY_CONVARG(1, FGW_STR, ReplaceFootprint, fpname = pcb_strdup(argv[1].val.str)); if (fpname == NULL) { - fpname = pcb_gui->prompt_for("Footprint name", ""); + fpname = pcb_hid_prompt_for("Footprint name to use for replacement:", "", "Footprint"); if (fpname == NULL) { pcb_message(PCB_MSG_ERROR, "No footprint name supplied\n"); PCB_ACT_IRES(1); @@ -414,16 +414,20 @@ return 0; } } + else + fpname = pcb_strdup(fpname); /* check if the footprint is available */ pcb_buffer_load_footprint(&pcb_buffers[PCB_MAX_BUFFER-1], fpname, NULL); len = pcb_subclist_length(&pcb_buffers[PCB_MAX_BUFFER-1].Data->subc); if (len == 0) { + free(fpname); pcb_message(PCB_MSG_ERROR, "Footprint %s contains no subcircuits", fpname); PCB_ACT_IRES(1); return 0; } if (len > 1) { + free(fpname); pcb_message(PCB_MSG_ERROR, "Footprint %s contains multiple subcircuits", fpname); PCB_ACT_IRES(1); return 0; @@ -463,6 +467,7 @@ } PCB_END_LOOP; + free(fpname); PCB_ACT_IRES(0); return 0; } Index: trunk/src/tool_text.c =================================================================== --- trunk/src/tool_text.c (revision 21450) +++ trunk/src/tool_text.c (revision 21451) @@ -50,7 +50,7 @@ { char *string; - if ((string = pcb_gui->prompt_for(_("Enter text:"), "")) != NULL) { + if ((string = pcb_hid_prompt_for("Enter text:", "", "text")) != NULL) { if (strlen(string) > 0) { pcb_text_t *text; int flag = PCB_FLAG_CLEARLINE;