Commits

BarryFSmith committed 475446a

fixes for text based interactive processor of options

Comments (0)

Files changed (1)

src/sys/objects/aoptions.c

       if (str[0]) {
         next->set = PETSC_TRUE;
 
-        ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr);
+        ierr = PetscStrallocpy(str,(char**)&next->data);CHKERRQ(ierr);
       }
       break;
     case OPTION_LIST:
       if (str[0]) {
         PetscOptionsObject.changedmethod = PETSC_TRUE;
         next->set = PETSC_TRUE;
-        ierr = PetscStrcpy((char*)next->data,str);CHKERRQ(ierr);
+        ierr = PetscStrallocpy(str,(char**)&next->data);CHKERRQ(ierr);
       }
       break;
     default:
 
 
 */
-PetscErrorCode PetscOptionsAMSInput()
+PetscErrorCode PetscOptionsSAWsInput()
 {
   PetscErrorCode ierr;
   PetscOptions   next     = PetscOptionsObject.next;
   PetscFunctionBegin;
   if (PetscOptionsObject.next) {
     if (!PetscOptionsPublishCount) {
-#if defined(PETSC_HAVE_SAWS)
-      ierr = PetscOptionsAMSInput();CHKERRQ(ierr);
+#if defined(PETSC_HAVE_SAWS) && defined(foo)
+      ierr = PetscOptionsSAWsInput();CHKERRQ(ierr);
 #else
       ierr = PetscOptionsGetFromTextInput();CHKERRQ(ierr);
 #endif
         ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
         break;
       case OPTION_STRING:
-        ierr = PetscStrcpy(value,*(char**)PetscOptionsObject.next->data);CHKERRQ(ierr);
+        ierr = PetscStrcpy(value,(char*)PetscOptionsObject.next->data);CHKERRQ(ierr);
       case OPTION_STRING_ARRAY:
         sprintf(value,"%s",((char**)PetscOptionsObject.next->data)[0]);
         for (j=1; j<PetscOptionsObject.next->arraylength; j++) {
   PetscFunctionBegin;
   if (!PetscOptionsPublishCount) {
     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
-    ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
-
-    *(const char**)amsopt->data = defaultv;
+    ierr = PetscStrallocpy(defaultv,(char**)&amsopt->data);CHKERRQ(ierr);
   }
   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {
   PetscFunctionBegin;
   if (!PetscOptionsPublishCount) {
     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_LIST,&amsopt);CHKERRQ(ierr);
-    ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
-
-    *(const char**)amsopt->data = defaultv;
-
+    ierr = PetscStrallocpy(defaultv,(char**)&amsopt->data);CHKERRQ(ierr);
     amsopt->flist = list;
   }
   ierr = PetscOptionsGetString(PetscOptionsObject.prefix,opt,value,len,set);CHKERRQ(ierr);
   PetscFunctionBegin;
   if (!PetscOptionsPublishCount) {
     ierr = PetscOptionsCreate_Private(opt,ltext,man,OPTION_ELIST,&amsopt);CHKERRQ(ierr);
-    ierr = PetscMalloc(sizeof(char*),&amsopt->data);CHKERRQ(ierr);
-
-    *(const char**)amsopt->data = defaultv;
-
+    ierr = PetscStrallocpy(defaultv,(char**)&amsopt->data);CHKERRQ(ierr);
     amsopt->list  = list;
     amsopt->nlist = ntext;
   }
   PetscFunctionBegin;
   if (!PetscOptionsPublishCount) {
     ierr = PetscOptionsCreate_Private(opt,text,man,OPTION_STRING,&amsopt);CHKERRQ(ierr);
-    ierr = PetscMalloc(sizeof(PetscInt),&amsopt->data);CHKERRQ(ierr);
-
-    *(const char**)amsopt->data = "";
+    ierr = PetscStrallocpy("",(char**)&amsopt->data);CHKERRQ(ierr);
   }
   ierr = PetscOptionsGetViewer(PetscOptionsObject.comm,PetscOptionsObject.prefix,opt,viewer,format,set);CHKERRQ(ierr);
   if (PetscOptionsObject.printhelp && PetscOptionsPublishCount == 1 && !PetscOptionsObject.alreadyprinted) {